This commit is contained in:
Jack Halford 2017-03-29 15:27:59 +02:00
commit 8d589542dd
227 changed files with 2834 additions and 131 deletions

259
42sh/42ShellTester/logmini Normal file
View file

@ -0,0 +1,259 @@
...x...~......xx........~...........~.....~...........
----------------------------------------------------------------
minishell/binary/004-binary-test-empty-path (FAILED)
Description:
 The purpose of this test is to check that the Shell finds binaries that are located in the current directory when the environment variable PATH is empty.
Before test:
 01: export PATH=""
STDIN:
 01: write_on_stdout "TOKEN201703291444"
STDOUT:
 FAILURE expected_to match_regex `TOKEN201703291444`
 (no output)
STDERR:
 FAILURE expected_to be_empty
 01: ../../42sh: command not found: write_on_stdout
MISC:
 FAILURE expected_to exit_with_status `0`
----------------------------------------------------------------
minishell/binary/008-binary-too-many-symbolic-links-encountered (WARNING)
Description:
 The purpose of this test is to check that trying to execute a path that encounters an infinite loop of symbolic link results in an error on standard error and a failure exit status.
Before test:
 01: rm -rf ./symbolic_link1 ./symbolic_link2 ./symbolic_link3
02: ln -s ./symbolic_link1 ./symbolic_link2
03: ln -s ./symbolic_link2 ./symbolic_link3
04: ln -s ./symbolic_link3 ./symbolic_link1
STDIN:
 01: ./symbolic_link1
STDOUT:
 SUCCESS might be_empty
 (no output)
STDERR:
 SUCCESS expected_to_not be_empty
 WARNING might match_regex `[Tt]oo many.*symbolic links`
 01: ../../42sh: ./symbolic_link1: no such file or directory
MISC:
 SUCCESS expected_to_not exit_with_status 0
----------------------------------------------------------------
minishell/builtins/cd/007-symbolic-link (FAILED)
Description:
 The purpose of this test is to check that using a symbolic link as first argument with the builtin `cd` results in moving the linked directory.
Before test:
 01: rm -f "./symbolic_link"
02: mkdir -p "./sub_directory"
03: ln -s "./sub_directory" "./symbolic_link"
STDIN:
 01: cd symbolic_link
02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd
03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_env
STDOUT:
 SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD$`
 FAILURE expected_to match_regex `^PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/symbolic_link$`
 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD
02: ------------------------------
03: TERM_PROGRAM=iTerm.app
04: TERM=screen-256color
05: SHELL=/bin/zsh
06: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp
07: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/
08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.4f2AkmTXni/Render
09: TERM_PROGRAM_VERSION=3.0.10
10: TERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0
11: ZSH=/Users/ariard/.oh-my-zsh
12: USER=ariard
13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.VotSnLjyD2/Listeners
14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0
15: PAGER=less
16: TMUX=/private/tmp/tmux-18965/default,460,2
17: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches
18: LSCOLORS=Gxfxcxdxbxegedabagacad
19: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin
20: MAIL=ariard@student.42.fr
21: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory
22: LANG=en_US.UTF-8
23: ITERM_PROFILE=Default
24: XPC_FLAGS=0x0
25: TMUX_PANE=%9
26: XPC_SERVICE_NAME=0
27: SHLVL=5
28: HOME=/Users/ariard
29: COLORFGBG=7;0
30: ITERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0
31: LOGNAME=ariard
32: LESS=-R
33: LC_CTYPE=en_US.UTF-8
34: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/
35: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester/tmp
36: _=../../42sh
37: ?=0
38: ------------------------------
39: TOTAL ENVIRONMENT VARIABLES: 35
STDERR:
 SUCCESS expected_to be_empty
 (no output)
----------------------------------------------------------------
minishell/builtins/cd/008-symbolic-link-2 (FAILED)
Description:
 The purpose of this test is to check that using a symbolic link as first argument with the builtin `cd` results in moving to the linked directory. In this test, the directory is linked with to chained symbolic links.
Before test:
 01: rm -f "./symbolic_link1" "./symbolic_link2"
02: mkdir -p "./sub_directory"
03: ln -s "./sub_directory" "./symbolic_link1"
04: ln -s "./symbolic_link1" "./symbolic_link2"
STDIN:
 01: cd symbolic_link2
02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd
03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_env
STDOUT:
 SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD$`
 FAILURE expected_to match_regex `^PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/symbolic_link2$`
 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD
02: ------------------------------
03: TERM_PROGRAM=iTerm.app
04: TERM=screen-256color
05: SHELL=/bin/zsh
06: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp
07: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/
08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.4f2AkmTXni/Render
09: TERM_PROGRAM_VERSION=3.0.10
10: TERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0
11: ZSH=/Users/ariard/.oh-my-zsh
12: USER=ariard
13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.VotSnLjyD2/Listeners
14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0
15: PAGER=less
16: TMUX=/private/tmp/tmux-18965/default,460,2
17: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches
18: LSCOLORS=Gxfxcxdxbxegedabagacad
19: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin
20: MAIL=ariard@student.42.fr
21: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory
22: LANG=en_US.UTF-8
23: ITERM_PROFILE=Default
24: XPC_FLAGS=0x0
25: TMUX_PANE=%9
26: XPC_SERVICE_NAME=0
27: SHLVL=5
28: HOME=/Users/ariard
29: COLORFGBG=7;0
30: ITERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0
31: LOGNAME=ariard
32: LESS=-R
33: LC_CTYPE=en_US.UTF-8
34: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/
35: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester/tmp
36: _=../../42sh
37: ?=0
38: ------------------------------
39: TOTAL ENVIRONMENT VARIABLES: 35
STDERR:
 SUCCESS expected_to be_empty
 (no output)
----------------------------------------------------------------
minishell/builtins/cd/errors/005-too-many-symbolic-links-encountered (WARNING)
Description:
 The purpose of this test is to check that using a symbolic link resulting in ELOOP error as first argument with the builtin `cd` results in error and not changing current directory.
Before test:
 01: rm -f "./symbolic_link1" "./symbolic_link2" "./symbolic_link3"
02: ln -s "./symbolic_link1" "./symbolic_link2"
03: ln -s "./symbolic_link2" "./symbolic_link3"
04: ln -s "./symbolic_link3" "./symbolic_link1"
STDIN:
 01: cd symbolic_link1
02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd
STDOUT:
 SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD`
 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD
STDERR:
 SUCCESS expected_to_not be_empty
 WARNING might match_regex `[Tt]oo many.*symbolic links`
 01: ../../42sh: cd : symbolic_link1: No such file or directory
----------------------------------------------------------------
minishell/builtins/env/errors/001-command-not-found (WARNING)
Description:
 The purpose of this test is to check that using the builtin `env` with an invalid binary as argument results in an error and failure exit status.
Before test:
 01: rm -f "./invalid_binary"
STDIN:
 01: env ./invalid_binary
STDOUT:
 (no output)
STDERR:
 SUCCESS expected_to_not be_empty
 WARNING might match_regex `[Cc]ommand not found`
 01: ../../42sh: env: ./invalid_binary: No such file or directory
MISC:
 SUCCESS expected_to_not exit_with_status `0`
----------------------------------------------------------------
minishell/builtins/exit/errors/001-too-many-args (WARNING)
Description:
 The purpose of this test is to check that using a wrong number of arguments with the builtin `exit` does not result in the Shell termination but an error on standard error.
STDIN:
 01: exit 21 42
02: ./write_on_stdout TOKEN201703291444
STDOUT:
 SUCCESS expected_to match_regex `TOKEN201703291444`
 01: TOKEN201703291444
STDERR:
 SUCCESS expected_to_not be_empty
 WARNING might match_regex `([Tt]oo many arguments|[Aa]rgument list too long)`
 01: ../../42sh: exit: too many argument required
MISC:
 SUCCESS expected_to exit_with_status `0`
Total tests: 54
Total failed tests: 3
Total pending tests: 0

View file

@ -0,0 +1,9 @@
# bonuses
*[spec](..) > bonuses*
* [builtins](./builtins)
* [inline-environment-variable](./inline-environment-variable)
* [redirections](./redirections)
* [separators](./separators)
* [tilde-expansion](./tilde-expansion)

View file

@ -0,0 +1,5 @@
# builtins
*[spec > bonuses](..) > builtins*
* [env](./env)

View file

@ -0,0 +1,61 @@
# 001-unset-variables
*[spec > bonuses > builtins > env](..) > 001-unset-variables*
The purpose of this test is to check that the builtin `env` implement the option `-u` to unset environment variables.
### What is done before test
```bash
export TESTVARIABLE="${GLOBAL_TOKEN}"
```
### Shell commands that are sent to the standard entry
```bash
env -u HOME -u PATH -u TESTVARIABLE ./display_env
```
### What is expected on standard output
```bash
expected_to_not match_regex "HOME="
expected_to_not match_regex "PATH="
expected_to_not match_regex "TESTVARIABLE="
```
### What is expected on error output
```bash
expected_to be_empty
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
export TESTVARIABLE="${GLOBAL_TOKEN}"

View file

@ -0,0 +1 @@
The purpose of this test is to check that the builtin `env` implement the option `-u` to unset environment variables.

View file

@ -0,0 +1 @@
`env -u` is not registered in the POSIX standard.

View file

@ -0,0 +1 @@
expected_to be_empty

View file

@ -0,0 +1 @@
env -u HOME -u PATH -u TESTVARIABLE ./display_env

View file

@ -0,0 +1,3 @@
expected_to_not match_regex "HOME="
expected_to_not match_regex "PATH="
expected_to_not match_regex "TESTVARIABLE="

View file

@ -0,0 +1,61 @@
# 002-unset-and-set-variable
*[spec > bonuses > builtins > env](..) > 002-unset-and-set-variable*
The purpose of this test is to check if env -u works to unset variables for a given binary, we are also checking if an argument not prefix with -u is add to the environment of the given binary.### What is done before test
```bash
# unset all environment variables except PATH
for VARIABLE in $(env | awk 'BEGIN {FS="="} $0 !~ /^PATH/ {print $1}'); do unset "${VARIABLE}"; done;
export HOME="/my/home"
```
### Shell commands that are sent to the standard entry
```bash
env -u HOME TESTVARIABLE=${GLOBAL_TOKEN} ./display_env
```
### What is expected on standard output
```bash
expected_to match_regex "^TESTVARIABLE=${GLOBAL_TOKEN}$"
expected_to_not match_regex "^HOME="
```
### What is expected on error output
```bash
expected_to be_empty
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1,4 @@
# unset all environment variables except PATH
for VARIABLE in $(env | awk 'BEGIN {FS="="} $0 !~ /^PATH/ {print $1}'); do unset "${VARIABLE}"; done;
export HOME="/my/home"

View file

@ -0,0 +1 @@
The purpose of this test is to check if env -u works to unset variables for a given binary, we are also checking if an argument not prefix with -u is add to the environment of the given binary.

View file

@ -0,0 +1 @@
expected_to be_empty

View file

@ -0,0 +1 @@
env -u HOME TESTVARIABLE=${GLOBAL_TOKEN} ./display_env

View file

@ -0,0 +1,2 @@
expected_to match_regex "^TESTVARIABLE=${GLOBAL_TOKEN}$"
expected_to_not match_regex "^HOME="

View file

@ -0,0 +1,6 @@
# env
*[spec > bonuses > builtins](..) > env*
* [001-unset-variables](./001-unset-variables)
* [002-unset-and-set-variable](./002-unset-and-set-variable)

View file

@ -0,0 +1,60 @@
# 001-modifies-child-environment-1
*[spec > bonuses > inline-environment-variable](..) > 001-modifies-child-environment-1*
The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline.
### What is done before test
```bash
unset "${GLOBAL_TOKEN}_VARIABLE"
```
### Shell commands that are sent to the standard entry
```bash
${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE ./display_env
./display_env
```
### What is expected on standard output
```bash
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE$" once
```
### What is expected on error output
```bash
expected_to be_empty
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
unset "${GLOBAL_TOKEN}_VARIABLE"

View file

@ -0,0 +1 @@
The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline.

View file

@ -0,0 +1,2 @@
${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE ./display_env
./display_env

View file

@ -0,0 +1 @@
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE$" once

View file

@ -0,0 +1,62 @@
# 002-modifies-child-environment-2
*[spec > bonuses > inline-environment-variable](..) > 002-modifies-child-environment-2*
The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline.
### What is done before test
```bash
unset "${GLOBAL_TOKEN}_VARIABLE"
```
### Shell commands that are sent to the standard entry
```bash
${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1 ${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2 ${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3 ./display_env
./display_env
```
### What is expected on standard output
```bash
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1$" once
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2$" once
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3$" once
```
### What is expected on error output
```bash
expected_to be_empty
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
unset "${GLOBAL_TOKEN}_VARIABLE"

View file

@ -0,0 +1 @@
The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline.

View file

@ -0,0 +1,2 @@
${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1 ${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2 ${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3 ./display_env
./display_env

View file

@ -0,0 +1,3 @@
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1$" once
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2$" once
expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3$" once

View file

@ -0,0 +1,71 @@
# 003-modifies-PATH-only
*[spec > bonuses > inline-environment-variable](..) > 003-modifies-PATH-only*
The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline.
### What is done before test
```bash
rm -rf "temporary_directory"
mkdir -p "temporary_directory"
cd "temporary_directory"
```
### Shell commands that are sent to the standard entry
```bash
PATH=.. write_on_stdout ${GLOBAL_TOKEN}
exit_with_status 42
```
### What is expected on standard output
```bash
expected_to match_regex "^${GLOBAL_TOKEN}$"
```
### What is expected on error output
```bash
expected_to_not be_empty
might match_regex "[Cc]ommand not found"
```
### What miscellaneous behaviors are expected
```bash
expected_to_not exit_with_status "42"
expected_to_not exit_with_status "0"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1,3 @@
rm -rf "temporary_directory"
mkdir -p "temporary_directory"
cd "temporary_directory"

View file

@ -0,0 +1 @@
The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline.

View file

@ -0,0 +1,2 @@
expected_to_not exit_with_status "42"
expected_to_not exit_with_status "0"

View file

@ -0,0 +1,2 @@
expected_to_not be_empty
might match_regex "[Cc]ommand not found"

View file

@ -0,0 +1,2 @@
PATH=.. write_on_stdout ${GLOBAL_TOKEN}
exit_with_status 42

View file

@ -0,0 +1 @@
expected_to match_regex "^${GLOBAL_TOKEN}$"

View file

@ -0,0 +1,7 @@
# inline-environment-variable
*[spec > bonuses](..) > inline-environment-variable*
* [001-modifies-child-environment-1](./001-modifies-child-environment-1)
* [002-modifies-child-environment-2](./002-modifies-child-environment-2)
* [003-modifies-PATH-only](./003-modifies-PATH-only)

View file

@ -0,0 +1,68 @@
# 001-append-twice-outputs-together
*[spec > bonuses > redirections](..) > 001-append-twice-outputs-together*
A double right redirection opens the file with the oflag `O_APPEND`, so that its size is not truncated to 0 and output is written at the end of file. If the file does not exist, it is created.
In this test, twice outputs are appended to the same file.
### What is done before test
```bash
rm -f "new_file_stderr_and_stdout"
```
### Shell commands that are sent to the standard entry
```bash
./write_on_stdout_and_stderr ${GLOBAL_TOKEN}_stdout ${GLOBAL_TOKEN}_stderr &>>new_file_stderr_and_stdout
```
### What is expected on standard output
```bash
expected_to_not match_regex "${GLOBAL_TOKEN}_stdout"
```
### What is expected on error output
```bash
expected_to_not match_regex "${GLOBAL_TOKEN}_stderr"
```
### What miscellaneous behaviors are expected
```bash
expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stdout$"
expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stderr$"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
rm -f "new_file_stderr_and_stdout"

View file

@ -0,0 +1,2 @@
A double right redirection opens the file with the oflag `O_APPEND`, so that its size is not truncated to 0 and output is written at the end of file. If the file does not exist, it is created.
In this test, twice outputs are appended to the same file.

View file

@ -0,0 +1 @@
This test only succeed with the reference ZSH.

View file

@ -0,0 +1,2 @@
expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stdout$"
expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stderr$"

View file

@ -0,0 +1 @@
The POSIX standard does not specify the capability for a Shell to append twice outputs to the same file.

View file

@ -0,0 +1 @@
expected_to_not match_regex "${GLOBAL_TOKEN}_stderr"

View file

@ -0,0 +1 @@
./write_on_stdout_and_stderr ${GLOBAL_TOKEN}_stdout ${GLOBAL_TOKEN}_stderr &>>new_file_stderr_and_stdout

View file

@ -0,0 +1 @@
expected_to_not match_regex "${GLOBAL_TOKEN}_stdout"

View file

@ -0,0 +1,5 @@
# redirections
*[spec > bonuses](..) > redirections*
* [001-append-twice-outputs-together](./001-append-twice-outputs-together)

View file

@ -0,0 +1,7 @@
# separators
*[spec > bonuses](..) > separators*
* [and](./and)
* [mixed](./mixed)
* [or](./or)

View file

@ -0,0 +1,53 @@
# 001-run-twice
*[spec > bonuses > separators > and](..) > 001-run-twice*
The purpose of this test is to check that the AND operator `&&` works with two valid commands.
### Shell commands that are sent to the standard entry
```bash
./write_on_stdout ${GLOBAL_TOKEN}_LEFT && ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT
```
### What is expected on standard output
```bash
might match_regex "${GLOBAL_TOKEN}_LEFT"
might match_regex "${GLOBAL_TOKEN}_RIGHT"
```
### What is expected on error output
```bash
might be_empty
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
The purpose of this test is to check that the AND operator `&&` works with two valid commands.

View file

@ -0,0 +1 @@
might be_empty

View file

@ -0,0 +1 @@
./write_on_stdout ${GLOBAL_TOKEN}_LEFT && ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT

View file

@ -0,0 +1,2 @@
might match_regex "${GLOBAL_TOKEN}_LEFT"
might match_regex "${GLOBAL_TOKEN}_RIGHT"

View file

@ -0,0 +1,61 @@
# 002-do-not-run-second
*[spec > bonuses > separators > and](..) > 002-do-not-run-second*
The purpose of this test is to check that the AND operator `&&` makes the right command to not be executed if the left one exits with an error status code.
The Shell should exit with the status code of the executed command.
### Shell commands that are sent to the standard entry
```bash
./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN}
```
### What is expected on standard output
```bash
might_not match_regex ${GLOBAL_TOKEN}
might be_empty
```
### What is expected on error output
```bash
might be_empty
```
### What miscellaneous behaviors are expected
```bash
might exit_with_status "42"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1,2 @@
The purpose of this test is to check that the AND operator `&&` makes the right command to not be executed if the left one exits with an error status code.
The Shell should exit with the status code of the executed command.

View file

@ -0,0 +1 @@
might exit_with_status "42"

View file

@ -0,0 +1 @@
might be_empty

View file

@ -0,0 +1 @@
./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN}

View file

@ -0,0 +1,2 @@
might_not match_regex ${GLOBAL_TOKEN}
might be_empty

View file

@ -0,0 +1,60 @@
# 003-run-until-failing
*[spec > bonuses > separators > and](..) > 003-run-until-failing*
The purpose of this test is to check that using the AND separator `&&` with chained commands results in the execution of all until the first fail.
### Shell commands that are sent to the standard entry
```bash
./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_FIRST && ./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN}_SECOND
```
### What is expected on standard output
```bash
expected_to match_regex "${GLOBAL_TOKEN}_FIRST"
expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND"
```
### What is expected on error output
```bash
expected_to be_empty
```
### What miscellaneous behaviors are expected
```bash
expected_to exit_with_status "42"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
The purpose of this test is to check that using the AND separator `&&` with chained commands results in the execution of all until the first fail.

View file

@ -0,0 +1 @@
expected_to exit_with_status "42"

View file

@ -0,0 +1 @@
expected_to be_empty

View file

@ -0,0 +1 @@
./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_FIRST && ./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN}_SECOND

View file

@ -0,0 +1,2 @@
expected_to match_regex "${GLOBAL_TOKEN}_FIRST"
expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND"

View file

@ -0,0 +1,8 @@
# and
*[spec > bonuses > separators](..) > and*
* [001-run-twice](./001-run-twice)
* [002-do-not-run-second](./002-do-not-run-second)
* [003-run-until-failing](./003-run-until-failing)
* [errors](./errors)

View file

@ -0,0 +1,63 @@
# 001-parse-error-at-beginning
*[spec > bonuses > separators > and > errors](..) > 001-parse-error-at-beginning*
Parsing test.
The purpose of this test is to check that the AND operator `&&` must be placed after a valid command.
If not, the Shell should display an error and exit with an error status code.
### Shell commands that are sent to the standard entry
```bash
&& ./write_on_stdout ${GLOBAL_TOKEN}
```
### What is expected on standard output
```bash
might_not match_regex "${GLOBAL_TOKEN}"
might be_empty
```
### What is expected on error output
```bash
might_not be_empty
might match_regex "([Ss]yntax|[Pp]arse) error"
```
### What miscellaneous behaviors are expected
```bash
might_not exit_with_status "0"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1,3 @@
Parsing test.
The purpose of this test is to check that the AND operator `&&` must be placed after a valid command.
If not, the Shell should display an error and exit with an error status code.

View file

@ -0,0 +1 @@
might_not exit_with_status "0"

View file

@ -0,0 +1,2 @@
might_not be_empty
might match_regex "([Ss]yntax|[Pp]arse) error"

View file

@ -0,0 +1 @@
&& ./write_on_stdout ${GLOBAL_TOKEN}

View file

@ -0,0 +1,2 @@
might_not match_regex "${GLOBAL_TOKEN}"
might be_empty

View file

@ -0,0 +1,63 @@
# 002-parse-error-too-much-symbol
*[spec > bonuses > separators > and > errors](..) > 002-parse-error-too-much-symbol*
Parsing test.
The purpose of this test is to check that more than two '&' operators are detected as a syntax error.
It should not execute the two commands `write_on_stdout` but display an error and exit with an error status code.
### Shell commands that are sent to the standard entry
```bash
./write_on_stdout ${GLOBAL_TOKEN} &&& ./write_on_stdout ${GLOBAL_TOKEN}
```
### What is expected on standard output
```bash
might_not match_regex "${GLOBAL_TOKEN}"
might be_empty
```
### What is expected on error output
```bash
might_not be_empty
might match_regex "([Ss]yntax|[Pp]arse) error"
```
### What miscellaneous behaviors are expected
```bash
expected_to_not exit_with_status "0"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1,3 @@
Parsing test.
The purpose of this test is to check that more than two '&' operators are detected as a syntax error.
It should not execute the two commands `write_on_stdout` but display an error and exit with an error status code.

View file

@ -0,0 +1 @@
expected_to_not exit_with_status "0"

View file

@ -0,0 +1,2 @@
might_not be_empty
might match_regex "([Ss]yntax|[Pp]arse) error"

View file

@ -0,0 +1 @@
./write_on_stdout ${GLOBAL_TOKEN} &&& ./write_on_stdout ${GLOBAL_TOKEN}

View file

@ -0,0 +1,2 @@
might_not match_regex "${GLOBAL_TOKEN}"
might be_empty

View file

@ -0,0 +1,6 @@
# errors
*[spec > bonuses > separators > and](..) > errors*
* [001-parse-error-at-beginning](./001-parse-error-at-beginning)
* [002-parse-error-too-much-symbol](./002-parse-error-too-much-symbol)

View file

@ -0,0 +1,59 @@
# 001-and-or
*[spec > bonuses > separators > mixed](..) > 001-and-or*
The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed.
### Shell commands that are sent to the standard entry
```bash
./exit_with_status 42 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS
```
### What is expected on standard output
```bash
expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS"
```
### What is expected on error output
```bash
expected_to be_empty
```
### What miscellaneous behaviors are expected
```bash
expected_to exit_with_status "0"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed.

View file

@ -0,0 +1 @@
expected_to exit_with_status "0"

View file

@ -0,0 +1 @@
expected_to be_empty

View file

@ -0,0 +1 @@
./exit_with_status 42 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS

View file

@ -0,0 +1 @@
expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS"

View file

@ -0,0 +1,59 @@
# 002-and-or
*[spec > bonuses > separators > mixed](..) > 002-and-or*
The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed.
### Shell commands that are sent to the standard entry
```bash
./exit_with_status 0 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS
```
### What is expected on standard output
```bash
expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS"
```
### What is expected on error output
```bash
expected_to match_regex "${GLOBAL_TOKEN}_ERROR"
```
### What miscellaneous behaviors are expected
```bash
expected_to exit_with_status "0"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed.

View file

@ -0,0 +1 @@
expected_to exit_with_status "0"

View file

@ -0,0 +1 @@
expected_to match_regex "${GLOBAL_TOKEN}_ERROR"

View file

@ -0,0 +1 @@
./exit_with_status 0 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS

View file

@ -0,0 +1 @@
expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS"

View file

@ -0,0 +1,59 @@
# 003-and-or
*[spec > bonuses > separators > mixed](..) > 003-and-or*
The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed.
### Shell commands that are sent to the standard entry
```bash
./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21
```
### What is expected on standard output
```bash
expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS"
```
### What is expected on error output
```bash
expected_to be_empty
```
### What miscellaneous behaviors are expected
```bash
expected_to exit_with_status "0"
```
### Variables
The following variables may appear in this test:
* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME
### Support binaries
The following binaries may appear in this test:
* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".

View file

@ -0,0 +1 @@
The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed.

View file

@ -0,0 +1 @@
expected_to exit_with_status "0"

View file

@ -0,0 +1 @@
expected_to be_empty

View file

@ -0,0 +1 @@
./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21

Some files were not shown because too many files have changed in this diff Show more