diff --git a/42sh/42ShellTester/file b/42sh/42ShellTester/file deleted file mode 100644 index 13370648..00000000 --- a/42sh/42ShellTester/file +++ /dev/null @@ -1,10 +0,0 @@ -42ShellTester.sh -README.md -file -lib -log -minishell_error -spec -support -tasks -tmp diff --git a/42sh/42ShellTester/log b/42sh/42ShellTester/log deleted file mode 100644 index bd9f852b..00000000 --- a/42sh/42ShellTester/log +++ /dev/null @@ -1,159 +0,0 @@ -.x..........................xx....x. - ----------------------------------------------------------------- - -21sh/misc/002-simple-command-line (FAILED) - - Description: - The purpose of this test is to check that the Shell is able to execute a simple command line that contains separators `;`, pipes `|`, and a right redirection `>`. - - Before test: - 01: rm -rf "./size" - 02: rm -rf "TOKEN201703271859" - 03: echo '^'$(echo TOKEN201703271859_FILE_TOKEN201703271859_STDOUT | wc -c)'$' > "./size" - - STDIN: - 01: mkdir TOKEN201703271859 ; cd TOKEN201703271859 ; touch TOKEN201703271859_FILE ; ls -1 ; ls | cat | wc -c > TOKEN201703271859_STDOUT ; cat TOKEN201703271859_STDOUT - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703271859_FILE$` - FAILURE expected_to match_each_regex_of_file `./size` - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/multiple/004-together (FAILED) - - Description: - A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`. - - Before test: - 01: rm -f "new_file_stderr_and_stdout" - - STDIN: - 01: ./write_on_stdout_and_stderr TOKEN201703271859_1 TOKEN201703271859_2 &>new_file_stderr_and_stdout - - STDOUT: - FAILURE expected_to_not match_regex `TOKEN201703271859_1` - SUCCESS expected_to_not match_regex `TOKEN201703271859_2` - 01: TOKEN201703271859_1 - - STDERR: - SUCCESS expected_to_not match_regex `TOKEN201703271859_1` - FAILURE expected_to_not match_regex `TOKEN201703271859_2` - 01: TOKEN201703271859_2 - - MISC: - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_1$` - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_2$` - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/multiple/005-together-with-whitespaces (FAILED) - - Description: - A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`. - In this test, we specify the file name in a separate field. - - Before test: - 01: rm -f new_file_stderr_and_stdout - - STDIN: - 01: ./write_on_stdout_and_stderr TOKEN201703271859_1 TOKEN201703271859_2 &> new_file_stderr_and_stdout - - STDOUT: - FAILURE expected_to_not match_regex `TOKEN201703271859_1` - SUCCESS expected_to_not match_regex `TOKEN201703271859_2` - 01: TOKEN201703271859_1 - - STDERR: - SUCCESS expected_to_not match_regex `TOKEN201703271859_1` - FAILURE expected_to_not match_regex `TOKEN201703271859_2` - 01: TOKEN201703271859_2 - - MISC: - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_1$` - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_2$` - ----------------------------------------------------------------- - -21sh/separators/semicolon/003-parse-error-empty-inline-command (FAILED) - - Description: - The purpose of this test is to check that using the simicolon separator `;` with empty commands results in error. - - STDIN: - 01: ./write_on_stdout TOKEN201703271859 ; ; ./exit_with_status 42 - - STDOUT: - SUCCESS expected_to be_empty - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` - 01: syntax error near unexpected token `;' - - MISC: - SUCCESS expected_to_not exit_with_status `42` - FAILURE expected_to_not exit_with_status `0` - -Total tests: 36 -Total failed tests: 4 -Total pending tests: 0 -38;5;160m(FAILED) - - Description: - A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`. - In this test, we specify the file name in a separate field. - - Before test: - 01: rm -f new_file_stderr_and_stdout - - STDIN: - 01: ./write_on_stdout_and_stderr TOKEN201703271859_1 TOKEN201703271859_2 &> new_file_stderr_and_stdout - - STDOUT: - FAILURE expected_to_not match_regex `TOKEN201703271859_1` - SUCCESS expected_to_not match_regex `TOKEN201703271859_2` - 01: TOKEN201703271859_1 - - STDERR: - SUCCESS expected_to_not match_regex `TOKEN201703271859_1` - FAILURE expected_to_not match_regex `TOKEN201703271859_2` - 01: TOKEN201703271859_2 - - MISC: - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_1$` - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_2$` - ----------------------------------------------------------------- - -21sh/separators/semicolon/003-parse-error-empty-inline-command (FAILED) - - Description: - The purpose of this test is to check that using the simicolon separator `;` with empty commands results in error. - - STDIN: - 01: ./write_on_stdout TOKEN201703271859 ; ; ./exit_with_status 42 - - STDOUT: - SUCCESS expected_to be_empty - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` - 01: syntax error near unexpected token `;' - - MISC: - SUCCESS expected_to_not exit_with_status `42` - FAILURE expected_to_not exit_with_status `0` - -Total tests: 36 -Total failed tests: 4 -Total pending tests: 0 diff --git a/42sh/42ShellTester/logmini b/42sh/42ShellTester/logmini new file mode 100644 index 00000000..e06dc5fc --- /dev/null +++ b/42sh/42ShellTester/logmini @@ -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 diff --git a/42sh/42ShellTester/minishell_error b/42sh/42ShellTester/minishell_error deleted file mode 100644 index 5ace4e58..00000000 --- a/42sh/42ShellTester/minishell_error +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/42sh/42ShellTester/spec/bonuses/README.md b/42sh/42ShellTester/spec/bonuses/README.md new file mode 100644 index 00000000..9c789434 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/README.md @@ -0,0 +1,9 @@ +# bonuses + +*[spec](..) > bonuses* + +* [builtins](./builtins) +* [inline-environment-variable](./inline-environment-variable) +* [redirections](./redirections) +* [separators](./separators) +* [tilde-expansion](./tilde-expansion) diff --git a/42sh/42ShellTester/spec/bonuses/builtins/README.md b/42sh/42ShellTester/spec/bonuses/builtins/README.md new file mode 100644 index 00000000..bc79927e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/README.md @@ -0,0 +1,5 @@ +# builtins + +*[spec > bonuses](..) > builtins* + +* [env](./env) diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/README.md b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/README.md new file mode 100644 index 00000000..f0ba28fc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/before_exec b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/before_exec new file mode 100644 index 00000000..b5017f3b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/before_exec @@ -0,0 +1 @@ +export TESTVARIABLE="${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/description b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/description new file mode 100644 index 00000000..6d2bc3a8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/description @@ -0,0 +1 @@ +The purpose of this test is to check that the builtin `env` implement the option `-u` to unset environment variables. diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/non-posix b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/non-posix new file mode 100644 index 00000000..8b9aeabf --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/non-posix @@ -0,0 +1 @@ +`env -u` is not registered in the POSIX standard. diff --git a/42sh/42ShellTester/spec/minishell_error b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/pending similarity index 100% rename from 42sh/42ShellTester/spec/minishell_error rename to 42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/pending diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stderr b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdin b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdin new file mode 100644 index 00000000..96a4be3f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdin @@ -0,0 +1 @@ +env -u HOME -u PATH -u TESTVARIABLE ./display_env diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdout b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdout new file mode 100644 index 00000000..93c94f83 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "HOME=" +expected_to_not match_regex "PATH=" +expected_to_not match_regex "TESTVARIABLE=" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md new file mode 100644 index 00000000..d8be155b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec new file mode 100644 index 00000000..072acc45 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec @@ -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" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/description b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/description new file mode 100644 index 00000000..d1d70325 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/description @@ -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. \ No newline at end of file diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/non-posix b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/non-posix new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/pending b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr new file mode 100644 index 00000000..c703fdc6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr @@ -0,0 +1 @@ +expected_to be_empty \ No newline at end of file diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin new file mode 100644 index 00000000..afb12db8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin @@ -0,0 +1 @@ +env -u HOME TESTVARIABLE=${GLOBAL_TOKEN} ./display_env diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout new file mode 100644 index 00000000..4afc77a6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "^TESTVARIABLE=${GLOBAL_TOKEN}$" +expected_to_not match_regex "^HOME=" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/README.md b/42sh/42ShellTester/spec/bonuses/builtins/env/README.md new file mode 100644 index 00000000..905bafab --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/README.md @@ -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) diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md new file mode 100644 index 00000000..18832f55 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec new file mode 100644 index 00000000..3d157a65 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec @@ -0,0 +1 @@ +unset "${GLOBAL_TOKEN}_VARIABLE" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin new file mode 100644 index 00000000..ac8a9dc1 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin @@ -0,0 +1,2 @@ +${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE ./display_env +./display_env diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout new file mode 100644 index 00000000..d0fe972f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout @@ -0,0 +1 @@ +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE$" once diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md new file mode 100644 index 00000000..ec6a634f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec new file mode 100644 index 00000000..3d157a65 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec @@ -0,0 +1 @@ +unset "${GLOBAL_TOKEN}_VARIABLE" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin new file mode 100644 index 00000000..41cea892 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin @@ -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 diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout new file mode 100644 index 00000000..37f7aa70 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout @@ -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 diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md new file mode 100644 index 00000000..c89e7ded --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec new file mode 100644 index 00000000..6da5ae48 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec @@ -0,0 +1,3 @@ +rm -rf "temporary_directory" +mkdir -p "temporary_directory" +cd "temporary_directory" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc new file mode 100644 index 00000000..b982085d --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc @@ -0,0 +1,2 @@ +expected_to_not exit_with_status "42" +expected_to_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr new file mode 100644 index 00000000..e259629c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr @@ -0,0 +1,2 @@ +expected_to_not be_empty +might match_regex "[Cc]ommand not found" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin new file mode 100644 index 00000000..e318f09a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin @@ -0,0 +1,2 @@ +PATH=.. write_on_stdout ${GLOBAL_TOKEN} +exit_with_status 42 diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout new file mode 100644 index 00000000..ba5eb86a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout @@ -0,0 +1 @@ +expected_to match_regex "^${GLOBAL_TOKEN}$" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/README.md new file mode 100644 index 00000000..b210b586 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/README.md @@ -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) diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/README.md b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/README.md new file mode 100644 index 00000000..1217e4e1 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec new file mode 100644 index 00000000..21a08a3e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec @@ -0,0 +1 @@ +rm -f "new_file_stderr_and_stdout" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/description b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/description new file mode 100644 index 00000000..9f258f1d --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/hard b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/hard new file mode 100644 index 00000000..ac178a36 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/hard @@ -0,0 +1 @@ +This test only succeed with the reference ZSH. diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/misc b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/misc new file mode 100644 index 00000000..5ff4505a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/misc @@ -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$" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix new file mode 100644 index 00000000..c009338b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix @@ -0,0 +1 @@ +The POSIX standard does not specify the capability for a Shell to append twice outputs to the same file. diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/pending b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stderr b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stderr new file mode 100644 index 00000000..954fde45 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stderr @@ -0,0 +1 @@ +expected_to_not match_regex "${GLOBAL_TOKEN}_stderr" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdin b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdin new file mode 100644 index 00000000..95ebe4a6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdin @@ -0,0 +1 @@ +./write_on_stdout_and_stderr ${GLOBAL_TOKEN}_stdout ${GLOBAL_TOKEN}_stderr &>>new_file_stderr_and_stdout diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdout b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdout new file mode 100644 index 00000000..edd840fd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdout @@ -0,0 +1 @@ +expected_to_not match_regex "${GLOBAL_TOKEN}_stdout" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/README.md b/42sh/42ShellTester/spec/bonuses/redirections/README.md new file mode 100644 index 00000000..3fb4835b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/README.md @@ -0,0 +1,5 @@ +# redirections + +*[spec > bonuses](..) > redirections* + +* [001-append-twice-outputs-together](./001-append-twice-outputs-together) diff --git a/42sh/42ShellTester/spec/bonuses/separators/README.md b/42sh/42ShellTester/spec/bonuses/separators/README.md new file mode 100644 index 00000000..baa8d80a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/README.md @@ -0,0 +1,7 @@ +# separators + +*[spec > bonuses](..) > separators* + +* [and](./and) +* [mixed](./mixed) +* [or](./or) diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/README.md new file mode 100644 index 00000000..977dc6a0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/description b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/description new file mode 100644 index 00000000..6c60d378 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/description @@ -0,0 +1 @@ +The purpose of this test is to check that the AND operator `&&` works with two valid commands. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdin new file mode 100644 index 00000000..793e144e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN}_LEFT && ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdout new file mode 100644 index 00000000..65f5ef3a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdout @@ -0,0 +1,2 @@ +might match_regex "${GLOBAL_TOKEN}_LEFT" +might match_regex "${GLOBAL_TOKEN}_RIGHT" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/README.md new file mode 100644 index 00000000..a1fb7113 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/description b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/description new file mode 100644 index 00000000..f85a5e86 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/misc b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/misc new file mode 100644 index 00000000..cdd865a4 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/misc @@ -0,0 +1 @@ +might exit_with_status "42" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdin new file mode 100644 index 00000000..486986fc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdin @@ -0,0 +1 @@ +./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdout new file mode 100644 index 00000000..b01a27a5 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdout @@ -0,0 +1,2 @@ +might_not match_regex ${GLOBAL_TOKEN} +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/README.md new file mode 100644 index 00000000..cca4c935 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/description b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/description new file mode 100644 index 00000000..9d47e372 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/misc b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/misc new file mode 100644 index 00000000..1983dc76 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/misc @@ -0,0 +1 @@ +expected_to exit_with_status "42" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdin new file mode 100644 index 00000000..ade933dd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdin @@ -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 diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdout new file mode 100644 index 00000000..16c3d329 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "${GLOBAL_TOKEN}_FIRST" +expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/README.md new file mode 100644 index 00000000..0465749c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/README.md @@ -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) diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md new file mode 100644 index 00000000..8f69cde8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description new file mode 100644 index 00000000..680a6627 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr @@ -0,0 +1,2 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin new file mode 100644 index 00000000..dc4ada22 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin @@ -0,0 +1 @@ +&& ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout new file mode 100644 index 00000000..f78d19db --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout @@ -0,0 +1,2 @@ +might_not match_regex "${GLOBAL_TOKEN}" +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md new file mode 100644 index 00000000..b28ff2c8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description new file mode 100644 index 00000000..00c27154 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc new file mode 100644 index 00000000..55d07cd5 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc @@ -0,0 +1 @@ +expected_to_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr @@ -0,0 +1,2 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin new file mode 100644 index 00000000..d43aa5f0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN} &&& ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout new file mode 100644 index 00000000..f78d19db --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout @@ -0,0 +1,2 @@ +might_not match_regex "${GLOBAL_TOKEN}" +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/errors/README.md new file mode 100644 index 00000000..60f1730e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/README.md @@ -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) diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/README.md new file mode 100644 index 00000000..8c6871fb --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdin new file mode 100644 index 00000000..ead446bc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdin @@ -0,0 +1 @@ +./exit_with_status 42 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/README.md new file mode 100644 index 00000000..e1706492 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdin new file mode 100644 index 00000000..7513ed7b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdin @@ -0,0 +1 @@ +./exit_with_status 0 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/README.md new file mode 100644 index 00000000..d257e648 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/README.md @@ -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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/description @@ -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. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdin new file mode 100644 index 00000000..e695ff1a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdin @@ -0,0 +1 @@ +./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/README.md new file mode 100644 index 00000000..eb66cf3f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/README.md @@ -0,0 +1,59 @@ +# 004-or-and + +*[spec > bonuses > separators > mixed](..) > 004-or-and* + +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds 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 be_empty + +``` + +### 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 "21" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/misc new file mode 100644 index 00000000..82d70611 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "21" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdin new file mode 100644 index 00000000..29391e99 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdin @@ -0,0 +1 @@ +./exit_with_status 42 || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdout new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdout @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/README.md new file mode 100644 index 00000000..bb944740 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/README.md @@ -0,0 +1,59 @@ +# 005-or-and + +*[spec > bonuses > separators > mixed](..) > 005-or-and* + +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 42 || ./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 match_regex "${GLOBAL_TOKEN}_ERROR" + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "21" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/misc new file mode 100644 index 00000000..82d70611 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "21" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdin new file mode 100644 index 00000000..6d9fee3a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdin @@ -0,0 +1 @@ +./exit_with_status 42 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/README.md new file mode 100644 index 00000000..aa7f35bd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/README.md @@ -0,0 +1,59 @@ +# 006-or-and + +*[spec > bonuses > separators > mixed](..) > 006-or-and* + +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds 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 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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdin new file mode 100644 index 00000000..7dab07c6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdin @@ -0,0 +1 @@ +./exit_with_status 0 || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/README.md new file mode 100644 index 00000000..a6863e70 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/README.md @@ -0,0 +1,10 @@ +# mixed + +*[spec > bonuses > separators](..) > mixed* + +* [001-and-or](./001-and-or) +* [002-and-or](./002-and-or) +* [003-and-or](./003-and-or) +* [004-or-and](./004-or-and) +* [005-or-and](./005-or-and) +* [006-or-and](./006-or-and) diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/README.md new file mode 100644 index 00000000..1d3ce380 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/README.md @@ -0,0 +1,53 @@ +# 001-run-first-only + +*[spec > bonuses > separators > or](..) > 001-run-first-only* + +The purpose of this test is to check that the OR operator `||` makes the right command to not be executed if the left one exits with a success status. +### 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_not 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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/description b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/description new file mode 100644 index 00000000..faf0dca8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/description @@ -0,0 +1 @@ +The purpose of this test is to check that the OR operator `||` makes the right command to not be executed if the left one exits with a success status. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdin new file mode 100644 index 00000000..e167faf4 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN}_LEFT || ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdout new file mode 100644 index 00000000..195b1a22 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdout @@ -0,0 +1,2 @@ +might match_regex ${GLOBAL_TOKEN}_LEFT +might_not match_regex ${GLOBAL_TOKEN}_RIGHT diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/README.md new file mode 100644 index 00000000..5e7a59df --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/README.md @@ -0,0 +1,59 @@ +# 002-run-second-only + +*[spec > bonuses > separators > or](..) > 002-run-second-only* + +The purpose of this test is to check that the OR operator `||` makes the right command to be executed if the left one exits with an error status code. +### 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 match_regex "${GLOBAL_TOKEN}" + +``` + +### What is expected on error output + +```bash +might be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +might 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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/description b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/description new file mode 100644 index 00000000..f8892296 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/description @@ -0,0 +1 @@ +The purpose of this test is to check that the OR operator `||` makes the right command to be executed if the left one exits with an error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/misc b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/misc new file mode 100644 index 00000000..fd805999 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/misc @@ -0,0 +1 @@ +might exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdin new file mode 100644 index 00000000..fc0472c0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdin @@ -0,0 +1 @@ +./exit_with_status 42 || ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdout new file mode 100644 index 00000000..bbdd98ff --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdout @@ -0,0 +1 @@ +might match_regex "${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/README.md new file mode 100644 index 00000000..8e2d2f22 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/README.md @@ -0,0 +1,60 @@ +# 003-run-until-succeeding + +*[spec > bonuses > separators > or](..) > 003-run-until-succeeding* + +The purpose of this test is to check that using the OR separator `||` with chained commands results in the execution of all until the first succeed. The remaining commands are not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 1 || ./exit_with_status 2 || ./exit_with_status 3 || ./exit_with_status 4 || ./write_on_stdout ${GLOBAL_TOKEN}_FIRST || ./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 "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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/description b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/description new file mode 100644 index 00000000..960a362b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the OR separator `||` with chained commands results in the execution of all until the first succeed. The remaining commands are not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/misc b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdin new file mode 100644 index 00000000..0f675560 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdin @@ -0,0 +1 @@ +./exit_with_status 1 || ./exit_with_status 2 || ./exit_with_status 3 || ./exit_with_status 4 || ./write_on_stdout ${GLOBAL_TOKEN}_FIRST || ./write_on_stdout ${GLOBAL_TOKEN}_SECOND diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdout new file mode 100644 index 00000000..16c3d329 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "${GLOBAL_TOKEN}_FIRST" +expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/README.md new file mode 100644 index 00000000..a3b10c36 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/README.md @@ -0,0 +1,8 @@ +# or + +*[spec > bonuses > separators](..) > or* + +* [001-run-first-only](./001-run-first-only) +* [002-run-second-only](./002-run-second-only) +* [003-run-until-succeeding](./003-run-until-succeeding) +* [errors](./errors) diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md new file mode 100644 index 00000000..c0b32de0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md @@ -0,0 +1,62 @@ +# 001-parse-error-at-beginning + +*[spec > bonuses > separators > or > errors](..) > 001-parse-error-at-beginning* + +Parsing test. +The purpose of this test is to check that the OR 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 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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description new file mode 100644 index 00000000..d29fb8ad --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description @@ -0,0 +1,3 @@ +Parsing test. +The purpose of this test is to check that the OR operator `||` must be placed after a valid command. +If not, the Shell should display an error and exit with an error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr @@ -0,0 +1,2 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin new file mode 100644 index 00000000..9dfc6dbd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin @@ -0,0 +1 @@ +|| ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md new file mode 100644 index 00000000..1edf6632 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md @@ -0,0 +1,63 @@ +# 002-parse-error-too-much-symbol + +*[spec > bonuses > separators > or > errors](..) > 002-parse-error-too-much-symbol* + +Parsing test. +The purpose of this test is to check that using more than two pipe symbols `|` is detected as an error. +The Shell should display an error and exit with a 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 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". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description new file mode 100644 index 00000000..940ef752 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description @@ -0,0 +1,3 @@ +Parsing test. +The purpose of this test is to check that using more than two pipe symbols `|` is detected as an error. +The Shell should display an error and exit with a error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr new file mode 100644 index 00000000..a6382d38 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr @@ -0,0 +1,3 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" + diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin new file mode 100644 index 00000000..782254a3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN} ||| ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/errors/README.md new file mode 100644 index 00000000..babe06e9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/README.md @@ -0,0 +1,6 @@ +# errors + +*[spec > bonuses > separators > or](..) > errors* + +* [001-parse-error-at-beginning](./001-parse-error-at-beginning) +* [002-parse-error-too-much-symbol](./002-parse-error-too-much-symbol) diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md new file mode 100644 index 00000000..f5f690c9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md @@ -0,0 +1,53 @@ +# 001-expanded-with-HOME-1 + +*[spec > bonuses > tilde-expansion](..) > 001-expanded-with-HOME-1* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable HOME. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~ + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}$" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description new file mode 100644 index 00000000..53e01191 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable HOME. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin new file mode 100644 index 00000000..69307f14 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~ diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout new file mode 100644 index 00000000..3c9d4ab8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout @@ -0,0 +1,2 @@ +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md new file mode 100644 index 00000000..9af192b8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md @@ -0,0 +1,53 @@ +# 002-expanded-with-HOME-2 + +*[spec > bonuses > tilde-expansion](..) > 002-expanded-with-HOME-2* + +The purpose of this test is to check that the symbol tilde `~` followed by the symbol slash `/` may be expanded with the environment variable HOME. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~/${GLOBAL_TOKEN}_SUBDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}/${GLOBAL_TOKEN}_SUBDIRECTORY$" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description new file mode 100644 index 00000000..2c601af5 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` followed by the symbol slash `/` may be expanded with the environment variable HOME. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin new file mode 100644 index 00000000..b806e8d9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~/${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout new file mode 100644 index 00000000..ddeb1db3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout @@ -0,0 +1,2 @@ +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}/${GLOBAL_TOKEN}_SUBDIRECTORY$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md new file mode 100644 index 00000000..d591b379 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md @@ -0,0 +1,54 @@ +# 003-expanded-with-PWD-1 + +*[spec > bonuses > tilde-expansion](..) > 003-expanded-with-PWD-1* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~+ + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~[+]" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description new file mode 100644 index 00000000..545ed856 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin new file mode 100644 index 00000000..c2315545 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+ diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout new file mode 100644 index 00000000..ec00fafb --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~[+]" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md new file mode 100644 index 00000000..6f108a8a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md @@ -0,0 +1,54 @@ +# 004-expanded-with-PWD-2 + +*[spec > bonuses > tilde-expansion](..) > 004-expanded-with-PWD-2* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~+/${GLOBAL_TOKEN}_SUBDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~+/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_SUBDIRECTORY$" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description new file mode 100644 index 00000000..545ed856 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin new file mode 100644 index 00000000..019c6cf9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+/${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout new file mode 100644 index 00000000..23a27406 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~+/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_SUBDIRECTORY$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md new file mode 100644 index 00000000..8220f52e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md @@ -0,0 +1,57 @@ +# 005-expanded-with-OLDPWD-1 + +*[spec > bonuses > tilde-expansion](..) > 005-expanded-with-OLDPWD-1* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. +### What is done before test + +```bash +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~- + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~-" +expected_to_not match_regex "/${GLOBAL_TOKEN}-" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec @@ -0,0 +1,3 @@ +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description new file mode 100644 index 00000000..1cb05172 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin new file mode 100644 index 00000000..c9e75916 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin @@ -0,0 +1,2 @@ +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~- diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout new file mode 100644 index 00000000..ff80be6f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~-" +expected_to_not match_regex "/${GLOBAL_TOKEN}-" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md new file mode 100644 index 00000000..de98ffb2 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md @@ -0,0 +1,57 @@ +# 006-expanded-with-OLDPWD-2 + +*[spec > bonuses > tilde-expansion](..) > 006-expanded-with-OLDPWD-2* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. +### What is done before test + +```bash +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-/${GLOBAL_TOKEN}_OTHERDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY$" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec @@ -0,0 +1,3 @@ +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description new file mode 100644 index 00000000..1cb05172 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin new file mode 100644 index 00000000..76895961 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin @@ -0,0 +1,2 @@ +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-/${GLOBAL_TOKEN}_OTHERDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout new file mode 100644 index 00000000..1dbf719e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/README.md new file mode 100644 index 00000000..5c02470e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/README.md @@ -0,0 +1,11 @@ +# tilde-expansion + +*[spec > bonuses](..) > tilde-expansion* + +* [001-expanded-with-HOME-1](./001-expanded-with-HOME-1) +* [002-expanded-with-HOME-2](./002-expanded-with-HOME-2) +* [003-expanded-with-PWD-1](./003-expanded-with-PWD-1) +* [004-expanded-with-PWD-2](./004-expanded-with-PWD-2) +* [005-expanded-with-OLDPWD-1](./005-expanded-with-OLDPWD-1) +* [006-expanded-with-OLDPWD-2](./006-expanded-with-OLDPWD-2) +* [not-expanded](./not-expanded) diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md new file mode 100644 index 00000000..04bc890e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md @@ -0,0 +1,53 @@ +# 001-not-expanded-with-HOME-1 + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 001-not-expanded-with-HOME-1* + +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~~ + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~~$" +expected_to_not match_regex "/${GLOBAL_TOKEN}" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description new file mode 100644 index 00000000..739f0907 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin new file mode 100644 index 00000000..fd5167ce --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~~ diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout new file mode 100644 index 00000000..3160a089 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "^~~$" +expected_to_not match_regex "/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md new file mode 100644 index 00000000..a573acaf --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md @@ -0,0 +1,53 @@ +# 002-not-expanded-with-HOME-2 + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 002-not-expanded-with-HOME-2* + +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~${GLOBAL_TOKEN}_UNKNOWNUSER + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~${GLOBAL_TOKEN}_UNKNOWNUSER$" +expected_to_not match_regex "/${GLOBAL_TOKEN}${GLOBAL_TOKEN}_UNKNOWNUSER" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description new file mode 100644 index 00000000..739f0907 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin new file mode 100644 index 00000000..3c0b74c7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~${GLOBAL_TOKEN}_UNKNOWNUSER diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout new file mode 100644 index 00000000..9a73fcf0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "^~${GLOBAL_TOKEN}_UNKNOWNUSER$" +expected_to_not match_regex "/${GLOBAL_TOKEN}${GLOBAL_TOKEN}_UNKNOWNUSER" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md new file mode 100644 index 00000000..4019717d --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md @@ -0,0 +1,54 @@ +# 003-not-expanded-with-PWD + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 003-not-expanded-with-PWD* + +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable PWD when not followed by the symbol `/`. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~+${GLOBAL_TOKEN}_SUBDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~[+]${GLOBAL_TOKEN}_SUBDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}${GLOBAL_TOKEN}_SUBDIRECTORY" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description new file mode 100644 index 00000000..832e877c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable PWD when not followed by the symbol `/`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin new file mode 100644 index 00000000..f0cc2677 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout new file mode 100644 index 00000000..53269842 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout @@ -0,0 +1,3 @@ +expected_to match_regex "^~[+]${GLOBAL_TOKEN}_SUBDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}${GLOBAL_TOKEN}_SUBDIRECTORY" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md new file mode 100644 index 00000000..c45e2a7f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md @@ -0,0 +1,57 @@ +# 004-not-expanded-with-OLDPWD + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 004-not-expanded-with-OLDPWD* + +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable OLDPWD when not followed by the symbol `/`. +### What is done before test + +```bash +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-${GLOBAL_TOKEN}_OTHERDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~-${GLOBAL_TOKEN}_OTHERDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY" + +``` + +### 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". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec @@ -0,0 +1,3 @@ +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description new file mode 100644 index 00000000..fad1aead --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable OLDPWD when not followed by the symbol `/`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin new file mode 100644 index 00000000..4c3cec62 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin @@ -0,0 +1,2 @@ +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-${GLOBAL_TOKEN}_OTHERDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout new file mode 100644 index 00000000..1ed88c70 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout @@ -0,0 +1,3 @@ +expected_to match_regex "^~-${GLOBAL_TOKEN}_OTHERDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/README.md new file mode 100644 index 00000000..bdb7eabc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/README.md @@ -0,0 +1,8 @@ +# not-expanded + +*[spec > bonuses > tilde-expansion](..) > not-expanded* + +* [001-not-expanded-with-HOME-1](./001-not-expanded-with-HOME-1) +* [002-not-expanded-with-HOME-2](./002-not-expanded-with-HOME-2) +* [003-not-expanded-with-PWD](./003-not-expanded-with-PWD) +* [004-not-expanded-with-OLDPWD](./004-not-expanded-with-OLDPWD) diff --git a/42sh/another_file b/42sh/another_file new file mode 100644 index 00000000..4caf053f --- /dev/null +++ b/42sh/another_file @@ -0,0 +1,243 @@ +src/builtin/bt_env_opt.c$$ +src/builtin/bt_read_get.c$$ +src/builtin/bt_read_term.c$$ +src/builtin/builtin_cd.c$$ +src/builtin/builtin_echo.c$$ +src/builtin/builtin_env.c$$ +src/builtin/builtin_exit.c$$ +src/builtin/builtin_export.c$$ +src/builtin/builtin_func.c$$ +src/builtin/builtin_hash.c$$ +src/builtin/builtin_history.c$$ +src/builtin/builtin_math.c$$ +src/builtin/builtin_read.c$$ +src/builtin/builtin_setenv.c$$ +src/builtin/builtin_unset.c$$ +src/builtin/builtin_unsetenv.c$$ +src/builtin/is_builtin.c$$ +src/completion/c_arrow.c$$ +src/completion/c_clear.c$$ +src/completion/c_find_abspath.c$$ +src/completion/c_find_binary.c$$ +src/completion/c_find_env.c$$ +src/completion/c_find_files.c$$ +src/completion/c_init.c$$ +src/completion/c_match.c$$ +src/completion/c_match_glob.c$$ +src/completion/c_match_update.c$$ +src/completion/c_misc.c$$ +src/completion/c_output.c$$ +src/completion/c_parser.c$$ +src/completion/c_pathsolver.c$$ +src/completion/c_printer.c$$ +src/completion/c_sizing.c$$ +src/completion/c_terminal.c$$ +src/completion/completion.c$$ +src/exec/ast_free.c$$ +src/exec/bad_fd.c$$ +src/exec/exec_ampersand.c$$ +src/exec/exec_and_if.c$$ +src/exec/exec_bang.c$$ +src/exec/exec_case_branch.c$$ +src/exec/exec_destroy.c$$ +src/exec/exec_elif.c$$ +src/exec/exec_else.c$$ +src/exec/exec_func.c$$ +src/exec/exec_init.c$$ +src/exec/exec_leaf.c$$ +src/exec/exec_or_if.c$$ +src/exec/exec_pipe.c$$ +src/exec/exec_semi.c$$ +src/exec/exec_var.c$$ +src/exec/fd_is_valid.c$$ +src/exec/ft_exec.c$$ +src/exec/ft_findexec.c$$ +src/exec/is_function.c$$ +src/exec/mark_process_status.c$$ +src/exec/node_copy.c$$ +src/exec/pfree_cmd.c$$ +src/exec/pfree_cond.c$$ +src/exec/pfree_func.c$$ +src/exec/pfree_list.c$$ +src/exec/pfree_subshell.c$$ +src/exec/plaunch_brace.c$$ +src/exec/plaunch_builtin.c$$ +src/exec/plaunch_case.c$$ +src/exec/plaunch_empty.c$$ +src/exec/plaunch_file.c$$ +src/exec/plaunch_for.c$$ +src/exec/plaunch_function.c$$ +src/exec/plaunch_if.c$$ +src/exec/plaunch_subshell.c$$ +src/exec/plaunch_until.c$$ +src/exec/plaunch_while.c$$ +src/exec/process_launch.c$$ +src/exec/process_redirect.c$$ +src/exec/process_set.c$$ +src/exec/process_setgroup.c$$ +src/exec/process_setsig.c$$ +src/exec/pset_brace.c$$ +src/exec/pset_case.c$$ +src/exec/pset_cmd.c$$ +src/exec/pset_for.c$$ +src/exec/pset_if.c$$ +src/exec/pset_subshell.c$$ +src/exec/pset_until.c$$ +src/exec/pset_while.c$$ +src/exec/redir_copy.c$$ +src/exec/redir_free.c$$ +src/exec/redirect_dgreat.c$$ +src/exec/redirect_dless.c$$ +src/exec/redirect_great.c$$ +src/exec/redirect_greatand.c$$ +src/exec/redirect_less.c$$ +src/exec/redirect_lessand.c$$ +src/exec/set_exitstatus.c$$ +src/exec/token_to_argv.c$$ +src/glob/command_getoutput.c$$ +src/glob/dir_glob.c$$ +src/glob/esc_print.c$$ +src/glob/expand_bquote.c$$ +src/glob/expand_brace.c$$ +src/glob/expand_esc.c$$ +src/glob/expand_home.c$$ +src/glob/expand_var.c$$ +src/glob/ft_strsplit_esc.c$$ +src/glob/ft_strsplit_spe.c$$ +src/glob/gen_tab_esc.c$$ +src/glob/glob.c$$ +src/glob/is_char_esc.c$$ +src/glob/match_pattern.c$$ +src/glob/tab_esc_copy.c$$ +src/glob/word_is_assignment.c$$ +src/hash_table/ft_add_hash.c$$ +src/hash_table/hash.c$$ +src/hash_table/hash_free.c$$ +src/hash_table/hash_str.c$$ +src/hash_table/is_hash.c$$ +src/history/add_str_in_history.c$$ +src/history/history.c$$ +src/history/history_parsing.c$$ +src/history/history_parsing_toolz.c$$ +src/history/history_parsing_toolz_2.c$$ +src/history/list_toolz.c$$ +src/history/surch_in_history.c$$ +src/job_control/builtin_bg.c$$ +src/job_control/builtin_fg.c$$ +src/job_control/builtin_jobs.c$$ +src/job_control/do_job_notification.c$$ +src/job_control/has_running_job.c$$ +src/job_control/has_stopped_job.c$$ +src/job_control/job_addprocess.c$$ +src/job_control/job_cmp_id.c$$ +src/job_control/job_format.c$$ +src/job_control/job_format_head.c$$ +src/job_control/job_free.c$$ +src/job_control/job_getprocess.c$$ +src/job_control/job_getrank.c$$ +src/job_control/job_hup_all.c$$ +src/job_control/job_is_completed.c$$ +src/job_control/job_is_stopped.c$$ +src/job_control/job_notify_change.c$$ +src/job_control/job_notify_new.c$$ +src/job_control/job_remove.c$$ +src/job_control/job_run.c$$ +src/job_control/job_update_id.c$$ +src/job_control/job_update_status.c$$ +src/job_control/job_wait.c$$ +src/job_control/jobc_destroy.c$$ +src/job_control/jobc_init.c$$ +src/job_control/mark_job_as_running.c$$ +src/job_control/pprint_brace.c$$ +src/job_control/pprint_case.c$$ +src/job_control/pprint_cmd.c$$ +src/job_control/pprint_for.c$$ +src/job_control/pprint_function.c$$ +src/job_control/pprint_if.c$$ +src/job_control/pprint_subshell.c$$ +src/job_control/pprint_until.c$$ +src/job_control/pprint_while.c$$ +src/job_control/process_cmp_pid.c$$ +src/job_control/process_format.c$$ +src/job_control/process_free.c$$ +src/job_control/put_job_in_background.c$$ +src/job_control/put_job_in_foreground.c$$ +src/job_control/sigchld_handler.c$$ +src/job_control/sigint_handler.c$$ +src/job_control/sigtstp_handler.c$$ +src/job_control/sigttin_handler.c$$ +src/job_control/sigttou_handler.c$$ +src/lexer/do_lexer_routine.c$$ +src/lexer/get_lexer_stack.c$$ +src/lexer/get_lexer_stack2.c$$ +src/lexer/get_reserved_words.c$$ +src/lexer/get_state_global.c$$ +src/lexer/get_state_redir.c$$ +src/lexer/insert_newline.c$$ +src/lexer/isrw_delim.c$$ +src/lexer/keep_last_type.c$$ +src/lexer/lexer_backslash.c$$ +src/lexer/lexer_bquote.c$$ +src/lexer/lexer_curly_braces.c$$ +src/lexer/lexer_default.c$$ +src/lexer/lexer_delim.c$$ +src/lexer/lexer_destroy.c$$ +src/lexer/lexer_dquote.c$$ +src/lexer/lexer_end.c$$ +src/lexer/lexer_great.c$$ +src/lexer/lexer_heredoc.c$$ +src/lexer/lexer_init.c$$ +src/lexer/lexer_less.c$$ +src/lexer/lexer_lex.c$$ +src/lexer/lexer_newline.c$$ +src/lexer/lexer_number.c$$ +src/lexer/lexer_paren.c$$ +src/lexer/lexer_quote.c$$ +src/lexer/lexer_sep.c$$ +src/lexer/lexer_word.c$$ +src/lexer/token_append.c$$ +src/lexer/token_cmp_type.c$$ +src/lexer/token_free.c$$ +src/lexer/token_init.c$$ +src/lexer/token_print.c$$ +src/line_editing/control_features.c$$ +src/line_editing/ft_prompt.c$$ +src/line_editing/get_key.c$$ +src/line_editing/readline.c$$ +src/line_editing/resize.c$$ +src/main/data_exit.c$$ +src/main/data_init.c$$ +src/main/data_singleton.c$$ +src/main/ft_putast.c$$ +src/main/main.c$$ +src/main/shell_fds.c$$ +src/main/shell_init.c$$ +src/main/shell_sig.c$$ +src/parser/add_bang.c$$ +src/parser/add_case.c$$ +src/parser/add_cmd.c$$ +src/parser/add_condition.c$$ +src/parser/add_func.c$$ +src/parser/add_loop.c$$ +src/parser/add_number.c$$ +src/parser/add_redir.c$$ +src/parser/add_sep.c$$ +src/parser/add_subshell.c$$ +src/parser/aggregate_sym.c$$ +src/parser/build_tree.c$$ +src/parser/do_parser_routine.c$$ +src/parser/error_syntax.c$$ +src/parser/eval_sym.c$$ +src/parser/ft_parse.c$$ +src/parser/heredoc_parser.c$$ +src/parser/parser_destroy.c$$ +src/parser/parser_init.c$$ +src/parser/pop_stack.c$$ +src/parser/produce_sym.c$$ +src/parser/push_stack.c$$ +src/parser/read_stack.c$$ +src/parser/redir_init.c$$ +src/parser/stack_init.c$$ +src/parser/sym_free.c$$ +src/parser/tree_func_free.c$$ +src/parser/tree_wrapper.c$$ diff --git a/42sh/file b/42sh/file new file mode 100644 index 00000000..72a3d290 --- /dev/null +++ b/42sh/file @@ -0,0 +1,19 @@ +/Users/ariard/Projects/42sh +/Users/ariard/Projects/42sh +42ShellTester +42sh +Makefile +README.md +STDBUG +another_file +auteur +donovan_segaults_06-02 +file +includes +libft +objs +pdf +sample +scriptheader.sh +src +update_makefile.sh diff --git a/42sh/sample/again.sh b/42sh/sample/again.sh index 1a85b88c..faaebbb4 100644 --- a/42sh/sample/again.sh +++ b/42sh/sample/again.sh @@ -1,2 +1,3 @@ echo "echo hello" >> sample/again.sh echo hello +echo hello diff --git a/42sh/sample/andor.sh b/42sh/sample/andor.sh index 15bdd7e0..6d83ae1a 100644 --- a/42sh/sample/andor.sh +++ b/42sh/sample/andor.sh @@ -1 +1,8 @@ pwd > file && pwd >> file || ls | cat && ls | cat >> file || ls +cat -e file + +sleep 2 +echo +echo "My script:" +echo +cat sample/andor.sh diff --git a/42sh/sample/mix.sh b/42sh/sample/mix.sh index 9cfd3fc2..21b5a1dc 100644 --- a/42sh/sample/mix.sh +++ b/42sh/sample/mix.sh @@ -27,4 +27,4 @@ echo echo "My sample :" sleep 3 echo -cat sample/mix/mix.sh +cat sample/mix.sh diff --git a/42sh/src/lexer/get_reserved_words.c b/42sh/src/lexer/get_reserved_words.c index 3bb8579d..382a6764 100644 --- a/42sh/src/lexer/get_reserved_words.c +++ b/42sh/src/lexer/get_reserved_words.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 00:07:05 by ariard #+# #+# */ -/* Updated: 2017/03/27 21:44:14 by gwojda ### ########.fr */ +/* Updated: 2017/03/29 15:07:16 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,7 +39,8 @@ static int recognization_rvwords(t_token *pv_tk, t_token *at_tk) || pv_tk->type == TK_ELIF || pv_tk->type == TK_ELSE || pv_tk->type == TK_DSEMI || pv_tk->type == TK_PAREN_OPEN || pv_tk->type == TK_LBRACE || pv_tk->type == TK_UNTIL) - || pv_tk->type == TK_PAREN_CLOSE + || pv_tk->type == TK_PAREN_CLOSE || pv_tk->type == TK_AND_IF + || pv_tk->type == TK_OR_IF || (pv_tk->type == TK_PAREN_CLOSE && at_tk->type == TK_PAREN_OPEN)); } diff --git a/42sh/src/parser/aggregate_sym.c b/42sh/src/parser/aggregate_sym.c index bccbb478..5b36a3f8 100644 --- a/42sh/src/parser/aggregate_sym.c +++ b/42sh/src/parser/aggregate_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 15:58:38 by ariard #+# #+# */ -/* Updated: 2017/03/29 14:30:32 by ariard ### ########.fr */ +/* Updated: 2017/03/29 15:19:50 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,8 @@ static t_aggrematch g_aggrematch[] = {TK_DSEMI, CMD_SUPERIOR, CLOSE_LIST, TK_PAREN_CLOSE}, {TK_DSEMI, PIPE_SEMI_SEQUENCE, CLOSE_LIST, TK_PAREN_CLOSE}, {TK_DSEMI, PIPE_CLOSE_SEQUENCE, CLOSE_LIST, TK_PAREN_CLOSE}, + {TK_DSEMI, COMPOUND_LIST, CLOSE_LIST, TK_PAREN_CLOSE}, + {TK_DSEMI, COMPLETE_COMMANDS, CLOSE_LIST, TK_PAREN_CLOSE}, {TK_PAREN_OPEN, TK_IN, PATTERN_CASE, 0}, {TK_PAREN_OPEN, CASE_LIST_NS, PATTERN_CASE, 0}, {TK_PAREN_OPEN, CMD_SUPERIOR, OPEN_FUNC, 0}, @@ -31,11 +33,13 @@ static t_aggrematch g_aggrematch[] = {TK_PIPE, PIPE_CLOSE_SEQUENCE, SEQUENCE, PIPE_CLOSE_SEQUENCE}, {TK_FI, ELSE_PART, IF_CLAUSE, TK_IF}, {TK_FI, COMPOUND_LIST, IF_CLAUSE, COMPLETE_CONDITION}, + {TK_FI, COMPLETE_COMMANDS, IF_CLAUSE, COMPLETE_CONDITION}, {TK_FI, COMPLETE_CONDITION, IF_CLAUSE, COMPLETE_CONDITION}, {TK_FI, CONDITION, IF_CLAUSE, COMPLETE_CONDITION}, {TK_THEN, CONDITION, COMPLETE_CONDITION, CONDITION}, {TK_DONE, CMD_SUPERIOR, DO_GROUP, TK_DO}, {TK_DONE, COMPOUND_LIST, DO_GROUP, TK_DO}, + {TK_DONE, COMPLETE_COMMANDS, DO_GROUP, TK_DO}, {TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE}, {TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE}, {TK_PAREN_CLOSE, SUBSHELL, SUBSHELL, TK_PAREN_OPEN}, @@ -327,7 +331,7 @@ static t_aggrematch g_aggrematch[] = {PIPELINE, SEPARATOR_OP, AND_OR, 0}, {PIPELINE, COMPLETE_CONDITION, AND_OR, 0}, {PIPELINE, CONDITION, AND_OR, 0}, - {PIPELINE, AND_OR, AND_OR, AND_OR}, + {PIPELINE, AND_OR, COMPLETE_COMMANDS, 0}, {AND_OR, AND_OR, AND_OR, AND_OR}, {AND_OR, TK_DO, COMPOUND_LIST, 0}, {AND_OR, TK_PAREN_CLOSE, COMPOUND_LIST, 0}, diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index 5156a680..2008c214 100644 --- a/42sh/src/parser/eval_sym.c +++ b/42sh/src/parser/eval_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 16:11:21 by ariard #+# #+# */ -/* Updated: 2017/03/29 14:32:14 by ariard ### ########.fr */ +/* Updated: 2017/03/29 15:19:03 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -282,13 +282,15 @@ static t_stackmatch g_stackmatch[] = {TK_FI, CMD_SUPERIOR}, {TK_FI, END_COMMAND}, {TK_FI, CONDITION}, - {TK_DO, CMD_SUPERIOR}, {TK_FI, COMPLETE_CONDITION}, + {TK_FI, COMPLETE_COMMANDS}, + {TK_DO, CMD_SUPERIOR}, {TK_DO, COMPOUND_LIST}, {TK_DO, NAME}, {TK_DO, SEQUENTIAL_SEP}, {TK_DONE, CMD_SUPERIOR}, {TK_DONE, COMPOUND_LIST}, + {TK_DONE, COMPLETE_COMMANDS}, {TK_DONE, END_COMMAND}, {TK_CASE, LINEBREAK}, {TK_CASE, TK_BANG}, @@ -468,12 +470,13 @@ static t_stackmatch g_stackmatch[] = {TK_SEMI, IN}, {TK_SEMI, WORDLIST}, {TK_SEMI, LIST}, - {TK_SEMI, TERM}, {TK_SEMI, CMD_NAME}, {TK_SEMI, PROGRAM}, {TK_SEMI, FOR_WORDLIST}, {TK_AMP, LIST}, {TK_AMP, TERM}, + {TK_AMP, PROGRAM}, + {TK_AMP, CMD_NAME}, {TK_PIPE, PATTERN}, {TK_PIPE, CMD_SUPERIOR}, {TK_PIPE, PIPE_SEMI_SEQUENCE},