mommy
The atago project wrote these specs on its own initiative and runs them in its own CI, to exercise atago against a real program. They are not mommy’s official test suite, and the mommy project is not affiliated with atago.
Summary #
1 suite · 10 scenarios
Contents #
- mommy (a wrapper that must stay out of the way) — 10 scenarios
- the version and the manual are answered without running anything
- the wrapped command’s status comes back untouched
- the message stays off stdout unless it is asked for
- a status can be judged without running anything at all
- a pipeline is judged by its last command
- pipefail makes the head of the pipeline count, where the shell has it
- asking for pipefail where the shell has none is the shell’s error
- the message is a template the config fills in
- the environment is not the configuration
- the toggle is a file in the user’s state directory
mommy (a wrapper that must stay out of the way) #
mommy runs your command and says something encouraging about how it went. It keeps its own test suite in ShellSpec; what those tests check is pinned here from outside.
A wrapper has two obligations before anything else: pass the exit status through untouched, and stay off the wrapped command’s stdout. Both are asserted here for success, for failure, and for an arbitrary code, together with the flag that deliberately moves the message onto stdout. The messages themselves are made deterministic by a config file the scenario writes, so the assertions are about which list was chosen rather than about which sentence was drawn from it.
Source: test/e2e/thirdparty/mommy/mommy.atago.yaml
Scenario: the version and the manual are answered without running anything #
only when command -v mommy succeeds · skipped on Windows
Given #
- Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL, MANPATH.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
When #
mommy --version
mommy --help
mommy --help
Then #
- after
mommy --version:- exit code is
0 - stdout matches
/^mommy, v[0-9]+\.[0-9]+\.[0-9]+/
- exit code is
- after
mommy --help:- exit code is
0 - stdout contains
mommy - here to support you~,-s status, --status=status,-1 writes output to stdout instead of stderr~
- exit code is
- after
mommy --help:- exit code is
1 - stdout is empty
- stderr contains
mommy couldn't find the help page., matches/https://github\.com/fwdekker/mommy/blob/[0-9]+\.[0-9]+\.[0-9]+/README\.md/
- exit code is
Scenario: the wrapped command’s status comes back untouched #
only when command -v mommy succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="that went well"
MOMMY_ENCOURAGEMENTS="that did not go well"
When #
mommy -c ./mommy.conf true
mommy -c ./mommy.conf false
mommy -c ./mommy.conf sh -c "exit 42"
Then #
- after
mommy -c ./mommy.conf true:- exit code is
0 - stdout is empty
- stderr equals an exact value
- exit code is
- after
mommy -c ./mommy.conf false:- exit code is
1 - stdout is empty
- stderr equals an exact value
- exit code is
- after
mommy -c ./mommy.conf sh -c "exit 42":- exit code is
42 - stdout is empty
- stderr equals an exact value
- exit code is
Expected output #
expected stderr:
that went well~
expected stderr:
that did not go well~
expected stderr:
that did not go well~
Scenario: the message stays off stdout unless it is asked for #
only when command -v mommy succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="well done"
When #
mommy -c ./mommy.conf -e "echo the-real-output | wc -l"
mommy -c ./mommy.conf -1 true
Then #
- after
mommy -c ./mommy.conf -e "echo the-real-output | wc -l":- exit code is
0 - stdout equals an exact value
- stderr equals an exact value
- exit code is
- after
mommy -c ./mommy.conf -1 true:- exit code is
0 - stdout equals an exact value
- stderr is empty
- exit code is
Expected output #
expected stdout:
1
expected stderr:
well done~
expected stdout:
well done~
Scenario: a status can be judged without running anything at all #
only when command -v mommy succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="that went well"
MOMMY_ENCOURAGEMENTS="that did not go well"
When #
mommy -c ./mommy.conf -s 3 sh -c "touch never-created"
mommy -c ./mommy.conf -s 0
Then #
- after
mommy -c ./mommy.conf -s 3 sh -c "touch never-created":- exit code is
3 - stderr equals an exact value
- the step changed exactly created nothing, modified nothing, deleted nothing
- file
never-createddoes not exist
- exit code is
- after
mommy -c ./mommy.conf -s 0:- exit code is
0 - stderr equals an exact value
- exit code is
Expected output #
expected stderr:
that did not go well~
expected stderr:
that went well~
Scenario: a pipeline is judged by its last command #
only when command -v mommy succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="that went well"
MOMMY_ENCOURAGEMENTS="that did not go well"
When #
mommy -c ./mommy.conf -e "false | true"
Then #
- exit code is
0 - stderr equals an exact value
Expected output #
expected stderr:
that went well~
Scenario: pipefail makes the head of the pipeline count, where the shell has it #
only when sh -c "set -o pipefail" succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="that went well"
MOMMY_ENCOURAGEMENTS="that did not go well"
When #
mommy -c ./mommy.conf -p -e "false | true"
Then #
- exit code is
1 - stderr equals an exact value
Expected output #
expected stderr:
that did not go well~
Scenario: asking for pipefail where the shell has none is the shell’s error #
only when command -v mommy succeeds · skipped when sh -c "set -o pipefail" succeeds
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="that went well"
MOMMY_ENCOURAGEMENTS="that did not go well"
When #
mommy -c ./mommy.conf -p -e "false | true"
Then #
- exit code is
2 - stderr contains
set: Illegal option -o pipefail,that did not go well~
Scenario: the message is a template the config fills in #
only when command -v mommy succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_CAREGIVER="daddy"
MOMMY_SWEETIE="champ"
MOMMY_SUFFIX="!"
MOMMY_COMPLIMENTS="%%CAREGIVER%% is proud of %%SWEETIE%%"
When #
mommy -c ./mommy.conf true
Then #
- exit code is
0 - stderr equals an exact value
Expected output #
expected stderr:
daddy is proud of champ!
Scenario: the environment is not the configuration #
only when command -v mommy succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL, MOMMY_COMPLIMENTS.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="from the config file"
When #
mommy -c ./mommy.conf true
mommy -c ./mommy.conf true
Then #
- after
mommy -c ./mommy.conf true:- exit code is
0 - stderr equals an exact value
- exit code is
- after
mommy -c ./mommy.conf true:- exit code is
0 - stderr equals an exact value
- exit code is
Expected output #
expected stderr:
from the config file~
expected stderr:
from the config file~
Scenario: the toggle is a file in the user’s state directory #
only when command -v mommy succeeds · skipped on Windows
Given #
- Fixture file
mommy.confis created. - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: LC_ALL.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture mommy.conf:
MOMMY_COMPLIMENTS="that went well"
MOMMY_ENCOURAGEMENTS="that did not go well"
When #
mommy -t
mommy -c ./mommy.conf false
mommy -t
mommy -c ./mommy.conf true
Then #
- after
mommy -t:- exit code is
0 - stdout contains
mommy has been disabled for this user. - stderr is empty
- the step changed exactly created
.atago-home/.local/state/mommy/toggle, modified nothing, deleted nothing
- exit code is
- after
mommy -c ./mommy.conf false:- exit code is
0 - stdout is empty
- stderr is empty
- exit code is
- after
mommy -t:- exit code is
0 - stdout contains
mommy has been enabled for this user.
- exit code is
- after
mommy -c ./mommy.conf true:- exit code is
0 - stderr equals an exact value
- exit code is
Expected output #
expected stderr:
that went well~