diff --git a/42sh/42shelltest-tmp/.gitignore b/42sh/42shelltest-tmp/.gitignore new file mode 100644 index 00000000..28f63f2b --- /dev/null +++ b/42sh/42shelltest-tmp/.gitignore @@ -0,0 +1,4 @@ +.idea +tmp/ +.mshell_hist +.DS_Store diff --git a/42sh/42shelltest-tmp/42ShellTester.sh b/42sh/42shelltest-tmp/42ShellTester.sh new file mode 100644 index 00000000..8bb3198b --- /dev/null +++ b/42sh/42shelltest-tmp/42ShellTester.sh @@ -0,0 +1,122 @@ +#!/bin/bash + +# /* +# Launcher +# */ + +get_install_directory() +{ + local SOURCE="${BASH_SOURCE[0]}" + local DIR + while [ -h "${SOURCE}" ] + do + DIR="$(cd -P "$(dirname "${SOURCE}")" && pwd)" + SOURCE="$(readlink "${SOURCE}")" + [[ "${SOURCE}" != /* ]] && SOURCE="${DIR}/${SOURCE}" + done + printf "%s" "$(cd -P "$(dirname "${SOURCE}")" && pwd)" +} + +# global variables +GLOBAL_PROG="" +GLOBAL_PROG_REFERENCE="" +GLOBAL_SPECS_FILTER="" +GLOBAL_ENTRYPATH=$(pwd) +GLOBAL_INSTALLDIR="$(get_install_directory)" +GLOBAL_TMP_DIRECTORY="${GLOBAL_INSTALLDIR}/tmp" +GLOBAL_LOCALBRANCH=$(git branch | awk '$0 ~ /^\*/ {print $2; exit}') +GLOBAL_TOKEN="TOKEN$(date +%Y%m%d%H%M)" +GLOBAL_TOTAL_TESTS=0 +GLOBAL_TOTAL_FAILED_TESTS=0 +GLOBAL_TOTAL_PENDING_TESTS=0 +GLOBAL_LOG="" +GLOBAL_SHOW_SUCCESS=0 +GLOBAL_RUN_POSIX_ONLY=0 +GLOBAL_RUN_PENDING_TESTS=0 +GLOBAL_RUN_HARD_TESTS=0 +GLOBAL_RUN_ALL_TESTS=0 +GLOBAL_INVALID_OPTION=0 +C_BOLD="\033[37;1m" +C_RED="\033[31m\033[38;5;160m" +C_GREEN="\033[31m\033[38;5;34m" +C_YELLOW="\033[31m\033[1;33m" +C_GREY="\033[38;5;239m" +C_CLEAR="\033[0m" + +# retrieve options +while [ ! -z "${1}" ]; do + if [[ "${1}" =~ ^-- ]] + then + case "${1}" in + "--reference") + shift 1 + GLOBAL_PROG_REFERENCE="$(which ${1})" + ;; + "--filter") + shift 1 + GLOBAL_SPECS_FILTER="${1}" + ;; + "--show-success") + GLOBAL_SHOW_SUCCESS=1 + ;; + "--pending") + GLOBAL_RUN_PENDING_TESTS=1 + ;; + "--posix") + GLOBAL_RUN_POSIX_ONLY=1 + ;; + "--hard") + GLOBAL_RUN_HARD_TESTS=1 + ;; + "--all") + GLOBAL_RUN_ALL_TESTS=1 + ;; + *) + printf "%s\n" "Invalid option: ${1}" + exit 1 + ;; + esac + else + if [ "${GLOBAL_PROG}" == "" ] + then + [[ "${1}" =~ ^[\.][\.]\/ ]] && GLOBAL_PROG="../${1}" || GLOBAL_PROG="$(which ${1})" + fi + fi + shift 1 +done + +# go to install directory +cd "${GLOBAL_INSTALLDIR}" + +# load application sources +for FILE in ./lib/* ./lib/verbs/* +do + if [ -f "${FILE}" ] + then + source "${FILE}" + fi +done + +# create and go to temporary directory +mkdir -p "${GLOBAL_TMP_DIRECTORY}" +cd "${GLOBAL_TMP_DIRECTORY}" + +# compile support binaries +make re -C "${GLOBAL_INSTALLDIR}/support/" TARGET_DIR=${GLOBAL_TMP_DIRECTORY} 1>- 2>- + +# run main function +run_main + +# display log +printf "%s\n\nTotal tests: %s\nTotal failed tests: %s\nTotal pending tests: %s\n" "${GLOBAL_LOG}" "${GLOBAL_TOTAL_TESTS}" "${GLOBAL_TOTAL_FAILED_TESTS}" "${GLOBAL_TOTAL_PENDING_TESTS}" + +# go back to entry directory +cd "${GLOBAL_ENTRYPATH}" + +# exit with success or error status +if [ "${GLOBAL_TOTAL_FAILED_TESTS}" == "0" ] +then + exit 0 +else + exit 1 +fi diff --git a/42sh/42shelltest-tmp/README.md b/42sh/42shelltest-tmp/README.md new file mode 100644 index 00000000..2d908aee --- /dev/null +++ b/42sh/42shelltest-tmp/README.md @@ -0,0 +1,596 @@ +# 42ShellTester + +42ShellTester is an **integration testing framework** wrote in Bash and designed for the pedagogical projects of the Shell branch at School 42 (Paris) listed bellow: +* **minishell** +* **21sh** +* **42sh** + +It brings you an easy way to **add**, **maintain** and **run** integration tests, helping you to work step by step on your Shell implementation. + + +42ShellTester is currently packaged with **304 tests**. + + +## Install + +```bash +git clone https://github.com/we-sh/42ShellTester ~/42ShellTester +``` + +## Run tests + +Add the path to your Shell as argument: + +```bash +bash ~/42ShellTester/42ShellTester.sh "/ABSOLUTE/PATH/TO/YOUR/SHELL" +``` + +## Options + +##### `--filter` + `$regex` + +Run tests that matches with the specified regular expression (e.g. `--filter "builtins"`). + +##### `--reference` + `$binary` + +Run tests that does not fail with the specified Shell binary (e.g. `--reference "bash"`). + +##### `--posix` + +Run tests that are POSIX compliant only (run all by default). + +##### `--hard` + +Run tests that are marked as « hard » (omitted by default). + +##### `--pending` + +Also run pending tests. + +##### `--all` + +Equivalent to use the two options `--pending` and `--hard` together. + +##### `--show-success` + +Also display tests that succeed (hidden by default). + +## List of tests + + +* **[21sh/](spec/21sh)** + * **[misc/](spec/21sh/misc)** + * [001-no-prompt-in-non-interactive-mode](spec/21sh/misc/001-no-prompt-in-non-interactive-mode) + * [002-simple-command-line](spec/21sh/misc/002-simple-command-line) + * **[pipe/](spec/21sh/pipe)** + * [001-single-pipe](spec/21sh/pipe/001-single-pipe) + * [002-chained-pipes](spec/21sh/pipe/002-chained-pipes) + * [003-many-chained-pipes](spec/21sh/pipe/003-many-chained-pipes) + * [004-without-surrounding-whitespaces](spec/21sh/pipe/004-without-surrounding-whitespaces) + * [005-asynchronous](spec/21sh/pipe/005-asynchronous) + * [006-exit-status](spec/21sh/pipe/006-exit-status) + * **[mixed/](spec/21sh/pipe/mixed)** + * [001-exit-or-not-exit ](spec/21sh/pipe/mixed/001-exit-or-not-exit) + * [002-cd-or-not-cd ](spec/21sh/pipe/mixed/002-cd-or-not-cd) + * [003-unsetenv-or-not-unsetenv ](spec/21sh/pipe/mixed/003-unsetenv-or-not-unsetenv) + * [004-setenv-or-not-setenv ](spec/21sh/pipe/mixed/004-setenv-or-not-setenv) + * **[redirections/](spec/21sh/redirections)** + * **[inputs/](spec/21sh/redirections/inputs)** + * [001-close-stdin](spec/21sh/redirections/inputs/001-close-stdin) + * [002-filename](spec/21sh/redirections/inputs/002-filename) + * [003-filename-with-whitespaces](spec/21sh/redirections/inputs/003-filename-with-whitespaces) + * [004-absolute-path](spec/21sh/redirections/inputs/004-absolute-path) + * [005-no-such-file](spec/21sh/redirections/inputs/005-no-such-file) + * **[outputs/](spec/21sh/redirections/outputs)** + * **[appending/](spec/21sh/redirections/outputs/appending)** + * [001-append-default-to-file](spec/21sh/redirections/outputs/appending/001-append-default-to-file) + * [002-append-stdout-to-file](spec/21sh/redirections/outputs/appending/002-append-stdout-to-file) + * [003-append-stderr-to-file](spec/21sh/redirections/outputs/appending/003-append-stderr-to-file) + * **[multiple/](spec/21sh/redirections/outputs/appending/multiple)** + * [001-append-twice-separately](spec/21sh/redirections/outputs/appending/multiple/001-append-twice-separately) + * **[closing/](spec/21sh/redirections/outputs/closing)** + * [001-close-default-output](spec/21sh/redirections/outputs/closing/001-close-default-output) + * [002-close-stdout](spec/21sh/redirections/outputs/closing/002-close-stdout) + * [003-close-stderr](spec/21sh/redirections/outputs/closing/003-close-stderr) + * [004-close-twice-outputs](spec/21sh/redirections/outputs/closing/004-close-twice-outputs) + * **[touching/](spec/21sh/redirections/outputs/touching)** + * [001-works](spec/21sh/redirections/outputs/touching/001-works) + * **[truncating/](spec/21sh/redirections/outputs/truncating)** + * [001-creates-file-if-not-exits](spec/21sh/redirections/outputs/truncating/001-creates-file-if-not-exits) + * [002-truncates-file-if-exists](spec/21sh/redirections/outputs/truncating/002-truncates-file-if-exists) + * [003-whitespace-before-filename](spec/21sh/redirections/outputs/truncating/003-whitespace-before-filename) + * **[multiple/](spec/21sh/redirections/outputs/truncating/multiple)** + * [001-separately](spec/21sh/redirections/outputs/truncating/multiple/001-separately) + * [002-together-stdout-first](spec/21sh/redirections/outputs/truncating/multiple/002-together-stdout-first) + * [003-together-stderr-first](spec/21sh/redirections/outputs/truncating/multiple/003-together-stderr-first) + * [004-together](spec/21sh/redirections/outputs/truncating/multiple/004-together) + * [005-together-with-whitespaces](spec/21sh/redirections/outputs/truncating/multiple/005-together-with-whitespaces) + * **[stderr/](spec/21sh/redirections/outputs/truncating/stderr)** + * [001-works](spec/21sh/redirections/outputs/truncating/stderr/001-works) + * **[stdout/](spec/21sh/redirections/outputs/truncating/stdout)** + * [001-with-explicit-fd](spec/21sh/redirections/outputs/truncating/stdout/001-with-explicit-fd) + * **[separators/](spec/21sh/separators)** + * **[semicolon/](spec/21sh/separators/semicolon)** + * [001-two-commands-sequentially](spec/21sh/separators/semicolon/001-two-commands-sequentially) + * [002-n-commands-sequentially](spec/21sh/separators/semicolon/002-n-commands-sequentially) + * [003-parse-error-empty-inline-command](spec/21sh/separators/semicolon/003-parse-error-empty-inline-command) + * [004-parse-error-empty-command](spec/21sh/separators/semicolon/004-parse-error-empty-command) +* **[42sh/](spec/42sh)** + * **[builtins/](spec/42sh/builtins)** + * **[export/](spec/42sh/builtins/export)** + * [001-display-env](spec/42sh/builtins/export/001-display-env) + * [002-export-basic-key-value-1](spec/42sh/builtins/export/002-export-basic-key-value-1) + * [003-export-basic-key-value-2](spec/42sh/builtins/export/003-export-basic-key-value-2) + * [004-export-empty-variable-1](spec/42sh/builtins/export/004-export-empty-variable-1) + * [005-export-empty-variable-2](spec/42sh/builtins/export/005-export-empty-variable-2) + * [006-export-update-env-variable](spec/42sh/builtins/export/006-export-update-env-variable) + * [007-existing-environment-variable](spec/42sh/builtins/export/007-existing-environment-variable) + * [008-local-to-environment](spec/42sh/builtins/export/008-local-to-environment) + * [009-export-with-equal-but-no-value-part1](spec/42sh/builtins/export/009-export-with-equal-but-no-value-part1) + * [010-export-with-equal-but-no-value-part2](spec/42sh/builtins/export/010-export-with-equal-but-no-value-part2) + * **[errors/](spec/42sh/builtins/export/errors)** + * [001-invalid-identifier-1](spec/42sh/builtins/export/errors/001-invalid-identifier-1) + * [002-invalid-identifier-2](spec/42sh/builtins/export/errors/002-invalid-identifier-2) + * [003-illegal-option](spec/42sh/builtins/export/errors/003-illegal-option) + * **[mixed/](spec/42sh/builtins/export/mixed)** + * [001-export-and-tmp-env-part1](spec/42sh/builtins/export/mixed/001-export-and-tmp-env-part1) + * [002-export-and-tmp-env-part2](spec/42sh/builtins/export/mixed/002-export-and-tmp-env-part2) + * **[options/](spec/42sh/builtins/export/options)** + * [001-export-with-only-p-parameter](spec/42sh/builtins/export/options/001-export-with-only-p-parameter) + * [002-export-p-param-and-token-should-add-local-var-only-part1](spec/42sh/builtins/export/options/002-export-p-param-and-token-should-add-local-var-only-part1) + * [003-export-p-param-and-token-should-add-local-var-only-part2](spec/42sh/builtins/export/options/003-export-p-param-and-token-should-add-local-var-only-part2) + * [004-export-n-param](spec/42sh/builtins/export/options/004-export-n-param) + * **[escaping/](spec/42sh/escaping)** + * [001-escape-single-character-1](spec/42sh/escaping/001-escape-single-character-1) + * [002-escape-single-character-2](spec/42sh/escaping/002-escape-single-character-2) + * [003-escape-single-character-3](spec/42sh/escaping/003-escape-single-character-3) + * [004-escape-single-character-4](spec/42sh/escaping/004-escape-single-character-4) + * [005-escape-single-character-5](spec/42sh/escaping/005-escape-single-character-5) + * **[mixed/](spec/42sh/escaping/mixed)** + * **[globbing/](spec/42sh/escaping/mixed/globbing)** + * **[brace-expansion/](spec/42sh/escaping/mixed/globbing/brace-expansion)** + * [001-it-does-not-expand-braces-1](spec/42sh/escaping/mixed/globbing/brace-expansion/001-it-does-not-expand-braces-1) + * [002-it-expands-braces-1](spec/42sh/escaping/mixed/globbing/brace-expansion/002-it-expands-braces-1) + * [003-it-expands-braces-2](spec/42sh/escaping/mixed/globbing/brace-expansion/003-it-expands-braces-2) + * **[bracket-expansion/](spec/42sh/escaping/mixed/globbing/bracket-expansion)** + * [001-it-does-not-expand-brackets](spec/42sh/escaping/mixed/globbing/bracket-expansion/001-it-does-not-expand-brackets) + * [002-escaped-inversion-mark](spec/42sh/escaping/mixed/globbing/bracket-expansion/002-escaped-inversion-mark) + * [003-it-takes-escaped-bracket-as-pattern-character](spec/42sh/escaping/mixed/globbing/bracket-expansion/003-it-takes-escaped-bracket-as-pattern-character) + * **[variable-expansion/](spec/42sh/escaping/mixed/variable-expansion)** + * [001-escape-variable-1](spec/42sh/escaping/mixed/variable-expansion/001-escape-variable-1) + * [002-it-does-not-escape-variable](spec/42sh/escaping/mixed/variable-expansion/002-it-does-not-escape-variable) + * [003-escape-variable-2](spec/42sh/escaping/mixed/variable-expansion/003-escape-variable-2) + * **[globbing/](spec/42sh/globbing)** + * **[brace-expansion/](spec/42sh/globbing/brace-expansion)** + * **[ascii-range/](spec/42sh/globbing/brace-expansion/ascii-range)** + * [001-simple-ascending-1](spec/42sh/globbing/brace-expansion/ascii-range/001-simple-ascending-1) + * [002-simple-ascending-2](spec/42sh/globbing/brace-expansion/ascii-range/002-simple-ascending-2) + * [003-simple-ascending-3](spec/42sh/globbing/brace-expansion/ascii-range/003-simple-ascending-3) + * [004-simple-descending-1](spec/42sh/globbing/brace-expansion/ascii-range/004-simple-descending-1) + * [005-simple-descending-2](spec/42sh/globbing/brace-expansion/ascii-range/005-simple-descending-2) + * [006-simple-descending-3](spec/42sh/globbing/brace-expansion/ascii-range/006-simple-descending-3) + * [007-identical-start-and-end](spec/42sh/globbing/brace-expansion/ascii-range/007-identical-start-and-end) + * [008-multiple-1](spec/42sh/globbing/brace-expansion/ascii-range/008-multiple-1) + * [009-multiple-2](spec/42sh/globbing/brace-expansion/ascii-range/009-multiple-2) + * [010-big-range](spec/42sh/globbing/brace-expansion/ascii-range/010-big-range) + * **[errors/](spec/42sh/globbing/brace-expansion/errors)** + * [001-invalid-pattern-1](spec/42sh/globbing/brace-expansion/errors/001-invalid-pattern-1) + * [002-invalid-pattern-2](spec/42sh/globbing/brace-expansion/errors/002-invalid-pattern-2) + * [003-invalid-pattern-3](spec/42sh/globbing/brace-expansion/errors/003-invalid-pattern-3) + * [004-invalid-pattern-4](spec/42sh/globbing/brace-expansion/errors/004-invalid-pattern-4) + * **[list-of-values/](spec/42sh/globbing/brace-expansion/list-of-values)** + * [001-nothing-to-be-done](spec/42sh/globbing/brace-expansion/list-of-values/001-nothing-to-be-done) + * [002-simple-test-1](spec/42sh/globbing/brace-expansion/list-of-values/002-simple-test-1) + * [003-simple-test-2](spec/42sh/globbing/brace-expansion/list-of-values/003-simple-test-2) + * **[numeric-range/](spec/42sh/globbing/brace-expansion/numeric-range)** + * [001-simple-ascending-1](spec/42sh/globbing/brace-expansion/numeric-range/001-simple-ascending-1) + * [002-simple-ascending-2](spec/42sh/globbing/brace-expansion/numeric-range/002-simple-ascending-2) + * [003-simple-ascending-3](spec/42sh/globbing/brace-expansion/numeric-range/003-simple-ascending-3) + * [004-simple-ascending-4](spec/42sh/globbing/brace-expansion/numeric-range/004-simple-ascending-4) + * [005-simple-ascending-5](spec/42sh/globbing/brace-expansion/numeric-range/005-simple-ascending-5) + * [006-simple-descending-1](spec/42sh/globbing/brace-expansion/numeric-range/006-simple-descending-1) + * [007-simple-descending-2](spec/42sh/globbing/brace-expansion/numeric-range/007-simple-descending-2) + * [008-simple-descending-3](spec/42sh/globbing/brace-expansion/numeric-range/008-simple-descending-3) + * [009-simple-descending-4](spec/42sh/globbing/brace-expansion/numeric-range/009-simple-descending-4) + * [010-simple-descending-5](spec/42sh/globbing/brace-expansion/numeric-range/010-simple-descending-5) + * [011-identical-positive-start-and-end](spec/42sh/globbing/brace-expansion/numeric-range/011-identical-positive-start-and-end) + * [012-identical-negative-start-and-end](spec/42sh/globbing/brace-expansion/numeric-range/012-identical-negative-start-and-end) + * [013-multiple-1](spec/42sh/globbing/brace-expansion/numeric-range/013-multiple-1) + * [014-multiple-2](spec/42sh/globbing/brace-expansion/numeric-range/014-multiple-2) + * [015-big-range](spec/42sh/globbing/brace-expansion/numeric-range/015-big-range) + * **[bracket-expansion/](spec/42sh/globbing/bracket-expansion)** + * **[multi/](spec/42sh/globbing/bracket-expansion/multi)** + * [001-range-and-char](spec/42sh/globbing/bracket-expansion/multi/001-range-and-char) + * [002-reverse-range-and-chars](spec/42sh/globbing/bracket-expansion/multi/002-reverse-range-and-chars) + * [003-reverse-multi-hard](spec/42sh/globbing/bracket-expansion/multi/003-reverse-multi-hard) + * [004-simple-bracket+char+range](spec/42sh/globbing/bracket-expansion/multi/004-simple-bracket+char+range) + * **[not/](spec/42sh/globbing/bracket-expansion/not)** + * [001-simple-opposit-match](spec/42sh/globbing/bracket-expansion/not/001-simple-opposit-match) + * [002-simple-opposite-range](spec/42sh/globbing/bracket-expansion/not/002-simple-opposite-range) + * **[range-pattern/](spec/42sh/globbing/bracket-expansion/range-pattern)** + * [001-alpha-range](spec/42sh/globbing/bracket-expansion/range-pattern/001-alpha-range) + * [002-numeric-range](spec/42sh/globbing/bracket-expansion/range-pattern/002-numeric-range) + * [003-ascii-range-1](spec/42sh/globbing/bracket-expansion/range-pattern/003-ascii-range-1) + * [004-ascii-range-2](spec/42sh/globbing/bracket-expansion/range-pattern/004-ascii-range-2) + * **[simple-pattern/](spec/42sh/globbing/bracket-expansion/simple-pattern)** + * [001-simple-list](spec/42sh/globbing/bracket-expansion/simple-pattern/001-simple-list) + * [002-multi-bracket](spec/42sh/globbing/bracket-expansion/simple-pattern/002-multi-bracket) + * [003-brackets-as-pattern](spec/42sh/globbing/bracket-expansion/simple-pattern/003-brackets-as-pattern) + * [004-multi-bracket-multi-char](spec/42sh/globbing/bracket-expansion/simple-pattern/004-multi-bracket-multi-char) + * **[single-char-pattern/](spec/42sh/globbing/bracket-expansion/single-char-pattern)** + * [001-single-char](spec/42sh/globbing/bracket-expansion/single-char-pattern/001-single-char) + * [002-closing-bracket-char](spec/42sh/globbing/bracket-expansion/single-char-pattern/002-closing-bracket-char) + * [003-opening-bracket-char](spec/42sh/globbing/bracket-expansion/single-char-pattern/003-opening-bracket-char) + * **[local-variable/](spec/42sh/local-variable)** + * [001-declare-and-expand-1](spec/42sh/local-variable/001-declare-and-expand-1) + * [002-declare-and-expand-2](spec/42sh/local-variable/002-declare-and-expand-2) + * [003-unknown-variable-does-not-result-in-new-argument](spec/42sh/local-variable/003-unknown-variable-does-not-result-in-new-argument) + * [004-existing-variable-in-environment-1](spec/42sh/local-variable/004-existing-variable-in-environment-1) + * [005-existing-variable-in-environment-2](spec/42sh/local-variable/005-existing-variable-in-environment-2) + * [006-existing-variable-in-environment-3](spec/42sh/local-variable/006-existing-variable-in-environment-3) + * [007-multiple-declaration-at-a-time](spec/42sh/local-variable/007-multiple-declaration-at-a-time) + * [008-multiple-declaration-with-same-name](spec/42sh/local-variable/008-multiple-declaration-with-same-name) + * [009-last-exit-status](spec/42sh/local-variable/009-last-exit-status) + * **[mixed/](spec/42sh/local-variable/mixed)** + * **[inline-environment-variable/](spec/42sh/local-variable/mixed/inline-environment-variable)** + * [001-local-variable-shouldnt-be-set](spec/42sh/local-variable/mixed/inline-environment-variable/001-local-variable-shouldnt-be-set) + * **[redirections/](spec/42sh/local-variable/mixed/redirections)** + * [001-truncating](spec/42sh/local-variable/mixed/redirections/001-truncating) + * [002-appending](spec/42sh/local-variable/mixed/redirections/002-appending) + * [003-reading](spec/42sh/local-variable/mixed/redirections/003-reading) + * **[tilde-expansion/](spec/42sh/local-variable/mixed/tilde-expansion)** + * [001-process-tilde-expansion](spec/42sh/local-variable/mixed/tilde-expansion/001-process-tilde-expansion) + * **[quoting/](spec/42sh/quoting)** + * **[double-quotes/](spec/42sh/quoting/double-quotes)** + * [001-it-works](spec/42sh/quoting/double-quotes/001-it-works) + * [002-concatenated-strings](spec/42sh/quoting/double-quotes/002-concatenated-strings) + * [003-first-argument-inhibited](spec/42sh/quoting/double-quotes/003-first-argument-inhibited) + * [004-multiline-1](spec/42sh/quoting/double-quotes/004-multiline-1) + * [005-multiline-2](spec/42sh/quoting/double-quotes/005-multiline-2) + * **[mixed/](spec/42sh/quoting/double-quotes/mixed)** + * **[escaping/](spec/42sh/quoting/double-quotes/mixed/escaping)** + * [001-escape-double-quote-1](spec/42sh/quoting/double-quotes/mixed/escaping/001-escape-double-quote-1) + * [002-escape-double-quote-2](spec/42sh/quoting/double-quotes/mixed/escaping/002-escape-double-quote-2) + * [003-escape-double-quote-3](spec/42sh/quoting/double-quotes/mixed/escaping/003-escape-double-quote-3) + * [004-it-results-in-error](spec/42sh/quoting/double-quotes/mixed/escaping/004-it-results-in-error) + * [005-it-does-not-escape-double-quote](spec/42sh/quoting/double-quotes/mixed/escaping/005-it-does-not-escape-double-quote) + * **[globbing/](spec/42sh/quoting/double-quotes/mixed/globbing)** + * **[brace-expansion/](spec/42sh/quoting/double-quotes/mixed/globbing/brace-expansion)** + * [001-it-does-not-expand-braces-1](spec/42sh/quoting/double-quotes/mixed/globbing/brace-expansion/001-it-does-not-expand-braces-1) + * [002-it-does-not-expand-braces-2](spec/42sh/quoting/double-quotes/mixed/globbing/brace-expansion/002-it-does-not-expand-braces-2) + * [003-it-does-not-expand-braces-3](spec/42sh/quoting/double-quotes/mixed/globbing/brace-expansion/003-it-does-not-expand-braces-3) + * [004-it-does-not-expand-braces-4](spec/42sh/quoting/double-quotes/mixed/globbing/brace-expansion/004-it-does-not-expand-braces-4) + * [005-it-does-not-expand-braces-5](spec/42sh/quoting/double-quotes/mixed/globbing/brace-expansion/005-it-does-not-expand-braces-5) + * **[bracket-expansion/](spec/42sh/quoting/double-quotes/mixed/globbing/bracket-expansion)** + * [001-it-works-1](spec/42sh/quoting/double-quotes/mixed/globbing/bracket-expansion/001-it-works-1) + * [002-it-works-2](spec/42sh/quoting/double-quotes/mixed/globbing/bracket-expansion/002-it-works-2) + * **[variable-expansion/](spec/42sh/quoting/double-quotes/mixed/variable-expansion)** + * [001-expansion-enabled](spec/42sh/quoting/double-quotes/mixed/variable-expansion/001-expansion-enabled) + * **[mixed/](spec/42sh/quoting/mixed)** + * [001-simple-and-double-quotes](spec/42sh/quoting/mixed/001-simple-and-double-quotes) + * [002-multiline](spec/42sh/quoting/mixed/002-multiline) + * **[globbing/](spec/42sh/quoting/mixed/globbing)** + * **[brace-expansion/](spec/42sh/quoting/mixed/globbing/brace-expansion)** + * [001-it-does-not-expand-braces-1](spec/42sh/quoting/mixed/globbing/brace-expansion/001-it-does-not-expand-braces-1) + * **[bracket-expansion/](spec/42sh/quoting/mixed/globbing/bracket-expansion)** + * [001-it-works-1](spec/42sh/quoting/mixed/globbing/bracket-expansion/001-it-works-1) + * [002-it-works-2](spec/42sh/quoting/mixed/globbing/bracket-expansion/002-it-works-2) + * **[variable-expansion/](spec/42sh/quoting/mixed/variable-expansion)** + * [001-it-does-not-expand-in-quotes](spec/42sh/quoting/mixed/variable-expansion/001-it-does-not-expand-in-quotes) + * **[simple-quotes/](spec/42sh/quoting/simple-quotes)** + * [001-it-works](spec/42sh/quoting/simple-quotes/001-it-works) + * [002-concatenated-strings](spec/42sh/quoting/simple-quotes/002-concatenated-strings) + * [003-first-argument-inhibited](spec/42sh/quoting/simple-quotes/003-first-argument-inhibited) + * [004-multiline-1](spec/42sh/quoting/simple-quotes/004-multiline-1) + * [005-multiline-2](spec/42sh/quoting/simple-quotes/005-multiline-2) + * **[mixed/](spec/42sh/quoting/simple-quotes/mixed)** + * **[escaping/](spec/42sh/quoting/simple-quotes/mixed/escaping)** + * [001-escape-simple-quote-1](spec/42sh/quoting/simple-quotes/mixed/escaping/001-escape-simple-quote-1) + * [002-escape-simple-quote-2](spec/42sh/quoting/simple-quotes/mixed/escaping/002-escape-simple-quote-2) + * [003-escape-simple-quote-3](spec/42sh/quoting/simple-quotes/mixed/escaping/003-escape-simple-quote-3) + * [004-it-does-not-escape-simple-quote-1](spec/42sh/quoting/simple-quotes/mixed/escaping/004-it-does-not-escape-simple-quote-1) + * [005-it-does-not-escape-simple-quote-2](spec/42sh/quoting/simple-quotes/mixed/escaping/005-it-does-not-escape-simple-quote-2) + * **[globbing/](spec/42sh/quoting/simple-quotes/mixed/globbing)** + * **[brace-expansion/](spec/42sh/quoting/simple-quotes/mixed/globbing/brace-expansion)** + * [001-it-does-not-expand-braces-1](spec/42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/001-it-does-not-expand-braces-1) + * [002-it-does-not-expand-braces-2](spec/42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/002-it-does-not-expand-braces-2) + * [003-it-does-not-expand-braces-3](spec/42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/003-it-does-not-expand-braces-3) + * [004-it-does-not-expand-braces-4](spec/42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/004-it-does-not-expand-braces-4) + * [005-it-does-not-expand-braces-5](spec/42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/005-it-does-not-expand-braces-5) + * **[bracket-expansion/](spec/42sh/quoting/simple-quotes/mixed/globbing/bracket-expansion)** + * [001-it-works-1](spec/42sh/quoting/simple-quotes/mixed/globbing/bracket-expansion/001-it-works-1) + * [002-it-works-2](spec/42sh/quoting/simple-quotes/mixed/globbing/bracket-expansion/002-it-works-2) + * **[variable-expansion/](spec/42sh/quoting/simple-quotes/mixed/variable-expansion)** + * [001-expansion-disabled](spec/42sh/quoting/simple-quotes/mixed/variable-expansion/001-expansion-disabled) + * **[shellscript/](spec/42sh/shellscript)** + * **[if/](spec/42sh/shellscript/if)** + * [001-simple-if-1](spec/42sh/shellscript/if/001-simple-if-1) + * [002-simple-if-2](spec/42sh/shellscript/if/002-simple-if-2) + * [003-simple-if-3](spec/42sh/shellscript/if/003-simple-if-3) + * [004-nested-if](spec/42sh/shellscript/if/004-nested-if) + * [005-hard-nested-if](spec/42sh/shellscript/if/005-hard-nested-if) + * **[until/](spec/42sh/shellscript/until)** + * [001-simple-until-1](spec/42sh/shellscript/until/001-simple-until-1) + * [002-simple-until-2](spec/42sh/shellscript/until/002-simple-until-2) + * [003-simple-until-3](spec/42sh/shellscript/until/003-simple-until-3) + * [004-nested-until](spec/42sh/shellscript/until/004-nested-until) + * [005-hard-nested-until](spec/42sh/shellscript/until/005-hard-nested-until) + * **[while/](spec/42sh/shellscript/while)** + * [001-simple-while-1](spec/42sh/shellscript/while/001-simple-while-1) + * [002-simple-while-2](spec/42sh/shellscript/while/002-simple-while-2) + * [003-simple-while-3](spec/42sh/shellscript/while/003-simple-while-3) + * [004-nested-while](spec/42sh/shellscript/while/004-nested-while) + * [005-hard-nested-while](spec/42sh/shellscript/while/005-hard-nested-while) + * **[subshell/](spec/42sh/subshell)** + * [001-tokens-are-recognized](spec/42sh/subshell/001-tokens-are-recognized) + * [002-multiple-levels-of-subshells](spec/42sh/subshell/002-multiple-levels-of-subshells) + * [003-multiline](spec/42sh/subshell/003-multiline) + * [004-exit-status](spec/42sh/subshell/004-exit-status) + * [005-copy-of-environment](spec/42sh/subshell/005-copy-of-environment) + * **[errors/](spec/42sh/subshell/errors)** + * [001-parse-error-1](spec/42sh/subshell/errors/001-parse-error-1) + * [002-parse-error-2](spec/42sh/subshell/errors/002-parse-error-2) + * [003-parse-error-3](spec/42sh/subshell/errors/003-parse-error-3) + * [004-parse-error-4](spec/42sh/subshell/errors/004-parse-error-4) + * **[mixed/](spec/42sh/subshell/mixed)** + * **[builtins/](spec/42sh/subshell/mixed/builtins)** + * **[cd/](spec/42sh/subshell/mixed/builtins/cd)** + * [001-it-does-not-change-current-directory](spec/42sh/subshell/mixed/builtins/cd/001-it-does-not-change-current-directory) + * [002-multiline](spec/42sh/subshell/mixed/builtins/cd/002-multiline) + * **[exit/](spec/42sh/subshell/mixed/builtins/exit)** + * [001-exiting-subshell](spec/42sh/subshell/mixed/builtins/exit/001-exiting-subshell) + * **[setenv/](spec/42sh/subshell/mixed/builtins/setenv)** + * [001-it-does-not-modify-parent-environment](spec/42sh/subshell/mixed/builtins/setenv/001-it-does-not-modify-parent-environment) + * **[unsetenv/](spec/42sh/subshell/mixed/builtins/unsetenv)** + * [001-it-does-not-modify-parent-environment](spec/42sh/subshell/mixed/builtins/unsetenv/001-it-does-not-modify-parent-environment) + * **[escaping/](spec/42sh/subshell/mixed/escaping)** + * [001-escaped-subshell-1](spec/42sh/subshell/mixed/escaping/001-escaped-subshell-1) + * [002-escaped-subshell-2](spec/42sh/subshell/mixed/escaping/002-escaped-subshell-2) + * **[inline-environment-variable/](spec/42sh/subshell/mixed/inline-environment-variable)** + * [001-modifies-the-child-environment-only-1](spec/42sh/subshell/mixed/inline-environment-variable/001-modifies-the-child-environment-only-1) + * [002-modifies-the-child-environment-only-2](spec/42sh/subshell/mixed/inline-environment-variable/002-modifies-the-child-environment-only-2) + * **[piping/](spec/42sh/subshell/mixed/piping)** + * [001-subshells-inside-piped-command](spec/42sh/subshell/mixed/piping/001-subshells-inside-piped-command) + * [002-pipes-inside-subshells](spec/42sh/subshell/mixed/piping/002-pipes-inside-subshells) + * [003-imbricated-subshells-and-pipes](spec/42sh/subshell/mixed/piping/003-imbricated-subshells-and-pipes) + * **[quoting/](spec/42sh/subshell/mixed/quoting)** + * [001-with-simple-quotes](spec/42sh/subshell/mixed/quoting/001-with-simple-quotes) + * [002-with-double-quotes](spec/42sh/subshell/mixed/quoting/002-with-double-quotes) + * [003-with-simple-and-double-quotes](spec/42sh/subshell/mixed/quoting/003-with-simple-and-double-quotes) +* **[bonuses/](spec/bonuses)** + * **[builtins/](spec/bonuses/builtins)** + * **[env/](spec/bonuses/builtins/env)** + * [001-unset-variables ](spec/bonuses/builtins/env/001-unset-variables) + * [002-unset-and-set-variable ](spec/bonuses/builtins/env/002-unset-and-set-variable) + * **[inline-environment-variable/](spec/bonuses/inline-environment-variable)** + * [001-modifies-child-environment-1](spec/bonuses/inline-environment-variable/001-modifies-child-environment-1) + * [002-modifies-child-environment-2](spec/bonuses/inline-environment-variable/002-modifies-child-environment-2) + * [003-modifies-PATH-only](spec/bonuses/inline-environment-variable/003-modifies-PATH-only) + * **[redirections/](spec/bonuses/redirections)** + * [001-append-twice-outputs-together ](spec/bonuses/redirections/001-append-twice-outputs-together) + * **[separators/](spec/bonuses/separators)** + * **[and/](spec/bonuses/separators/and)** + * [001-run-twice](spec/bonuses/separators/and/001-run-twice) + * [002-do-not-run-second](spec/bonuses/separators/and/002-do-not-run-second) + * [003-run-until-failing](spec/bonuses/separators/and/003-run-until-failing) + * **[errors/](spec/bonuses/separators/and/errors)** + * [001-parse-error-at-beginning](spec/bonuses/separators/and/errors/001-parse-error-at-beginning) + * [002-parse-error-too-much-symbol](spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol) + * **[mixed/](spec/bonuses/separators/mixed)** + * [001-and-or](spec/bonuses/separators/mixed/001-and-or) + * [002-and-or](spec/bonuses/separators/mixed/002-and-or) + * [003-and-or](spec/bonuses/separators/mixed/003-and-or) + * [004-or-and](spec/bonuses/separators/mixed/004-or-and) + * [005-or-and](spec/bonuses/separators/mixed/005-or-and) + * [006-or-and](spec/bonuses/separators/mixed/006-or-and) + * **[or/](spec/bonuses/separators/or)** + * [001-run-first-only](spec/bonuses/separators/or/001-run-first-only) + * [002-run-second-only](spec/bonuses/separators/or/002-run-second-only) + * [003-run-until-succeeding](spec/bonuses/separators/or/003-run-until-succeeding) + * **[errors/](spec/bonuses/separators/or/errors)** + * [001-parse-error-at-beginning](spec/bonuses/separators/or/errors/001-parse-error-at-beginning) + * [002-parse-error-too-much-symbol](spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol) + * **[tilde-expansion/](spec/bonuses/tilde-expansion)** + * [001-expanded-with-HOME-1](spec/bonuses/tilde-expansion/001-expanded-with-HOME-1) + * [002-expanded-with-HOME-2](spec/bonuses/tilde-expansion/002-expanded-with-HOME-2) + * [003-expanded-with-PWD-1](spec/bonuses/tilde-expansion/003-expanded-with-PWD-1) + * [004-expanded-with-PWD-2](spec/bonuses/tilde-expansion/004-expanded-with-PWD-2) + * [005-expanded-with-OLDPWD-1](spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1) + * [006-expanded-with-OLDPWD-2](spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2) + * **[not-expanded/](spec/bonuses/tilde-expansion/not-expanded)** + * [001-not-expanded-with-HOME-1](spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1) + * [002-not-expanded-with-HOME-2](spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2) + * [003-not-expanded-with-PWD](spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD) + * [004-not-expanded-with-OLDPWD](spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD) +* **[minishell/](spec/minishell)** + * **[binary/](spec/minishell/binary)** + * [001-binary-path-relative](spec/minishell/binary/001-binary-path-relative) + * [002-binary-path-absolute](spec/minishell/binary/002-binary-path-absolute) + * [003-binary-test-exec-order](spec/minishell/binary/003-binary-test-exec-order) + * [004-binary-test-empty-path](spec/minishell/binary/004-binary-test-empty-path) + * [005-binary-test-wrong-path](spec/minishell/binary/005-binary-test-wrong-path) + * [006-binary-undefined-path](spec/minishell/binary/006-binary-undefined-path) + * [007-binary-permission-denied](spec/minishell/binary/007-binary-permission-denied) + * [008-binary-too-many-symbolic-links-encountered](spec/minishell/binary/008-binary-too-many-symbolic-links-encountered) + * **[builtins/](spec/minishell/builtins)** + * **[cd/](spec/minishell/builtins/cd)** + * [001-no-arg](spec/minishell/builtins/cd/001-no-arg) + * [002-current-directory](spec/minishell/builtins/cd/002-current-directory) + * [003-current-directory-2](spec/minishell/builtins/cd/003-current-directory-2) + * [004-parent-directory](spec/minishell/builtins/cd/004-parent-directory) + * [005-root-path](spec/minishell/builtins/cd/005-root-path) + * [006-root-path-2](spec/minishell/builtins/cd/006-root-path-2) + * [007-symbolic-link](spec/minishell/builtins/cd/007-symbolic-link) + * [008-symbolic-link-2](spec/minishell/builtins/cd/008-symbolic-link-2) + * [009-following-links ](spec/minishell/builtins/cd/009-following-links) + * [010-update-OLDPWD](spec/minishell/builtins/cd/010-update-OLDPWD) + * [011-dotdot](spec/minishell/builtins/cd/011-dotdot) + * [012-dot](spec/minishell/builtins/cd/012-dot) + * [013-absolute-path](spec/minishell/builtins/cd/013-absolute-path) + * **[errors/](spec/minishell/builtins/cd/errors)** + * [001-not-a-directory](spec/minishell/builtins/cd/errors/001-not-a-directory) + * [002-not-a-directory-2](spec/minishell/builtins/cd/errors/002-not-a-directory-2) + * [003-permission-denied](spec/minishell/builtins/cd/errors/003-permission-denied) + * [004-permission-denied-2](spec/minishell/builtins/cd/errors/004-permission-denied-2) + * [005-too-many-symbolic-links-encountered](spec/minishell/builtins/cd/errors/005-too-many-symbolic-links-encountered) + * [006-too-many-symbolic-links-encountered-2](spec/minishell/builtins/cd/errors/006-too-many-symbolic-links-encountered-2) + * [007-no-such-file-or-directory](spec/minishell/builtins/cd/errors/007-no-such-file-or-directory) + * [008-no-such-file-or-directory-2](spec/minishell/builtins/cd/errors/008-no-such-file-or-directory-2) + * [009-no-such-file-or-directory-symlink](spec/minishell/builtins/cd/errors/009-no-such-file-or-directory-symlink) + * [010-no-such-file-or-directory-symlink-2](spec/minishell/builtins/cd/errors/010-no-such-file-or-directory-symlink-2) + * **[options/](spec/minishell/builtins/cd/options)** + * [001-not-following-links](spec/minishell/builtins/cd/options/001-not-following-links) + * [002-oldpwd](spec/minishell/builtins/cd/options/002-oldpwd) + * **[env/](spec/minishell/builtins/env)** + * [001-env-same-value-as-parent](spec/minishell/builtins/env/001-env-same-value-as-parent) + * [002-env-check-usefull-var](spec/minishell/builtins/env/002-env-check-usefull-var) + * [003-ignore-environment](spec/minishell/builtins/env/003-ignore-environment) + * [005-set-variables](spec/minishell/builtins/env/005-set-variables) + * **[errors/](spec/minishell/builtins/env/errors)** + * [001-command-not-found](spec/minishell/builtins/env/errors/001-command-not-found) + * [002-illegal-option](spec/minishell/builtins/env/errors/002-illegal-option) + * **[multiple-options/](spec/minishell/builtins/env/multiple-options)** + * [001-ignore-environment-and-set-variable](spec/minishell/builtins/env/multiple-options/001-ignore-environment-and-set-variable) + * **[exit/](spec/minishell/builtins/exit)** + * [001-without-any-argument](spec/minishell/builtins/exit/001-without-any-argument) + * [002-status-passed-as-argument](spec/minishell/builtins/exit/002-status-passed-as-argument) + * [003-status-of-last-command](spec/minishell/builtins/exit/003-status-of-last-command) + * **[errors/](spec/minishell/builtins/exit/errors)** + * [001-too-many-args](spec/minishell/builtins/exit/errors/001-too-many-args) + * [002-non-numeric-argument](spec/minishell/builtins/exit/errors/002-non-numeric-argument) + * **[mixed/](spec/minishell/builtins/mixed)** + * [001-setenv-unsetenv](spec/minishell/builtins/mixed/001-setenv-unsetenv) + * **[setenv/](spec/minishell/builtins/setenv)** + * [001-no-argument](spec/minishell/builtins/setenv/001-no-argument) + * [002-add-new-variable](spec/minishell/builtins/setenv/002-add-new-variable) + * [003-set-existing-variable](spec/minishell/builtins/setenv/003-set-existing-variable) + * [004-invalid-identifier](spec/minishell/builtins/setenv/004-invalid-identifier) + * [005-add-and-set-multiple-variables](spec/minishell/builtins/setenv/005-add-and-set-multiple-variables) + * **[unsetenv/](spec/minishell/builtins/unsetenv)** + * [001-unsetenv-first-elem](spec/minishell/builtins/unsetenv/001-unsetenv-first-elem) + * [002-unsetenv-mult-envp](spec/minishell/builtins/unsetenv/002-unsetenv-mult-envp) + * [003-unsetenv-mult-envp-inline](spec/minishell/builtins/unsetenv/003-unsetenv-mult-envp-inline) + * **[misc/](spec/minishell/misc)** + * [001-copy-of-environment](spec/minishell/misc/001-copy-of-environment) + + + +# Development + +## Coding convention + +* Scope indentation must be done with 2 spaces +* Variable names must be upper case (e.g. `INDEX`) +* Global variables must be prefixed with `GLOBAL_` (e.g. `GLOBAL_TOKEN`) +* Variable expansion must be surrounded by curly braces (e.g. `${VARIABLE}`) +* Arguments of functions and commands must be surrounded by double or simple quotes (e.g. `run_assert "STDERR"`) +* Semicolon are banned so that words like `then` and `do` are always at start of lines (e.g. wrong inline code: `if [ ... ]; then cmd; fi`) +* Folder names may only contain alphanumeric and `-` + +## Adding new test + +An integration test must be **self-sufficient**, that means executing the full test suite or only one test must result in the same failed or success status. The framework 42ShellTester brings you tools for that! + +Firstly, tests are executed inside a temporary folder `tmp/` that is created at launch time and placed at the root installation folder of the framework. You may generate temporary files, binaries and folders that are needed for your test, but pay attention to not touch external folders. Use the `before_exec` callback to generate these resources. + +Secondly, each test is executed within a sub-shell, so that you may modify the environment without disrupting the test suite. Use the `before_exec` callback to modify the environment. + +Thirdly, a test must concern one single feature at a time, that means **wherever possible** you must avoid the use of multiple builtins or capabilities (e.g. do not use a pipe `|` within a test that concerns the builtin `env`, or again use absolute paths to binaries like `/bin/ls` to let the Shell implementation not support the `PATH`, except if you precisely test this feature!). + +Fourthly, when a test need binaries like `/bin/env` or `/bin/echo`, prefer to recode your own, simplier and multi-platform, and place it in `support/` folder. Then use the `before_exec` callback to compile it and make it available for your test. + +Sixthly, a test that is not POSIX compliant must contain a file named `non-posix` containing a small explanation of why. + +Finally, don't write a README and let the task `generate_readmes` do it for you :-) A description may be added in a file named `description` that will appear at the top of the README. + +Follow the guideline to add a new test: + +1. Create a sub-folder in `spec/` (e.g. `spec/minishell/builtin/cd/new-test/`) +2. If necessary, create a file `before_exec` that contains the shell commands that prepare the environment and the temporary resources (e.g. `mkdir valid_folder`) +2. Create a file `stdin` that contains the shell command you want to test (e.g. `cd invalid_folder`) +3. Create the files `stdout` and/or `stderr` that contain the expected output assertions (e.g. in stderr: `expected_to_not be_empty`) (see available assertions and verbs bellow) +4. You may also create a file `misc` that contains special expectations not concerning output on standard and error (e.g. `expected_to_not exit_with_status 0`) +5. If necessary, create a file `description` that describes more precisely the purpose of the test (e.g. `Trying to access invalid folder must display an error on standard error and result in a failure status code`) (the description will be included at top of the auto-generated README) +6. If the test is not POSIX compliant, create a file `non-posix` that explains why. + +## Assertions + +* **`expected_to`** / **`expected_to_not`** + *`verb`*: An assertion beginning with **expected_to** (or its opposite **expected_to_not**) makes the test resulting in failure status if the expectation that follows **does not** comply. + +* **`might`** / **`might_not`** + *`verb`*: An assertion beginning with **might** (or its opposite **might_not**) always makes the test resulting in success status. When the expectation that follows **may not** comply, it is nevertheless considered as success but it displays a warning message. + +## Verbs + +* **`be_empty`**: Actual output is empty. +* **`create_file`** + *`$filename`*: Actual command creates a file named *$filename*. May also be followed with a file test: + * **`matching_regex`** + *`$regex`*: At least one line of the file matches with the regular expression *$regex*. + * **`not_matching_regex`** + *`$regex`*: Any line of the file does match with the regular expression *$regex*. + * **`with_nb_of_lines`** + *`$int`*: The file contains exactly *$int* lines. +* **`exit_with_status`** + *`$int`*: The Shell termination results in the exit status *$int*. +* **`have_nb_of_lines`** + *`$int`*: Actual output contains exactly *$int* lines. +* **`match_regex`** + *`$regex`*: At least one line of actual output does match with the regular expression *$regex*. + * **`once`**: The matching is limited to only one occurrence. + * *`$int`* **`times`**: The matching must exactly occur *$int* times. +* **`match_each_regex_of_file`** + *`$filename`*: Actual output does match with each regular expression contained in the file named *$filename* (in an indifferent order). + +## Adding new verb + +A verb is a function that is prefixed by `run_verb_` and that returns `0` or `1` according to the tested behavior. It may return a status `255` when bad or missing argument. + +At runtime, the framework provides a list of variables that can be used by the verbs: + +* **`RESPONSE`**: The path to the file containing actual output (STDOUT or STDERR) +* **`RESPONSE_EXIT_STATUS`**: The exit status of the Shell termination +* **`EXPECTED_TO_ARGS[]`**: An array containing the arguments following the verb + +Follow the guideline to add a new verb: + +1. Choose the best name that respects the *CamelCase* convention and that can be human-readable when used with an assertion (e.g. `expected_to be_empty` can be read `actual output is expected to be empty`) +2. Create a file in `lib/verbs/` with the exact name of the verb and that is prefixed with `run_verb_` (e.g. `lib/verbs/run_verb_be_empty.sh` +3. Add a *shebang*: `#!/bin/sh` and a comment that describes the tested behavior +4. Create a function with the exact name of the verb and that is prefixed with `run_verb_` (the same as the file name) and make it respect the following rules: + * Local variables must be declared with `local` + * No output can be done with `echo` or `printf` + * Function returns `0` on succes, `1` on fail or `255` on bad use + * Use the array `EXPECTED_TO_ARGS[]` to take advantage of arguments (e.g. `expected_to match_regex "regex"`, then `EXPECTED_TO_ARGS[0]` contains `regex`) + +## Support binaries + +The framework 42ShellTester provides several binaries to be used within the tests. Using them instead of using Unix binaries prevents from undefined behaviors and compatibility errors. + +Find the available list of support binaries bellow: + + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)**: A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)**: A binary that delete all files called in argument. +* **[./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". + + + +## Tasks + +* `bash ./tasks/generate_readmes.sh` (only on master branch) to automaticaly generate the README files of tests + +# The Team + +* **Adrien Nouvel** [@anouvel](https://github.com/anouvel) +* **Gabriel Kuma** [@gabkk](https://github.com/gabkk) +* **Jean-Michel Gigault** [@jgigault](https://github.com/jgigault) + +## Logo credits + +Edouard Audeguy +Illustrateur / Infographiste +https://edouardaudeguy.wix.com/portfolio +# 42shelltest-tmp diff --git a/42sh/42shelltest-tmp/lib/assert.sh b/42sh/42shelltest-tmp/lib/assert.sh new file mode 100644 index 00000000..b23d96c4 --- /dev/null +++ b/42sh/42shelltest-tmp/lib/assert.sh @@ -0,0 +1,145 @@ +#!/bin/bash + +# /* +# Assert logic +# +# run_assert +# @param -> prefix applied to output file name +# @param -> output that is tested (STDOUT, STDERR or MISC) +# function that: +# - sets the variable RESPONSE with the path of the file that stores the actual output +# - iterates over the current test configuration file ('stdout', 'stderr' or 'misc') +# - calls the expected type of assertion ('expected', 'might' or their opposite) +# +# run_expected_to +# run_expected_to_not +# run_might +# run_might_to +# @param -> current test (e.g. 'expected_to be_empty') +# functions that calls the verbs and treats their exit status +# */ + +run_assert() +{ + local LINE + local PREFIX_STD="${1}" + local EXPECTED_STD="RESPONSE_${PREFIX_STD}${2}" + local RESPONSE="${!EXPECTED_STD}" + local EXPECTED_STD_NAME="${2}" + local RESPONSE_EXIT_STATUS_VAR="${PREFIX_STD}EXIT_STATUS" + local RESPONSE_EXIT_STATUS="${!RESPONSE_EXIT_STATUS_VAR}" + local TEST_CMD + local OLD_IFS="${IFS}" + local ASSERT_STATUS="0" + local CURRENT_ASSERT_STATUS + local DISPLAY_LINE + + IFS=$'\n' + for LINE in $(awk '{gsub(/\\\\/, "\\\\\\\\\\\\\\\\"); print}' "${TEST}/$(echo "${EXPECTED_STD_NAME}" | awk '{print tolower($0)}')") + do + TEST_CMD="$(echo "${LINE}" | awk '{ print $1 }')" + DISPLAY_LINE="$(printf "${LINE}" | awk -v GLOBAL_TOKEN="${GLOBAL_TOKEN}" -v GLOBAL_INSTALLDIR="${GLOBAL_INSTALLDIR}" -v GLOBAL_TMP_DIRECTORY="${GLOBAL_TMP_DIRECTORY}" -v PATH="${PATH}" -v HOME="${HOME}" '{i=1; while(i <= NF) {gsub(/^"/, "`", $i); gsub(/"$/, "`", $i); i++}; gsub(/\\\\\\\\/, "\\"); gsub(/\$\{GLOBAL_TOKEN\}/, GLOBAL_TOKEN); gsub(/\$\{GLOBAL_INSTALLDIR\}/, GLOBAL_INSTALLDIR); gsub(/\$\{GLOBAL_TMP_DIRECTORY\}/, GLOBAL_TMP_DIRECTORY); gsub(/\$\{PATH\}/, PATH); gsub(/\$\{HOME\}/, HOME); print}')" + eval "run_${TEST_CMD}" ${LINE} + CURRENT_ASSERT_STATUS="${?}" + if [ "${CURRENT_ASSERT_STATUS}" != "0" ] + then + [ "${ASSERT_STATUS}" == "0" -o "${ASSERT_STATUS}" == "2" ] && ASSERT_STATUS="${CURRENT_ASSERT_STATUS}" + fi + done + IFS="${OLD_IFS}" + + return "${ASSERT_STATUS}" +} + +run_expected_to() +{ + shift 1 + local EXPECTED_TO_CMD="${1}" + shift 1 + local -a EXPECTED_TO_ARGS='(${@})' + local ASSERT_STATUS + + eval "run_verb_${EXPECTED_TO_CMD}" + ASSERT_STATUS="${?}" + case "${ASSERT_STATUS}" in + 0) + printf "${C_GREEN} %-10s %s${C_CLEAR}\n" "SUCCESS" "${DISPLAY_LINE}" ;; + 1) + printf "${C_RED} %-10s %s${C_CLEAR}\n" "FAILURE" "${DISPLAY_LINE}" ;; + 255) + printf "${C_RED} [!] INVALID TEST COMMAND: %s${C_CLEAR}\n" "${DISPLAY_LINE}" ;; + esac + + return "${ASSERT_STATUS}" +} + +run_expected_to_not() +{ + shift 1 + local EXPECTED_TO_CMD="${1}" + shift 1 + local -a EXPECTED_TO_ARGS='(${@})' + local ASSERT_STATUS + + eval "run_verb_${EXPECTED_TO_CMD}" + ASSERT_STATUS="${?}" + case "${ASSERT_STATUS}" in + 1) + ASSERT_STATUS="0" + printf "${C_GREEN} %-10s %s${C_CLEAR}\n" "SUCCESS" "${DISPLAY_LINE}" ;; + 0) + ASSERT_STATUS="1" + printf "${C_RED} %-10s %s${C_CLEAR}\n" "FAILURE" "${DISPLAY_LINE}" ;; + 255) + printf "${C_RED} [!] INVALID TEST COMMAND: %s${C_CLEAR}\n" "${DISPLAY_LINE}" ;; + esac + + return "${ASSERT_STATUS}" +} + +run_might() +{ + shift 1 + local EXPECTED_TO_CMD="${1}" + shift 1 + local -a EXPECTED_TO_ARGS='(${@})' + local ASSERT_STATUS + + eval "run_verb_${EXPECTED_TO_CMD}" + ASSERT_STATUS="${?}" + case "${ASSERT_STATUS}" in + 0) + printf "${C_GREEN} %-10s %s${C_CLEAR}\n" "SUCCESS" "${DISPLAY_LINE}" ;; + 1) + ASSERT_STATUS="2" + printf "${C_YELLOW} %-10s %s${C_CLEAR}\n" "WARNING" "${DISPLAY_LINE}" ;; + 255) + printf "${C_RED} [!] INVALID TEST COMMAND: %s${C_CLEAR}\n" "${DISPLAY_LINE}" ;; + esac + + return "${ASSERT_STATUS}" +} + +run_might_not() +{ + shift 1 + local EXPECTED_TO_CMD="${1}" + shift 1 + local -a EXPECTED_TO_ARGS='(${@})' + local ASSERT_STATUS + + eval "run_verb_${EXPECTED_TO_CMD}" + ASSERT_STATUS="${?}" + case "${ASSERT_STATUS}" in + 1) + ASSERT_STATUS="0" + printf "${C_GREEN} %-10s %s${C_CLEAR}\n" "SUCCESS" "${DISPLAY_LINE}" ;; + 0) + ASSERT_STATUS="2" + printf "${C_YELLOW} %-10s %s${C_CLEAR}\n" "WARNING" "${DISPLAY_LINE}" ;; + 255) + printf "${C_RED} [!] INVALID TEST COMMAND: ${EXPECTED_STD_NAME} %s${C_CLEAR}\n" "${DISPLAY_LINE}" ;; + esac + + return "${ASSERT_STATUS}" +} diff --git a/42sh/42shelltest-tmp/lib/assets/42ShellTester.ascii b/42sh/42shelltest-tmp/lib/assets/42ShellTester.ascii new file mode 100644 index 00000000..c74786df --- /dev/null +++ b/42sh/42shelltest-tmp/lib/assets/42ShellTester.ascii @@ -0,0 +1,21 @@ + #### ######## + #### ## #### + #### ##### + ########### ##### # + ########### ######## + #### + ################### #### + ################### + ################### + ################### ##### + ########## ##### + ########## ############ + ########## ############ +# ########## ############ +### ######### ##### +##### ####### ##### +####### ##### ##### +######### ### ##### + #### + ### + ## diff --git a/42sh/42shelltest-tmp/lib/assets/42ShellTester.png b/42sh/42shelltest-tmp/lib/assets/42ShellTester.png new file mode 100644 index 00000000..aa14b009 Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/42ShellTester.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/42ShellTester_250x250.png b/42sh/42shelltest-tmp/lib/assets/42ShellTester_250x250.png new file mode 100644 index 00000000..32114b80 Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/42ShellTester_250x250.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/42ShellTester_416x416.png b/42sh/42shelltest-tmp/lib/assets/42ShellTester_416x416.png new file mode 100644 index 00000000..16b83efc Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/42ShellTester_416x416.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/42ShellTester_cropped.png b/42sh/42shelltest-tmp/lib/assets/42ShellTester_cropped.png new file mode 100644 index 00000000..e633e2aa Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/42ShellTester_cropped.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/42shTestsTeamLogo.png b/42sh/42shelltest-tmp/lib/assets/42shTestsTeamLogo.png new file mode 100644 index 00000000..07609eac Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/42shTestsTeamLogo.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/42shTestsTeamLogo_sm.png b/42sh/42shelltest-tmp/lib/assets/42shTestsTeamLogo_sm.png new file mode 100644 index 00000000..cb25d709 Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/42shTestsTeamLogo_sm.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/README.md b/42sh/42shelltest-tmp/lib/assets/README.md new file mode 100644 index 00000000..2a50a487 --- /dev/null +++ b/42sh/42shelltest-tmp/lib/assets/README.md @@ -0,0 +1,5 @@ +## logo credits + +Edouard Audeguy +Illustrateur / Infographiste +https://edouardaudeguy.wix.com/portfolio diff --git a/42sh/42shelltest-tmp/lib/assets/hard.png b/42sh/42shelltest-tmp/lib/assets/hard.png new file mode 100644 index 00000000..256dd7fd Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/hard.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/non-posix.png b/42sh/42shelltest-tmp/lib/assets/non-posix.png new file mode 100644 index 00000000..5a5fa705 Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/non-posix.png differ diff --git a/42sh/42shelltest-tmp/lib/assets/pending.png b/42sh/42shelltest-tmp/lib/assets/pending.png new file mode 100644 index 00000000..c07a3e7c Binary files /dev/null and b/42sh/42shelltest-tmp/lib/assets/pending.png differ diff --git a/42sh/42shelltest-tmp/lib/main.sh b/42sh/42shelltest-tmp/lib/main.sh new file mode 100644 index 00000000..6a665006 --- /dev/null +++ b/42sh/42shelltest-tmp/lib/main.sh @@ -0,0 +1,280 @@ +#!/bin/bash + +# /* +# Main function +# +# run_main +# function that: +# - iterates over the spec folder +# - executes the tests and their callbacks +# - displays the results +# */ + +run_main() +{ + local TEST + local TEST_NAME + local TEST_FULLNAME + local RESULT + local RESPONSE_STDOUT + local RESPONSE_STDERR + local EXIT_STATUS + local RESPONSE_REFERENCE_STDOUT + local RESPONSE_REFERENCE_STDERR + local REFERENCE_EXIT_STATUS + local RUN_TEST + local RUN_ASSERT + local TEST_STATUS + local ASSERT_STATUS + local LOG_CURRENT_TEST + local LOG_CURRENT_TEST_STDOUT + local LOG_CURRENT_TEST_STDERR + local LOG_CURRENT_TEST_MISC + local LOG_SUCCESS_TESTS + local LOG_FAILED_TESTS + local AWK_PATH="$(which "awk")" + local OLD_IFS="${IFS}" + local UNAME=`uname` + local FIND="find" + + # Use find instead find -E on Linux + if [ {UNAME} == "Darwin" ]; then + FIND= "find -E" + fi + + if [ ! -f "${GLOBAL_PROG}" ] + then + [ "${GLOBAL_PROG}" == "" ] && printf "%s\n" "Missing argument: specify the binary to test" && return + [ ! -f "${GLOBAL_PROG}" -a ! -f "$(which "${GLOBAL_PROG}")" ] && printf "%s\n" "Wrong argument: no such file '"${GLOBAL_PROG}"'" && return + fi + + IFS=$'\n' + for TEST in $(${FIND} "${GLOBAL_INSTALLDIR}/spec" -type d -regex "${GLOBAL_INSTALLDIR}/spec/.*${GLOBAL_SPECS_FILTER}.*") + do + [ -f "${TEST}/pending" -a "${GLOBAL_RUN_PENDING_TESTS}" == "0" ] && (( GLOBAL_TOTAL_PENDING_TESTS = GLOBAL_TOTAL_PENDING_TESTS + 1 )) + if [ -f "${TEST}/stdin" ] && [ ! -f "${TEST}/non-posix" -o "${GLOBAL_RUN_POSIX_ONLY}" == "0" ] && [ ! -f "${TEST}/pending" -o "${GLOBAL_RUN_PENDING_TESTS}" == "1" -o "${GLOBAL_RUN_ALL_TESTS}" == "1" ] && [ ! -f "${TEST}/hard" -o "${GLOBAL_RUN_HARD_TESTS}" == "1" -o "${GLOBAL_RUN_ALL_TESTS}" == "1" ] + then + + # compile support binaries + make -C "${GLOBAL_INSTALLDIR}/support/" TARGET_DIR=${GLOBAL_TMP_DIRECTORY} 1>- 2>- + + TEST_NAME="${TEST##*/}" + TEST_FULLNAME="${TEST##*spec/}" + RUN_TEST=0 + TEST_STATUS="0" + LOG_CURRENT_TEST="${TEST_FULLNAME}" + LOG_CURRENT_TEST_STDOUT="" + LOG_CURRENT_TEST_STDERR="" + LOG_CURRENT_TEST_MISC="" + + RESPONSE_STDOUT="${GLOBAL_TMP_DIRECTORY}/${TEST_FULLNAME//\//-}.stdout" + RESPONSE_STDERR="${GLOBAL_TMP_DIRECTORY}/${TEST_FULLNAME//\//-}.stderr" + RESPONSE_REFERENCE_STDOUT="${GLOBAL_TMP_DIRECTORY}/${TEST_FULLNAME//\//-}.ref.stdout" + RESPONSE_REFERENCE_STDERR="${GLOBAL_TMP_DIRECTORY}/${TEST_FULLNAME//\//-}.ref.stderr" + + rm -f "${GLOBAL_TMP_DIRECTORY}/stdin" + local INDEX=1 + local LINE + local TOTAL=$(awk 'END {print NR+1}' "${TEST}/stdin") + while [ "$INDEX" -le "$TOTAL" ] + do + awk -v INDEX="${INDEX}" -v GLOBAL_TOKEN="${GLOBAL_TOKEN}" -v GLOBAL_INSTALLDIR="${GLOBAL_INSTALLDIR}" -v GLOBAL_TMP_DIRECTORY="${GLOBAL_TMP_DIRECTORY}" -v PATH="${PATH}" -v HOME="${HOME}" 'NR == INDEX {gsub(/\$\{GLOBAL_TOKEN\}/, GLOBAL_TOKEN); gsub(/\$\{GLOBAL_INSTALLDIR\}/, GLOBAL_INSTALLDIR); gsub(/\$\{GLOBAL_TMP_DIRECTORY\}/, GLOBAL_TMP_DIRECTORY); gsub(/\$\{PATH\}/, PATH); gsub(/\$\{HOME\}/, HOME); print; exit}' "${TEST}/stdin" >>"${GLOBAL_TMP_DIRECTORY}/stdin" + + (( INDEX += 1 )) + done + + ( + SUBSHELL_EXIT_STATUS= + + if [ -f "${TEST}/before_exec" ] + then + + local INDEX=0 + local TOTAL=$(${AWK_PATH} 'END {print NR+1}' "${TEST}/before_exec") + while [ "$INDEX" -le "$TOTAL" ] + do + eval $(${AWK_PATH} -v INDEX="${INDEX}" 'NR == INDEX {print $0; exit}' "${TEST}/before_exec") + (( INDEX += 1 )) + done + + fi + + eval "${GLOBAL_PROG}" < "${GLOBAL_TMP_DIRECTORY}/stdin" 1> "${RESPONSE_STDOUT}.raw" 2> "${RESPONSE_STDERR}.raw" + SUBSHELL_EXIT_STATUS=${?} + + if [ -f "${TEST}/after_exec" ] + then + + local INDEX=0 + local TOTAL=$(${AWK_PATH} 'END {print NR+1}' "${TEST}/after_exec") + while [ "$INDEX" -le "$TOTAL" ] + do + eval $(${AWK_PATH} -v INDEX="${INDEX}" 'NR == INDEX {print $0; exit}' "${TEST}/after_exec") + (( INDEX += 1 )) + done + + fi + + exit "${SUBSHELL_EXIT_STATUS}" + ) + EXIT_STATUS=${?} + + awk '{gsub(/\033\[[0-9;]*m/, ""); print}' "${RESPONSE_STDOUT}.raw" > "${RESPONSE_STDOUT}" + awk '{gsub(/\033\[[0-9;]*m/, ""); print}' "${RESPONSE_STDERR}.raw" > "${RESPONSE_STDERR}" + + if [ "${GLOBAL_PROG_REFERENCE}" != "" ] + then + ( + SUBSHELL_EXIT_STATUS= + + if [ -f "${TEST}/before_exec" ] + then + + local INDEX=0 + local TOTAL=$(${AWK_PATH} 'END {print NR+1}' "${TEST}/before_exec") + while [ "$INDEX" -le "$TOTAL" ] + do + eval $(${AWK_PATH} -v INDEX="${INDEX}" 'NR == INDEX {print $0; exit}' "${TEST}/before_exec") + (( INDEX += 1 )) + done + + fi + + eval "${GLOBAL_PROG_REFERENCE}" < "${GLOBAL_TMP_DIRECTORY}/stdin" 1> "${RESPONSE_REFERENCE_STDOUT}.raw" 2> "${RESPONSE_REFERENCE_STDERR}.raw" + SUBSHELL_EXIT_STATUS=${?} + + + if [ -f "${TEST}/after_exec" ] + then + + local INDEX=0 + local TOTAL=$(${AWK_PATH} 'END {print NR+1}' "${TEST}/after_exec") + while [ "$INDEX" -le "$TOTAL" ] + do + eval $(${AWK_PATH} -v INDEX="${INDEX}" 'NR == INDEX {print $0; exit}' "${TEST}/after_exec") + (( INDEX += 1 )) + done + + fi + + exit "${SUBSHELL_EXIT_STATUS}" + ) + REFERENCE_EXIT_STATUS=${?} + + awk '{gsub(/\033\[[0-9;]*m/, ""); print}' "${RESPONSE_REFERENCE_STDOUT}.raw" > "${RESPONSE_REFERENCE_STDOUT}" + awk '{gsub(/\033\[[0-9;]*m/, ""); print}' "${RESPONSE_REFERENCE_STDERR}.raw" > "${RESPONSE_REFERENCE_STDERR}" + fi + + if [ -f "${TEST}/stdout" ] + then + RUN_ASSERT="0" + if [ "${GLOBAL_PROG_REFERENCE}" != "" ] + then + run_assert "REFERENCE_" "STDOUT" 1>- 2>- + RUN_ASSERT="${?}" + fi + if [ "${RUN_ASSERT}" == "0" ] + then + LOG_CURRENT_TEST_STDOUT="$(run_assert "" "STDOUT")" + ASSERT_STATUS="${?}" + if [ "${ASSERT_STATUS}" != "0" ] + then + [ "${TEST_STATUS}" == "0" -o "${TEST_STATUS}" == "2" ] && TEST_STATUS="${ASSERT_STATUS}" + fi + RUN_TEST=1 + fi + fi + + if [ -f "${TEST}/stderr" ] + then + RUN_ASSERT="0" + if [ "${GLOBAL_PROG_REFERENCE}" != "" ] + then + run_assert "REFERENCE_" "STDERR" 1>- 2>- + RUN_ASSERT="${?}" + fi + if [ "${RUN_ASSERT}" == "0" ] + then + LOG_CURRENT_TEST_STDERR="$(run_assert "" "STDERR")" + ASSERT_STATUS="${?}" + if [ "${ASSERT_STATUS}" != "0" ] + then + [ "${TEST_STATUS}" == "0" -o "${TEST_STATUS}" == "2" ] && TEST_STATUS="${ASSERT_STATUS}" + fi + RUN_TEST=1 + fi + fi + + if [ -f "${TEST}/misc" ] + then + RUN_ASSERT="0" + if [ "${GLOBAL_PROG_REFERENCE}" != "" ] + then + run_assert "REFERENCE_" "MISC" 1>- 2>- + RUN_ASSERT="${?}" + fi + if [ "${RUN_ASSERT}" == "0" ] + then + LOG_CURRENT_TEST_MISC="$(run_assert "" "MISC")" + ASSERT_STATUS="${?}" + if [ "${ASSERT_STATUS}" != "0" ] + then + [ "${TEST_STATUS}" == "0" -o "${TEST_STATUS}" == "2" ] && TEST_STATUS="${ASSERT_STATUS}" + fi + RUN_TEST=1 + fi + fi + + + if [ "${RUN_TEST}" == "1" ] + then + (( GLOBAL_TOTAL_TESTS = GLOBAL_TOTAL_TESTS + 1 )) + + if [ "${TEST_STATUS}" != "0" -o "${GLOBAL_SHOW_SUCCESS}" == "1" ] + then + GLOBAL_LOG="$(printf "%s\n\n%s\n\n${C_BOLD}%s${C_CLEAR}" "${GLOBAL_LOG}" "----------------------------------------------------------------" "${LOG_CURRENT_TEST}")" + case "${TEST_STATUS}" in + 0) GLOBAL_LOG="$(printf "%s ${C_GREEN}%s${C_CLEAR}" "${GLOBAL_LOG}" "(SUCCESS)")" ;; + 1) GLOBAL_LOG="$(printf "%s ${C_RED}%s${C_CLEAR}" "${GLOBAL_LOG}" "(FAILED)")" ;; + 2) GLOBAL_LOG="$(printf "%s ${C_YELLOW}%s${C_CLEAR}" "${GLOBAL_LOG}" "(WARNING)")" ;; + 255) GLOBAL_LOG="$(printf "%s ${C_RED}%s${C_CLEAR}" "${GLOBAL_LOG}" "(RUNTIME ERROR)")" ;; + esac + [ -f "${TEST}/description" ] && GLOBAL_LOG="$(printf "%s\n\n Description:\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "$(awk '{printf " %s\n", $0}' "${TEST}/description")")" + + [ -f "${TEST}/before_exec" ] && GLOBAL_LOG="$(printf "%s\n\n Before test:\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "$(awk -v GLOBAL_TOKEN="${GLOBAL_TOKEN}" -v GLOBAL_INSTALLDIR="${GLOBAL_INSTALLDIR}" -v GLOBAL_TMP_DIRECTORY="${GLOBAL_TMP_DIRECTORY}" -v PATH="${PATH}" -v HOME="${HOME}" '{gsub(/\$\{GLOBAL_TOKEN\}/, GLOBAL_TOKEN); gsub(/\$\{GLOBAL_INSTALLDIR\}/, GLOBAL_INSTALLDIR); gsub(/\$\{GLOBAL_TMP_DIRECTORY\}/, GLOBAL_TMP_DIRECTORY); gsub(/\$\{PATH\}/, PATH); gsub(/\$\{HOME\}/, HOME); printf " %02s: %s\n", NR, $0}' "${TEST}/before_exec")")" + + GLOBAL_LOG="$(printf " %s\n\n STDIN:\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "$(awk '{printf " %02s: %s\n", NR, $0}' "${GLOBAL_TMP_DIRECTORY}/stdin")")" + + if [ "${LOG_CURRENT_TEST_STDOUT}" != "" ] + then + GLOBAL_LOG="$(printf "%s\n\n STDOUT:\n%s\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "${LOG_CURRENT_TEST_STDOUT}" "$(awk '{printf " %02s: %s\n", NR, $0} END {if (NR==0) { print " (no output)" }}' "${RESPONSE_STDOUT}")")" + else + GLOBAL_LOG="$(printf "%s\n\n STDOUT:\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "$(awk '{printf " %02s: %s\n", NR, $0} END {if (NR==0) { print " (no output)" }}' "${RESPONSE_STDOUT}")")" + fi + + if [ "${LOG_CURRENT_TEST_STDERR}" != "" ] + then + GLOBAL_LOG="$(printf "%s\n\n STDERR:\n%s\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "${LOG_CURRENT_TEST_STDERR}" "$(awk '{printf " %02s: %s\n", NR, $0} END {if (NR==0) { print " (no output)" }}' "${RESPONSE_STDERR}")")" + else + GLOBAL_LOG="$(printf "%s\n\n STDERR:\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "$(awk '{printf " %02s: %s\n", NR, $0} END {if (NR==0) { print " (no output)" }}' "${RESPONSE_STDERR}")")" + fi + + [ "${LOG_CURRENT_TEST_MISC}" != "" ] && GLOBAL_LOG="$(printf "%s\n\n MISC:\n%s" "${GLOBAL_LOG}" "${LOG_CURRENT_TEST_MISC}")" + + [ -f "${TEST}/after_exec" ] && GLOBAL_LOG="$(printf "%s\n\n After test:\n${C_GREY}%s${C_CLEAR}" "${GLOBAL_LOG}" "$(awk -v GLOBAL_TOKEN="${GLOBAL_TOKEN}" -v GLOBAL_INSTALLDIR="${GLOBAL_INSTALLDIR}" -v GLOBAL_TMP_DIRECTORY="${GLOBAL_TMP_DIRECTORY}" -v PATH="${PATH}" -v HOME="${HOME}" '{gsub(/\$\{GLOBAL_TOKEN\}/, GLOBAL_TOKEN); gsub(/\$\{GLOBAL_INSTALLDIR\}/, GLOBAL_INSTALLDIR); gsub(/\$\{GLOBAL_TMP_DIRECTORY\}/, GLOBAL_TMP_DIRECTORY); gsub(/\$\{PATH\}/, PATH); gsub(/\$\{HOME\}/, HOME); printf " %02s: %s\n", NR, $0}' "${TEST}/after_exec")")" + + [ "${TEST_STATUS}" == "1" ] && (( GLOBAL_TOTAL_FAILED_TESTS = GLOBAL_TOTAL_FAILED_TESTS + 1 )) + fi + + case "${TEST_STATUS}" in + 0) printf "${C_GREEN}.${C_CLEAR}" ;; + 1) printf "${C_RED}x${C_CLEAR}" ;; + 2) printf "${C_YELLOW}~${C_CLEAR}" ;; + 255) printf "${C_RED}!${C_CLEAR}" ;; + esac + fi + + fi + done + IFS="${OLD_IFS}" +} diff --git a/42sh/42shelltest-tmp/lib/verbs/be_empty.sh b/42sh/42shelltest-tmp/lib/verbs/be_empty.sh new file mode 100644 index 00000000..81d091ef --- /dev/null +++ b/42sh/42shelltest-tmp/lib/verbs/be_empty.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# /* +# Test emptiness of output +# RESPONSE -> actual output (stdout or stderr) +# */ + +run_verb_be_empty() +{ + if [ "$(awk '{print}' "${RESPONSE}")" == "" ] + then + return 0 + else + return 1 + fi +} diff --git a/42sh/42shelltest-tmp/lib/verbs/create_file.sh b/42sh/42shelltest-tmp/lib/verbs/create_file.sh new file mode 100644 index 00000000..127e3eaa --- /dev/null +++ b/42sh/42shelltest-tmp/lib/verbs/create_file.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# /* +# Test file creation +# EXPECTED_TO_ARGS[0]* -> expected file path +# EXPECTED_TO_ARGS[1] -> file test (with_regexp, without_regexp, with_nb_of_lines) +# EXPECTED_TO_ARGS[2] -> argument of file test +# */ + +run_verb_create_file() +{ + if [ -f "${EXPECTED_TO_ARGS[0]}" ] + then + if [ "${EXPECTED_TO_ARGS[1]}" == "" ] + then + return 0 + else + case "${EXPECTED_TO_ARGS[1]}" in + matching_regex) + if [ "$(awk -v regexp="${EXPECTED_TO_ARGS[2]}" '$0 ~ regexp {print}' "${EXPECTED_TO_ARGS[0]}")" == "" ] + then + return 1 + else + return 0 + fi ;; + not_matching_regex) + if [ "$(awk -v regexp="${EXPECTED_TO_ARGS[2]}" '$0 ~ regexp {print}' "${EXPECTED_TO_ARGS[0]}")" == "" ] + then + return 0 + else + return 1 + fi ;; + with_nb_of_lines) + if [ "$(awk 'END {print NR}' "${EXPECTED_TO_ARGS[0]}")" == "${EXPECTED_TO_ARGS[2]}" ] + then + return 0 + else + return 1 + fi ;; + *) + return 255 ;; + esac + fi + else + return 1 + fi +} diff --git a/42sh/42shelltest-tmp/lib/verbs/exit_with_status.sh b/42sh/42shelltest-tmp/lib/verbs/exit_with_status.sh new file mode 100644 index 00000000..062e17f1 --- /dev/null +++ b/42sh/42shelltest-tmp/lib/verbs/exit_with_status.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# /* +# Test exit status +# EXPECTED_TO_ARGS[0]* -> expected exit status (integer) +# RESPONSE_EXIT_STATUS -> actual exit status +# */ + +run_verb_exit_with_status() +{ + if [ "${RESPONSE_EXIT_STATUS}" == "${EXPECTED_TO_ARGS[0]}" ] + then + return 0 + else + return 1 + fi +} diff --git a/42sh/42shelltest-tmp/lib/verbs/have_nb_of_lines.sh b/42sh/42shelltest-tmp/lib/verbs/have_nb_of_lines.sh new file mode 100644 index 00000000..b7571838 --- /dev/null +++ b/42sh/42shelltest-tmp/lib/verbs/have_nb_of_lines.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# /* +# Test number of output lines +# EXPECTED_TO_ARGS[0]* -> expected number of lines (integer) +# RESPONSE -> actual output (stdout or stderr) +# */ + +run_verb_have_nb_of_lines() +{ + if [ "$(awk 'END {printf NR}' "${RESPONSE}")" == "${EXPECTED_TO_ARGS[0]}" ] + then + return 0 + else + return 1 + fi +} diff --git a/42sh/42shelltest-tmp/lib/verbs/match_each_regex_of_file.sh b/42sh/42shelltest-tmp/lib/verbs/match_each_regex_of_file.sh new file mode 100644 index 00000000..17569d4a --- /dev/null +++ b/42sh/42shelltest-tmp/lib/verbs/match_each_regex_of_file.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# /* +# Multiple test regular expression +# EXPECTED_TO_ARGS[0]* -> file path that stores expected regular expression +# RESPONSE -> actual output (stdout or stderr) +# */ + +run_verb_match_each_regex_of_file() +{ + local INDEX=0 ERROR=0 TOTAL LINE + TOTAL=$(awk 'END {print NR+1}' "${EXPECTED_TO_ARGS[0]}") + while [ "${INDEX}" -le "${TOTAL}" ] + do + LINE="$(awk -v INDEX="${INDEX}" 'NR == INDEX {print; exit}' "${EXPECTED_TO_ARGS[0]}")" + if [ "$(awk -v regexp="${LINE}" '$0 ~ regexp {print}' "${RESPONSE}")" == "" ] + then + ERROR=1 + fi + (( INDEX += 1 )) + done + if [ ${ERROR} -eq 1 ] + then + return 1 + else + return 0 + fi +} diff --git a/42sh/42shelltest-tmp/lib/verbs/match_regex.sh b/42sh/42shelltest-tmp/lib/verbs/match_regex.sh new file mode 100644 index 00000000..2c9e8b92 --- /dev/null +++ b/42sh/42shelltest-tmp/lib/verbs/match_regex.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# /* +# Test regular expression +# EXPECTED_TO_ARGS[0]* -> expected regular expression match +# EXPECTED_TO_ARGS[1]* -> value 'once' or if next argument is value 'times', the number of times +# RESPONSE -> actual output (stdout or stderr) +# */ + +run_verb_match_regex() +{ + local NB_OF_TIMES="0" RESULT + if [ "${EXPECTED_TO_ARGS[1]}" == "once" ] + then + NB_OF_TIMES="1" + fi + if [ "${EXPECTED_TO_ARGS[2]}" == "times" ] + then + NB_OF_TIMES="${EXPECTED_TO_ARGS[1]}" + fi + RESULT="$(awk -v regexp="${EXPECTED_TO_ARGS[0]}" 'BEGIN {TOTAL=0} $0 ~ regexp {TOTAL++} END {printf TOTAL}' "${RESPONSE}")" + if [ "${NB_OF_TIMES}" == "0" ] + then + if [ "${RESULT}" != "0" ] + then + return 0 + else + return 1 + fi + else + if [ "${RESULT}" == "${NB_OF_TIMES}" ] + then + return 0 + else + return 1 + fi + fi +} diff --git a/42sh/42shelltest-tmp/log b/42sh/42shelltest-tmp/log new file mode 100644 index 00000000..a0683387 --- /dev/null +++ b/42sh/42shelltest-tmp/log @@ -0,0 +1,3075 @@ +.x..........................xx....x.xxxxxxxxxx~~xxx.xxx......xx......xxxxxxxxxx.......xxxxxxxxxxxxxxx.xx~xx..x~..x..x..xxxx.xx.xxx.x......xxxx.xxxx.....x..x...........xxxx..................................xx..x...xxx...~x.........~~..xxxxxxxx...x.x.~......xx....~.~.~.........xxxxx...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 "TOKEN201703172323" + 03: echo '^'$(echo TOKEN201703172323_FILE_TOKEN201703172323_STDOUT | wc -c)'$' > "./size" + + STDIN: + 01: mkdir TOKEN201703172323 ; cd TOKEN201703172323 ; touch TOKEN201703172323_FILE ; ls -1 ; ls | cat | wc -c > TOKEN201703172323_STDOUT ; cat TOKEN201703172323_STDOUT + + STDOUT: + SUCCESS expected_to match_regex `TOKEN201703172323_FILE$` + FAILURE expected_to match_each_regex_of_file `./size` + 01: TOKEN201703172323_FILE + 02: 23 + + 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 TOKEN201703172323_1 TOKEN201703172323_2 &>new_file_stderr_and_stdout + + STDOUT: + FAILURE expected_to_not match_regex `TOKEN201703172323_1` + SUCCESS expected_to_not match_regex `TOKEN201703172323_2` + 01: TOKEN201703172323_1 + + STDERR: + SUCCESS expected_to_not match_regex `TOKEN201703172323_1` + FAILURE expected_to_not match_regex `TOKEN201703172323_2` + 01: TOKEN201703172323_2 + + MISC: + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703172323_1$` + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703172323_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 TOKEN201703172323_1 TOKEN201703172323_2 &> new_file_stderr_and_stdout + + STDOUT: + FAILURE expected_to_not match_regex `TOKEN201703172323_1` + SUCCESS expected_to_not match_regex `TOKEN201703172323_2` + 01: TOKEN201703172323_1 + + STDERR: + SUCCESS expected_to_not match_regex `TOKEN201703172323_1` + FAILURE expected_to_not match_regex `TOKEN201703172323_2` + 01: TOKEN201703172323_2 + + MISC: + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703172323_1$` + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703172323_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 TOKEN201703172323 ; ; ./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` + +---------------------------------------------------------------- + +42sh/builtins/export/001-display-env (FAILED) + + Description: + The purpose of this test is to check that using the builtin `export` without parameters results at least in a display of the environment variables. + + Before test: + 01: rm -rf "./stored_env" + 02: env | awk 'BEGIN {FS="="} $0 !~ /^(OLDPWD|_)/ {print $1"="}' > "./stored_env" + + STDIN: + 01: export + + STDOUT: + FAILURE expected_to match_each_regex_of_file `./stored_env` + (no output) + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/builtins/export/002-export-basic-key-value-1 (FAILED) + + Description: + The purpose of this test is to check that the builtin `export` may declare a new environment variable. + + Before test: + 01: unset "TOKEN201703172323_NAME" + + STDIN: + 01: export TOKEN201703172323_NAME=TOKEN201703172323_VALUE + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE$` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: ./lib/main.sh: line 102: 66973 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + +---------------------------------------------------------------- + +42sh/builtins/export/003-export-basic-key-value-2 (FAILED) + + Description: + The purpose of this test is to check that the builtin `export` may declare a new environment variable and is able to display it later. + + Before test: + 01: unset "TOKEN201703172323_NAME" + + STDIN: + 01: export TOKEN201703172323_NAME=TOKEN201703172323_VALUE + 02: export + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323_NAME=["]?TOKEN201703172323_VALUE["]?$` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: ./lib/main.sh: line 102: 67097 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + +---------------------------------------------------------------- + +42sh/builtins/export/004-export-empty-variable-1 (FAILED) + + Description: + The purpose of this test is to check that exporting an empty variable does not add it to the environment. + + Before test: + 01: unset "TOKEN201703172323" + + STDIN: + 01: export TOKEN201703172323 + 02: ./display_env + + STDOUT: + FAILURE expected_to_not match_regex `TOKEN201703172323` + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 08: TERM_PROGRAM_VERSION=3.0.10 + 09: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 10: ZSH=/Users/ariard/.oh-my-zsh + 11: USER=ariard + 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 14: PAGER=less + 15: TMUX=/private/tmp/tmux-18965/default,83855,1 + 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 17: LSCOLORS=Gxfxcxdxbxegedabagacad + 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 19: MAIL=ariard@student.42.fr + 20: PWD=/Users/ariard/42shelltest-tmp/tmp + 21: LANG=en_US.UTF-8 + 22: ITERM_PROFILE=Default + 23: XPC_FLAGS=0x0 + 24: TMUX_PANE=%8 + 25: XPC_SERVICE_NAME=0 + 26: SHLVL=4 + 27: HOME=/Users/ariard + 28: COLORFGBG=7;0 + 29: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 30: LOGNAME=ariard + 31: LESS=-R + 32: LC_CTYPE=en_US.UTF-8 + 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 34: OLDPWD=/Users/ariard/42shelltest-tmp + 35: _=/Users/ariard/Projects/42sh/42sh + 36: ?=0 + 37: TOKEN201703172323= + 38: ------------------------------ + 39: TOTAL ENVIRONMENT VARIABLES: 36 + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/builtins/export/005-export-empty-variable-2 (FAILED) + + Description: + The purpose of this test is to check that exporting an empty variable does not add it to the environment, but can be displayed with the builtin `export`. + + Before test: + 01: unset "TOKEN201703172323" + + STDIN: + 01: export TOKEN201703172323 + 02: export + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323` + (no output) + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/builtins/export/006-export-update-env-variable (FAILED) + + Description: + The purpose of this test is to check that exporting the same variable twice in a row does result in an updated variable, but not in a duplicated variable. + + Before test: + 01: unset "TOKEN201703172323_NAME" + + STDIN: + 01: export TOKEN201703172323_NAME=TOKEN201703172323_VALUE1 + 02: export TOKEN201703172323_NAME=TOKEN201703172323_VALUE2 + 03: ./display_env + + STDOUT: + SUCCESS expected_to_not match_regex `TOKEN201703172323_NAME=TOKEN201703172323_VALUE1` + FAILURE expected_to match_regex `TOKEN201703172323_NAME=TOKEN201703172323_VALUE2` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: ./lib/main.sh: line 102: 67471 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + +---------------------------------------------------------------- + +42sh/builtins/export/007-existing-environment-variable (FAILED) + + Description: + The purpose of this test is to check that exporting an existing variable results in an updated variable. + + Before test: + 01: export "TOKEN201703172323_NAME=TOKEN201703172323_VALUE1" + + STDIN: + 01: export TOKEN201703172323_NAME=TOKEN201703172323_VALUE2 + 02: ./display_env + + STDOUT: + SUCCESS expected_to_not match_regex `TOKEN201703172323_NAME=TOKEN201703172323_VALUE1` + FAILURE expected_to match_regex `TOKEN201703172323_NAME=TOKEN201703172323_VALUE2` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: ./lib/main.sh: line 102: 67610 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + +---------------------------------------------------------------- + +42sh/builtins/export/008-local-to-environment (FAILED) + + Description: + The purpose of this test is to check that a declared local variable may be exported to the environment with the builtin `export`. + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_VALUE + 02: export TOKEN201703172323_NAME + 03: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE$` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: ./lib/main.sh: line 102: 67739 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + +---------------------------------------------------------------- + +42sh/builtins/export/009-export-with-equal-but-no-value-part1 (FAILED) + + Description: + The purpose of this test is to check if the builtin export works fine with equal sign but no value. This test is based on the environment variables return. + + Before test: + 01: unset "TOKEN201703172323" + + STDIN: + 01: export TOKEN201703172323_NAME= + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: ./lib/main.sh: line 102: 67860 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + +---------------------------------------------------------------- + +42sh/builtins/export/010-export-with-equal-but-no-value-part2 (FAILED) + + Description: + The purpose of this test is to check if the builtin export works fine with equal sign but no value. This test is based on the local variables return. + + Before test: + 01: unset "TOKEN201703172323" + + STDIN: + 01: export TOKEN201703172323_NAME= + 02: export + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323_NAME=` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: ./lib/main.sh: line 102: 67984 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + +---------------------------------------------------------------- + +42sh/builtins/export/errors/001-invalid-identifier-1 (WARNING) + + Description: + The purpose of this test is to check that trying to export an invalid variable identifier results in error. + + STDIN: + 01: export 42=TOKEN201703172323 + + STDOUT: + SUCCESS expected_to_not match_regex `TOKEN201703172323` + (no output) + + STDERR: + SUCCESS expected_to_not be_empty + WARNING might match_regex `(not.*identifier|must begin.*letter)` + 01: ./lib/main.sh: line 102: 68103 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + + MISC: + SUCCESS expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +42sh/builtins/export/errors/002-invalid-identifier-2 (WARNING) + + Description: + The purpose of this test is to check that trying to export an invalid variable identifier results in error. + + STDIN: + 01: export .=TOKEN201703172323 + + STDOUT: + SUCCESS expected_to_not match_regex `TOKEN201703172323` + (no output) + + STDERR: + SUCCESS expected_to_not be_empty + WARNING might match_regex `(not.*identifier|must begin.*letter)` + 01: ./lib/main.sh: line 102: 68240 Segmentation fault: 11 /Users/ariard/Projects/42sh/42sh + + MISC: + SUCCESS expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +42sh/builtins/export/errors/003-illegal-option (FAILED) + + Description: + The purpose of this test is to check that using the builtin `export` with an illegal option results in an error and a failure exit status. + + STDIN: + 01: export -w + + STDOUT: + (no output) + + STDERR: + SUCCESS expected_to_not be_empty + SUCCESS might match_regex `([Ii]nvalid|[Ii]llegal) (option|argument)` + 01: /Users/ariard/Projects/42sh/42sh: invalid option -w + + MISC: + FAILURE expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +42sh/builtins/export/mixed/001-export-and-tmp-env-part1 (FAILED) + + Description: + The purpose of this test is to check that modifying the environment for the builtin `export` results in an added variable into the exported list. + + Before test: + 01: unset "TOKEN201703172323_NAME" + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_VALUE export TOKEN201703172323_NAME + 02: export + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323_NAME=["]?TOKEN201703172323_VALUE["]?` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: TOKEN201703172323_NAME=TOKEN201703172323_VALUE + +---------------------------------------------------------------- + +42sh/builtins/export/mixed/002-export-and-tmp-env-part2 (FAILED) + + Description: + The purpose of this test is to check that modifying the environment for the builtin `export` results in an added environment variable. + + Before test: + 01: unset "TOKEN201703172323_NAME" + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_VALUE export TOKEN201703172323_NAME + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323_NAME=TOKEN201703172323_VALUE` + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 08: TERM_PROGRAM_VERSION=3.0.10 + 09: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 10: ZSH=/Users/ariard/.oh-my-zsh + 11: USER=ariard + 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 14: PAGER=less + 15: TMUX=/private/tmp/tmux-18965/default,83855,1 + 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 17: LSCOLORS=Gxfxcxdxbxegedabagacad + 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 19: MAIL=ariard@student.42.fr + 20: PWD=/Users/ariard/42shelltest-tmp/tmp + 21: LANG=en_US.UTF-8 + 22: ITERM_PROFILE=Default + 23: XPC_FLAGS=0x0 + 24: TMUX_PANE=%8 + 25: XPC_SERVICE_NAME=0 + 26: SHLVL=4 + 27: HOME=/Users/ariard + 28: COLORFGBG=7;0 + 29: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 30: LOGNAME=ariard + 31: LESS=-R + 32: LC_CTYPE=en_US.UTF-8 + 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 34: OLDPWD=/Users/ariard/42shelltest-tmp + 35: _=/Users/ariard/Projects/42sh/42sh + 36: ?=127 + 37: ------------------------------ + 38: TOTAL ENVIRONMENT VARIABLES: 35 + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: TOKEN201703172323_NAME=TOKEN201703172323_VALUE + +---------------------------------------------------------------- + +42sh/builtins/export/options/002-export-p-param-and-token-should-add-local-var-only-part1 (FAILED) + + Description: + The purpose of this test is to check if export with -p option + token , add the variable into export list but not in env list. And don't display the export variable on stdout. + + Before test: + 01: rm -f "./stored_env" + 02: unset "TOKEN201703172323_NAME" + 03: export | awk 'BEGIN {FS="="} $0 !~ /^(OLDPWD|_)/ {print $1"="}' > "./stored_env" + + STDIN: + 01: export -p TOKEN201703172323_NAME + 02: export + + STDOUT: + FAILURE expected_to_not match_each_regex_of_file `./stored_env` + FAILURE expected_to match_regex `TOKEN201703172323_NAME` + 01: export TERM_PROGRAM=iTerm.app + 02: export TERM=screen-256color + 03: export SHELL=/bin/zsh + 04: export HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 05: export TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 06: export Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 07: export TERM_PROGRAM_VERSION=3.0.10 + 08: export TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 09: export ZSH=/Users/ariard/.oh-my-zsh + 10: export USER=ariard + 11: export SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 12: export __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 13: export PAGER=less + 14: export TMUX=/private/tmp/tmux-18965/default,83855,1 + 15: export HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 16: export LSCOLORS=Gxfxcxdxbxegedabagacad + 17: export PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 18: export MAIL=ariard@student.42.fr + 19: export PWD=/Users/ariard/42shelltest-tmp/tmp + 20: export LANG=en_US.UTF-8 + 21: export ITERM_PROFILE=Default + 22: export XPC_FLAGS=0x0 + 23: export TMUX_PANE=%8 + 24: export XPC_SERVICE_NAME=0 + 25: export SHLVL=4 + 26: export HOME=/Users/ariard + 27: export COLORFGBG=7;0 + 28: export ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 29: export LOGNAME=ariard + 30: export LESS=-R + 31: export LC_CTYPE=en_US.UTF-8 + 32: export TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 33: export OLDPWD=/Users/ariard/42shelltest-tmp + 34: export _=/Users/ariard/Projects/42sh/42sh + 35: export ?=0 + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/builtins/export/options/003-export-p-param-and-token-should-add-local-var-only-part2 (FAILED) + + Description: + The purpose of this test is to check that the builtin `export` with option `-p` results in an added variable into the export list but not from the environment. + + Before test: + 01: rm -f "./stored_env" + 02: unset "TOKEN201703172323_NAME" + 03: export | awk 'BEGIN {FS="="} $0 !~ /^(OLDPWD|_)/ {print $1"="}' > "./stored_env" + + STDIN: + 01: export -p TOKEN201703172323_NAME + 02: ./display_env + + STDOUT: + FAILURE expected_to_not match_each_regex_of_file `./stored_env` + SUCCESS expected_to_not match_regex `TOKEN201703172323_NAME` + 01: export TERM_PROGRAM=iTerm.app + 02: export TERM=screen-256color + 03: export SHELL=/bin/zsh + 04: export HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 05: export TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 06: export Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 07: export TERM_PROGRAM_VERSION=3.0.10 + 08: export TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 09: export ZSH=/Users/ariard/.oh-my-zsh + 10: export USER=ariard + 11: export SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 12: export __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 13: export PAGER=less + 14: export TMUX=/private/tmp/tmux-18965/default,83855,1 + 15: export HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 16: export LSCOLORS=Gxfxcxdxbxegedabagacad + 17: export PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 18: export MAIL=ariard@student.42.fr + 19: export PWD=/Users/ariard/42shelltest-tmp/tmp + 20: export LANG=en_US.UTF-8 + 21: export ITERM_PROFILE=Default + 22: export XPC_FLAGS=0x0 + 23: export TMUX_PANE=%8 + 24: export XPC_SERVICE_NAME=0 + 25: export SHLVL=4 + 26: export HOME=/Users/ariard + 27: export COLORFGBG=7;0 + 28: export ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 29: export LOGNAME=ariard + 30: export LESS=-R + 31: export LC_CTYPE=en_US.UTF-8 + 32: export TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 33: export OLDPWD=/Users/ariard/42shelltest-tmp + 34: export _=/Users/ariard/Projects/42sh/42sh + 35: export ?=0 + 36: ------------------------------ + 37: TERM_PROGRAM=iTerm.app + 38: TERM=screen-256color + 39: SHELL=/bin/zsh + 40: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 41: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 42: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 43: TERM_PROGRAM_VERSION=3.0.10 + 44: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 45: ZSH=/Users/ariard/.oh-my-zsh + 46: USER=ariard + 47: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 48: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 49: PAGER=less + 50: TMUX=/private/tmp/tmux-18965/default,83855,1 + 51: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 52: LSCOLORS=Gxfxcxdxbxegedabagacad + 53: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 54: MAIL=ariard@student.42.fr + 55: PWD=/Users/ariard/42shelltest-tmp/tmp + 56: LANG=en_US.UTF-8 + 57: ITERM_PROFILE=Default + 58: XPC_FLAGS=0x0 + 59: TMUX_PANE=%8 + 60: XPC_SERVICE_NAME=0 + 61: SHLVL=4 + 62: HOME=/Users/ariard + 63: COLORFGBG=7;0 + 64: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 65: LOGNAME=ariard + 66: LESS=-R + 67: LC_CTYPE=en_US.UTF-8 + 68: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 69: OLDPWD=/Users/ariard/42shelltest-tmp + 70: _=/Users/ariard/Projects/42sh/42sh + 71: ?=0 + 72: ------------------------------ + 73: TOTAL ENVIRONMENT VARIABLES: 35 + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/builtins/export/options/004-export-n-param (FAILED) + + Description: + The purpose of this test is to check that using the builtin `export` with option `-n` results in a removed environment variable. + + Before test: + 01: export TOKEN201703172323_NAME=TOKEN201703172323_VALUE + + STDIN: + 01: export -n TOKEN201703172323_NAME + 02: export + 03: ./display_env + + STDOUT: + FAILURE expected_to_not match_regex `TOKEN201703172323_NAME` + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TOKEN201703172323_NAME= + 07: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 09: TERM_PROGRAM_VERSION=3.0.10 + 10: OLDPWD=/Users/ariard/42shelltest-tmp + 11: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 12: ZSH=/Users/ariard/.oh-my-zsh + 13: USER=ariard + 14: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 15: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 16: PAGER=less + 17: TMUX=/private/tmp/tmux-18965/default,83855,1 + 18: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 19: LSCOLORS=Gxfxcxdxbxegedabagacad + 20: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 21: MAIL=ariard@student.42.fr + 22: PWD=/Users/ariard/42shelltest-tmp/tmp + 23: LANG=en_US.UTF-8 + 24: ITERM_PROFILE=Default + 25: XPC_FLAGS=0x0 + 26: TMUX_PANE=%8 + 27: XPC_SERVICE_NAME=0 + 28: SHLVL=4 + 29: HOME=/Users/ariard + 30: COLORFGBG=7;0 + 31: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 32: LOGNAME=ariard + 33: LESS=-R + 34: LC_CTYPE=en_US.UTF-8 + 35: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 36: _=/Users/ariard/Projects/42sh/42sh + 37: ?=0 + 38: ------------------------------ + 39: TOTAL ENVIRONMENT VARIABLES: 36 + + STDERR: + FAILURE expected_to be_empty + 01: /Users/ariard/Projects/42sh/42sh: invalid option -n + +---------------------------------------------------------------- + +42sh/escaping/mixed/globbing/brace-expansion/002-it-expands-braces-1 (FAILED) + + Description: + The purpose of this test is to check that using multiple escape characters `\\` results in a good behavior with the brace expansion. + + STDIN: + 01: ./write_all_arguments_on_stdout \\{1..2} + + STDOUT: + FAILURE expected_to match_regex `^\1@\2@$` + 01: \{1..2}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/escaping/mixed/globbing/brace-expansion/003-it-expands-braces-2 (FAILED) + + Description: + The purpose of this test is to check that using multiple escape characters `\\` results in a good behavior with the brace expansion. + + STDIN: + 01: ./write_all_arguments_on_stdout \\\{1..2} \\\\{1..2} \\\\\{1..2} \\\\\\{1..2} + + STDOUT: + FAILURE expected_to match_regex `^\[{]1..2}@\\1@\\2@\\[{]1..2}@\\\1@\\\2@$` + 01: \{1..2}@\\{1..2}@\\{1..2}@\\\{1..2}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/001-simple-ascending-1 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with an ASCII range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {a..e} + + STDOUT: + FAILURE expected_to match_regex `^a@b@c@d@e@$` + 01: {a..e}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/002-simple-ascending-2 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with an ASCII range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{a..e}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323aTOKEN201703172323@TOKEN201703172323bTOKEN201703172323@TOKEN201703172323cTOKEN201703172323@TOKEN201703172323dTOKEN201703172323@TOKEN201703172323eTOKEN201703172323@$` + 01: TOKEN201703172323{a..e}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/003-simple-ascending-3 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with an ASCII range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {A..E} + + STDOUT: + FAILURE expected_to match_regex `^A@B@C@D@E@$` + 01: {A..E}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/004-simple-descending-1 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with an ASCII range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {E..A} + + STDOUT: + FAILURE expected_to match_regex `^E@D@C@B@A@$` + 01: {E..A}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/005-simple-descending-2 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with an ASCII range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{E..A}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323ETOKEN201703172323@TOKEN201703172323DTOKEN201703172323@TOKEN201703172323CTOKEN201703172323@TOKEN201703172323BTOKEN201703172323@TOKEN201703172323ATOKEN201703172323@$` + 01: TOKEN201703172323{E..A}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/006-simple-descending-3 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with an ASCII range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{e..a} + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323e@TOKEN201703172323d@TOKEN201703172323c@TOKEN201703172323b@TOKEN201703172323a@$` + 01: TOKEN201703172323{e..a}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/007-identical-start-and-end (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a range of single ASCII value. + + STDIN: + 01: ./write_all_arguments_on_stdout {f..f} + + STDOUT: + FAILURE expected_to match_regex `^f@$` + 01: {f..f}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/008-multiple-1 (FAILED) + + Description: + The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. + + STDIN: + 01: ./write_all_arguments_on_stdout {a..b}{c..d}{e..f} + + STDOUT: + FAILURE expected_to match_regex `^ace@acf@ade@adf@bce@bcf@bde@bdf@$` + 01: {a..b}{c..d}{e..f}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/009-multiple-2 (FAILED) + + Description: + The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{a..b}abc{Z..X}def{s..s} + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323aabcZdefs@TOKEN201703172323aabcYdefs@TOKEN201703172323aabcXdefs@TOKEN201703172323babcZdefs@TOKEN201703172323babcYdefs@TOKEN201703172323babcXdefs@$` + 01: TOKEN201703172323{a..b}abc{Z..X}def{s..s}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/ascii-range/010-big-range (FAILED) + + Description: + The purpose of this test is to check that brace expansion may be performed with a big numeric range. + + STDIN: + 01: ./write_all_arguments_on_stdout {A..z} + + STDOUT: + FAILURE expected_to match_regex `^A@B@C@D@E@F@G@H@I@J@K@L@M@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@.+@.?@.+@.+@_@.+@a@b@c@d@e@f@g@h@i@j@k@l@m@n@o@p@q@r@s@t@u@v@w@x@y@z@$` + 01: {A..z}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/001-simple-ascending-1 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {1..5} + + STDOUT: + FAILURE expected_to match_regex `^1@2@3@4@5@$` + 01: {1..5}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/002-simple-ascending-2 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{1..5}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^TOKEN2017031723231TOKEN201703172323@TOKEN2017031723232TOKEN201703172323@TOKEN2017031723233TOKEN201703172323@TOKEN2017031723234TOKEN201703172323@TOKEN2017031723235TOKEN201703172323@$` + 01: TOKEN201703172323{1..5}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/003-simple-ascending-3 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{1..+5} + + STDOUT: + FAILURE expected_to match_regex `^TOKEN2017031723231@TOKEN2017031723232@TOKEN2017031723233@TOKEN2017031723234@TOKEN2017031723235@$` + 01: TOKEN201703172323{1..+5}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/004-simple-ascending-4 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {-5..0}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^-5TOKEN201703172323@-4TOKEN201703172323@-3TOKEN201703172323@-2TOKEN201703172323@-1TOKEN201703172323@0TOKEN201703172323@$` + 01: {-5..0}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/005-simple-ascending-5 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {-100..-98}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^-100TOKEN201703172323@-99TOKEN201703172323@-98TOKEN201703172323@$` + 01: {-100..-98}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/006-simple-descending-1 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {5..1} + + STDOUT: + FAILURE expected_to match_regex `^5@4@3@2@1@$` + 01: {5..1}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/007-simple-descending-2 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{5..1}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^TOKEN2017031723235TOKEN201703172323@TOKEN2017031723234TOKEN201703172323@TOKEN2017031723233TOKEN201703172323@TOKEN2017031723232TOKEN201703172323@TOKEN2017031723231TOKEN201703172323@$` + 01: TOKEN201703172323{5..1}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/008-simple-descending-3 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{5..+1} + + STDOUT: + FAILURE expected_to match_regex `^TOKEN2017031723235@TOKEN2017031723234@TOKEN2017031723233@TOKEN2017031723232@TOKEN2017031723231@$` + 01: TOKEN201703172323{5..+1}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/009-simple-descending-4 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {0..-5}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^0TOKEN201703172323@-1TOKEN201703172323@-2TOKEN201703172323@-3TOKEN201703172323@-4TOKEN201703172323@-5TOKEN201703172323@$` + 01: {0..-5}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/010-simple-descending-5 (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. + + STDIN: + 01: ./write_all_arguments_on_stdout {-98..-100}TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^-98TOKEN201703172323@-99TOKEN201703172323@-100TOKEN201703172323@$` + 01: {-98..-100}TOKEN201703172323@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/011-identical-positive-start-and-end (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a range of single value. + + STDIN: + 01: ./write_all_arguments_on_stdout {42..42} + + STDOUT: + FAILURE expected_to match_regex `^42@$` + 01: {42..42}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/012-identical-negative-start-and-end (FAILED) + + Description: + The purpose of this test is to check that the brace expansion does work with a range of single value. + + STDIN: + 01: ./write_all_arguments_on_stdout {-42..-42} + + STDOUT: + FAILURE expected_to match_regex `^-42@$` + 01: {-42..-42}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/013-multiple-1 (FAILED) + + Description: + The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. + + STDIN: + 01: ./write_all_arguments_on_stdout {1..2}{3..4}{5..6} + + STDOUT: + FAILURE expected_to match_regex `^135@136@145@146@235@236@245@246@$` + 01: {1..2}{3..4}{5..6}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/014-multiple-2 (FAILED) + + Description: + The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. + + STDIN: + 01: ./write_all_arguments_on_stdout TOKEN201703172323{1..2}abc{-50..-53}def{0..0} + + STDOUT: + FAILURE expected_to match_regex `^TOKEN2017031723231abc-50def0@TOKEN2017031723231abc-51def0@TOKEN2017031723231abc-52def0@TOKEN2017031723231abc-53def0@TOKEN2017031723232abc-50def0@TOKEN2017031723232abc-51def0@TOKEN2017031723232abc-52def0@TOKEN2017031723232abc-53def0@$` + 01: TOKEN201703172323{1..2}abc{-50..-53}def{0..0}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/brace-expansion/numeric-range/015-big-range (FAILED) + + Description: + The purpose of this test is to check that brace expansion may be performed with a big numeric range. + + STDIN: + 01: ./write_all_arguments_on_stdout {-100..100} + + STDOUT: + FAILURE expected_to match_regex `^-100@-99@-98@-97@-96@-95@-94@-93@-92@-91@-90@-89@-88@-87@-86@-85@-84@-83@-82@-81@-80@-79@-78@-77@-76@-75@-74@-73@-72@-71@-70@-69@-68@-67@-66@-65@-64@-63@-62@-61@-60@-59@-58@-57@-56@-55@-54@-53@-52@-51@-50@-49@-48@-47@-46@-45@-44@-43@-42@-41@-40@-39@-38@-37@-36@-35@-34@-33@-32@-31@-30@-29@-28@-27@-26@-25@-24@-23@-22@-21@-20@-19@-18@-17@-16@-15@-14@-13@-12@-11@-10@-9@-8@-7@-6@-5@-4@-3@-2@-1@0@1@2@3@4@5@6@7@8@9@10@11@12@13@14@15@16@17@18@19@20@21@22@23@24@25@26@27@28@29@30@31@32@33@34@35@36@37@38@39@40@41@42@43@44@45@46@47@48@49@50@51@52@53@54@55@56@57@58@59@60@61@62@63@64@65@66@67@68@69@70@71@72@73@74@75@76@77@78@79@80@81@82@83@84@85@86@87@88@89@90@91@92@93@94@95@96@97@98@99@100@$` + 01: {-100..100}@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/multi/002-reverse-range-and-chars (FAILED) + + Description: + The purpose of this test is to check that brackets expansion works with 2 patterns. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch 'a4' 'a3' 'a2' 'a42' 'a[42]' 'z4' 'z3' 'z2' 'z42' 'z[42]' '42' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [!a-y][42] + 02: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [^a-y][42] + + STDOUT: + SUCCESS expected_to match_regex `42@` + SUCCESS expected_to match_regex `z4@` + SUCCESS expected_to match_regex `z2@` + SUCCESS expected_to_not match_regex `z3@` + SUCCESS expected_to_not match_regex `z42@` + SUCCESS expected_to_not match_regex `z[[]42]@` + SUCCESS expected_to_not match_regex `a3@` + SUCCESS expected_to_not match_regex `a42@` + SUCCESS expected_to_not match_regex `a[[]42]@` + SUCCESS might match_regex `^42@z2@z4@$` + 01: 42@z2@z4@ + + STDERR: + FAILURE expected_to be_empty + 01: syntax error near unexpected token `!' + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/multi/003-reverse-multi-hard (FAILED) + + Description: + The purpose of this test is to check how the value inside multiple brackets are parsed with bracket as pattern. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch '][' 'a[' '1[' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [!]az][[] + 02: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [^]az][[] + + STDOUT: + FAILURE expected_to match_regex `1[[]@` + SUCCESS expected_to_not match_regex `][[]@` + SUCCESS expected_to_not match_regex `a[[]@` + WARNING might match_regex `^1[[]@$` + 01: [^]az][[]@ + + STDERR: + FAILURE expected_to be_empty + 01: syntax error near unexpected token `!' + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/multi/004-simple-bracket+char+range (WARNING) + + Description: + The purpose of this test is to control if 2 patterns splited by a minus characters can be match. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch 'a-0' 'a-1' 'a-2' 'b-0' 'b-1' 'b-2' 'Z-0' 'Z-1' 'Z-2' 'a1' 'Z9' 'D4' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [aZ]-[1-9] + + STDOUT: + SUCCESS expected_to match_regex `a-1@` + SUCCESS expected_to match_regex `a-2@` + SUCCESS expected_to match_regex `Z-1@` + SUCCESS expected_to match_regex `Z-2@` + SUCCESS expected_to_not match_regex `a-0@` + SUCCESS expected_to_not match_regex `b-0@` + SUCCESS expected_to_not match_regex `b-1@` + SUCCESS expected_to_not match_regex `b-2@` + SUCCESS expected_to_not match_regex `a1@` + SUCCESS expected_to_not match_regex `Z9@` + SUCCESS expected_to_not match_regex `D4@` + WARNING might match_regex `^Z-1@Z-2@a-1@a-2@$` + 01: a-1@a-2@Z-1@Z-2@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/not/001-simple-opposit-match (FAILED) + + Description: + The purpose of this test is to check that the brackets expansion works with the inversion mark `!` or `^`. The expected behavior is the reversion of the following pattern. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch 'a' '1' 'Z' 'd' 'e' 'f' 'def' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [!a1Z] + 02: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [^a1Z] + + STDOUT: + SUCCESS expected_to match_regex `d@` + SUCCESS expected_to match_regex `e@` + SUCCESS expected_to match_regex `f@` + SUCCESS expected_to_not match_regex `def@` + SUCCESS might match_regex `^d@e@f@$` + 01: d@e@f@ + + STDERR: + FAILURE expected_to be_empty + 01: syntax error near unexpected token `!' + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/not/002-simple-opposite-range (FAILED) + + Description: + The purpose of this test is to check that the brackets expansion works with the inversion mark `!` or `^`. The expected behavior is the reversion of the following pattern. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch 'a' 'b' 'c' 'z' '1' '2' '3' '42' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [!a-z] + 02: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [^a-z] + + STDOUT: + SUCCESS expected_to match_regex `1@` + SUCCESS expected_to match_regex `2@` + SUCCESS expected_to match_regex `3@` + SUCCESS expected_to_not match_regex `42@` + SUCCESS might match_regex `^1@2@3@$` + 01: 1@2@3@ + + STDERR: + FAILURE expected_to be_empty + 01: syntax error near unexpected token `!' + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/range-pattern/003-ascii-range-1 (FAILED) + + Description: + The purpose of this test is to check if the bracket expansion works with the following pattern []-z]. + One test use the following range which is the default range for bash: + < > , ; : ! ' " ( ) [ ] { } @ $ \ # % 1 2 3 4 5 6 7 8 9 a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z + The other use the ascii value, which does make more sense. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch '2' 'a' 'B' 'c' 'Z' '[' ']' '[]-z]' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout []-z] + + STDOUT: + FAILURE expected_to match_regex `a@` + FAILURE expected_to match_regex `c@` + SUCCESS expected_to match_regex `]@` + SUCCESS expected_to_not match_regex `2@` + SUCCESS expected_to_not match_regex `B@` + SUCCESS expected_to_not match_regex `Z@` + SUCCESS expected_to_not match_regex `[[]@` + FAILURE expected_to_not match_regex `[[]]-z]@` + WARNING might match_regex `^]@a@c@$` + 01: []-z]@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/range-pattern/004-ascii-range-2 (WARNING) + + Description: + The purpose of this test is to check that the brackets expansion works with the following pattern `[1-z]`. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch '2' 'a' 'B' 'c' 'Z' ']' '[' '[1-z]' '1-z' '-' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [1-z] + + STDOUT: + SUCCESS expected_to match_regex `2@` + SUCCESS expected_to match_regex `a@` + SUCCESS expected_to match_regex `B@` + SUCCESS expected_to match_regex `c@` + SUCCESS expected_to match_regex `Z@` + SUCCESS expected_to match_regex `]@` + SUCCESS expected_to match_regex `[[]@` + SUCCESS expected_to_not match_regex `-@` + SUCCESS expected_to_not match_regex `1-z@` + SUCCESS expected_to_not match_regex `[[]1-z]@` + WARNING might match_regex `^2@B@Z@[[]@]@a@c@$` + 01: 2@[@]@a@B@c@Z@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/simple-pattern/003-brackets-as-pattern (FAILED) + + Description: + The purpose of this test is to check that the brackets expansion works with an opening bracket `[` and a closing bracket `]` as pattern. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch '[' ']' 'a' 'Z' '[][]' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout [][] + + STDOUT: + FAILURE expected_to match_regex `[[]@` + SUCCESS expected_to match_regex `]@` + SUCCESS expected_to_not match_regex `a@` + SUCCESS expected_to_not match_regex `Z@` + FAILURE expected_to_not match_regex `[[]][[]]@` + WARNING might match_regex `^[[]@]@$` + 01: [][]@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/globbing/bracket-expansion/single-char-pattern/002-closing-bracket-char (FAILED) + + Description: + The purpose of this test is to check that the brackets expansion works with a closing bracket `]` as pattern. + + Before test: + 01: rm -rf "./test_globbing" + 02: mkdir "./test_globbing" + 03: cd "./test_globbing" + 04: touch ']' '[]]' + + STDIN: + 01: /Users/ariard/42shelltest-tmp/tmp/write_all_arguments_on_stdout []] + + STDOUT: + SUCCESS expected_to match_regex `]@` + FAILURE expected_to_not match_regex `[[]]]@` + WARNING might match_regex `^]@$` + 01: []]@ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/local-variable/002-declare-and-expand-2 (FAILED) + + Description: + The purpose of this test is to check that an empty variable is not expanded as an empty string and results in any new argument in the command line. + + STDIN: + 01: TOKEN201703172323_NAME= + 02: ./write_on_stdout_and_stderr $TOKEN201703172323_NAME $TOKEN201703172323_NAME + + STDOUT: + FAILURE expected_to match_regex `write on stdout` + 01:  + + STDERR: + FAILURE expected_to match_regex `write on stderr` + 01:  + +---------------------------------------------------------------- + +42sh/local-variable/003-unknown-variable-does-not-result-in-new-argument (FAILED) + + Description: + The purpose of this test is to check that an unknown variable is not expanded as an empty string and results in any new argument in the command line. + + Before test: + 01: unset "TOKEN201703172323_UNKNOWN" + + STDIN: + 01: ./write_on_stdout $TOKEN201703172323_UNKNOWN TOKEN201703172323_DISPLAYED + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323_DISPLAYED` + 01: write on stdout + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/local-variable/004-existing-variable-in-environment-1 (FAILED) + + Description: + The purpose of this test is initialize a local variable named as an environment variable and check if it's update the existing environment variable. + + Before test: + 01: export "TOKEN201703172323_NAME=TOKEN201703172323_VALUE_OLD" + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_VALUE_NEW + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE_NEW$` + FAILURE expected_to_not match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE_OLD$` + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TOKEN201703172323_NAME=TOKEN201703172323_VALUE_OLD + 07: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 09: TERM_PROGRAM_VERSION=3.0.10 + 10: OLDPWD=/Users/ariard/42shelltest-tmp + 11: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 12: ZSH=/Users/ariard/.oh-my-zsh + 13: USER=ariard + 14: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 15: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 16: PAGER=less + 17: TMUX=/private/tmp/tmux-18965/default,83855,1 + 18: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 19: LSCOLORS=Gxfxcxdxbxegedabagacad + 20: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 21: MAIL=ariard@student.42.fr + 22: PWD=/Users/ariard/42shelltest-tmp/tmp + 23: LANG=en_US.UTF-8 + 24: ITERM_PROFILE=Default + 25: XPC_FLAGS=0x0 + 26: TMUX_PANE=%8 + 27: XPC_SERVICE_NAME=0 + 28: SHLVL=4 + 29: HOME=/Users/ariard + 30: COLORFGBG=7;0 + 31: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 32: LOGNAME=ariard + 33: LESS=-R + 34: LC_CTYPE=en_US.UTF-8 + 35: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 36: _=/Users/ariard/Projects/42sh/42sh + 37: ?=0 + 38: ------------------------------ + 39: TOTAL ENVIRONMENT VARIABLES: 36 + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/local-variable/005-existing-variable-in-environment-2 (FAILED) + + Description: + The purpose of this test is initialize a local variable named as an environment variable and check if it's update the existing environment variable. + + Before test: + 01: export "TOKEN201703172323_NAME=TOKEN201703172323_VALUE" + + STDIN: + 01: TOKEN201703172323_NAME= + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=$` + FAILURE expected_to_not match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE$` + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TOKEN201703172323_NAME=TOKEN201703172323_VALUE + 07: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 09: TERM_PROGRAM_VERSION=3.0.10 + 10: OLDPWD=/Users/ariard/42shelltest-tmp + 11: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 12: ZSH=/Users/ariard/.oh-my-zsh + 13: USER=ariard + 14: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 15: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 16: PAGER=less + 17: TMUX=/private/tmp/tmux-18965/default,83855,1 + 18: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 19: LSCOLORS=Gxfxcxdxbxegedabagacad + 20: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 21: MAIL=ariard@student.42.fr + 22: PWD=/Users/ariard/42shelltest-tmp/tmp + 23: LANG=en_US.UTF-8 + 24: ITERM_PROFILE=Default + 25: XPC_FLAGS=0x0 + 26: TMUX_PANE=%8 + 27: XPC_SERVICE_NAME=0 + 28: SHLVL=4 + 29: HOME=/Users/ariard + 30: COLORFGBG=7;0 + 31: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 32: LOGNAME=ariard + 33: LESS=-R + 34: LC_CTYPE=en_US.UTF-8 + 35: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 36: _=/Users/ariard/Projects/42sh/42sh + 37: ?=0 + 38: ------------------------------ + 39: TOTAL ENVIRONMENT VARIABLES: 36 + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/local-variable/007-multiple-declaration-at-a-time (FAILED) + + Description: + The purpose of this test is to check that declaring multiple variables in the same command line does work. + + STDIN: + 01: TOKEN201703172323_NAME1=TOKEN201703172323_VALUE1 TOKEN201703172323_NAME2=TOKEN201703172323_VALUE2 TOKEN201703172323_NAME3=TOKEN201703172323_VALUE3 + 02: ./write_on_stdout_and_stderr $TOKEN201703172323_NAME1 $TOKEN201703172323_NAME1 + 03: ./write_on_stdout $TOKEN201703172323_NAME2 + 04: ./write_on_stderr $TOKEN201703172323_NAME3 + + STDOUT: + SUCCESS expected_to match_regex `^TOKEN201703172323_VALUE1$` + FAILURE expected_to match_regex `^TOKEN201703172323_VALUE2$` + SUCCESS expected_to_not match_regex `^TOKEN201703172323_VALUE3$` + 01: TOKEN201703172323_VALUE1 + 02:  + + STDERR: + SUCCESS expected_to match_regex `^TOKEN201703172323_VALUE1$` + SUCCESS expected_to_not match_regex `^TOKEN201703172323_VALUE2$` + FAILURE expected_to match_regex `^TOKEN201703172323_VALUE3$` + 01: TOKEN201703172323_VALUE1 + 02:  + +---------------------------------------------------------------- + +42sh/local-variable/008-multiple-declaration-with-same-name (FAILED) + + Description: + The purpose of this test is to check that declaring the same variable several times in the same command line does work and does not result in error. + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_VALUE1 TOKEN201703172323_NAME=TOKEN201703172323_VALUE2 TOKEN201703172323_NAME=TOKEN201703172323_VALUE3 + 02: ./write_on_stdout $TOKEN201703172323_NAME + + STDOUT: + FAILURE expected_to_not match_regex `^TOKEN201703172323_VALUE1$` + SUCCESS expected_to_not match_regex `^TOKEN201703172323_VALUE2$` + FAILURE expected_to match_regex `^TOKEN201703172323_VALUE3$` + 01: TOKEN201703172323_VALUE1 + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/local-variable/mixed/inline-environment-variable/001-local-variable-shouldnt-be-set (FAILED) + + Description: + The purpose of this test is to check that declaring a variable and specifying a binary does not result in local variable declaration but a modified environment for the command. + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_VALUE ./display_env + 02: ./write_on_stderr $TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE$` + (no output) + + STDERR: + FAILURE expected_to_not match_regex `TOKEN201703172323_VALUE` + FAILURE expected_to match_regex `write on stderr` + 01: minishell: command not found: TOKEN201703172323_NAME=TOKEN201703172323_VALUE + 02:  + +---------------------------------------------------------------- + +42sh/local-variable/mixed/redirections/001-truncating (FAILED) + + Description: + The purpose of this test is to check that a redirection can be set with a local variable as file name. + + Before test: + 01: rm -f "TOKEN201703172323_FILENAME" + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_FILENAME + 02: ./write_on_stdout TOKEN201703172323_VALUE > $TOKEN201703172323_NAME + + STDOUT: + SUCCESS expected_to be_empty + (no output) + + STDERR: + SUCCESS expected_to be_empty + (no output) + + MISC: + FAILURE expected_to create_file `TOKEN201703172323_FILENAME` matching_regex `^TOKEN201703172323_VALUE$` + SUCCESS expected_to exit_with_status `0` + +---------------------------------------------------------------- + +42sh/local-variable/mixed/redirections/002-appending (FAILED) + + Description: + The purpose of this test is to check that a redirection can be set with a local variable as file name. + + Before test: + 01: rm -f "TOKEN201703172323_FILENAME" + + STDIN: + 01: TOKEN201703172323_NAME=TOKEN201703172323_FILENAME + 02: ./write_on_stdout TOKEN201703172323_VALUE1 >> $TOKEN201703172323_NAME + 03: ./write_on_stdout TOKEN201703172323_VALUE2 >> $TOKEN201703172323_NAME + + STDOUT: + SUCCESS expected_to be_empty + (no output) + + STDERR: + SUCCESS expected_to be_empty + (no output) + + MISC: + FAILURE expected_to create_file `TOKEN201703172323_FILENAME` matching_regex `^TOKEN201703172323_VALUE1$` + FAILURE expected_to create_file `TOKEN201703172323_FILENAME` matching_regex `^TOKEN201703172323_VALUE2$` + SUCCESS expected_to exit_with_status `0` + +---------------------------------------------------------------- + +42sh/local-variable/mixed/tilde-expansion/001-process-tilde-expansion (FAILED) + + Description: + The purpose of this test is to check that the tilde expansion `~` in variable declaration. + + Before test: + 01: export "HOME=/TOKEN201703172323" + + STDIN: + 01: TOKEN201703172323=~ + 02: ./write_on_stdout TILDE:$TOKEN201703172323 + + STDOUT: + FAILURE expected_to_not match_regex `TILDE:~` + WARNING might match_regex `TILDE:/TOKEN201703172323` + 01: TILDE:~ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/escaping/002-escape-double-quote-2 (FAILED) + + Description: + The purpose of this test is to check that a double-quote `"` may be preserved when it is preceded by a backslash `\\`. + + STDIN: + 01: ./write_on_stdout "TOKEN201703172323 \" TOKEN201703172323" + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323 ` TOKEN201703172323$` + (no output) + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/escaping/003-escape-double-quote-3 (FAILED) + + Description: + The purpose of this test is to check that a double-quote `"` may be preserved when it is preceded by a backslash `\\`. + + STDIN: + 01: ./write_on_stdout "\"" + + STDOUT: + FAILURE expected_to match_regex `^"$` + (no output) + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/escaping/004-it-results-in-error (FAILED) + + Description: + The purpose of this test is to check that using backslash `\\` before the closing double-quote `"` does result in syntax error. + + STDIN: + 01: ./write_on_stdout "TOKEN201703172323\" + + STDOUT: + SUCCESS expected_to_not match_regex `^TOKEN201703172323$` + 01: TOKEN201703172323\ + + STDERR: + FAILURE expected_to_not be_empty + WARNING might match_regex `([Ss]yntax|[Pp]arse) error` + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/escaping/005-it-does-not-escape-double-quote (FAILED) + + Description: + The purpose of this test is to check that using two backslashes `\\` before the symbol double-quote `"` does not result in escaped inhibitors. + + STDIN: + 01: ./write_on_stdout \\"TOKEN201703172323\\" + + STDOUT: + FAILURE expected_to match_regex `^\TOKEN201703172323\$` + 01: \TOKEN201703172323\\ + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/globbing/brace-expansion/002-it-does-not-expand-braces-2 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout {1..2}"{1..2}" + + STDOUT: + FAILURE expected_to match_regex `1[{]1..2}@2[{]1..2}@` + 01: {1..2}{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/globbing/brace-expansion/003-it-does-not-expand-braces-3 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout "{1..2}"{1..2} + + STDOUT: + FAILURE expected_to match_regex `[{]1..2}1@[{]1..2}2@` + 01: {1..2}{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/globbing/brace-expansion/004-it-does-not-expand-braces-4 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout "{1..2}"{1..2}"{1..2}"{1..2}"{1..2}"{1..2} + + STDOUT: + FAILURE expected_to match_regex `[{]1..2}1[{]1..2}1[{]1..2}1@[{]1..2}1[{]1..2}1[{]1..2}2@[{]1..2}1[{]1..2}2[{]1..2}1@[{]1..2}1[{]1..2}2[{]1..2}2@[{]1..2}2[{]1..2}1[{]1..2}1@[{]1..2}2[{]1..2}1[{]1..2}2@[{]1..2}2[{]1..2}2[{]1..2}1@[{]1..2}2[{]1..2}2[{]1..2}2@` + 01: {1..2}{1..2}{1..2}{1..2}{1..2}{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/double-quotes/mixed/globbing/brace-expansion/005-it-does-not-expand-braces-5 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout "{1..2}" {1..2} "{1..2}" "{1..2}" + + STDOUT: + FAILURE expected_to match_regex `[{]1..2}@1@2@[{]1..2}@[{]1..2}@` + 01: {1..2}@{1..2}@{1..2}@{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/mixed/globbing/brace-expansion/001-it-does-not-expand-braces-1 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout "{1..2}"{1..2}'{1..2}'{1..2}"{1..2}"{1..2} + + STDOUT: + FAILURE expected_to match_regex `[{]1..2}1[{]1..2}1[{]1..2}1@[{]1..2}1[{]1..2}1[{]1..2}2@[{]1..2}1[{]1..2}2[{]1..2}1@[{]1..2}1[{]1..2}2[{]1..2}2@[{]1..2}2[{]1..2}1[{]1..2}1@[{]1..2}2[{]1..2}1[{]1..2}2@[{]1..2}2[{]1..2}2[{]1..2}1@[{]1..2}2[{]1..2}2[{]1..2}2@` + 01: {1..2}{1..2}{1..2}{1..2}{1..2}{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/mixed/variable-expansion/001-it-does-not-expand-in-quotes (FAILED) + + Description: + The purpose of this test is to check if a local variable is display correctly inside simple and double quote. + + Before test: + 01: export "TOKEN201703172323_NAME=TOKEN201703172323_VALUE" + + STDIN: + 01: ./write_on_stdout "$TOKEN201703172323_NAME"$TOKEN201703172323_NAME'$TOKEN201703172323_NAME' + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323_VALUETOKEN201703172323_VALUE[$]TOKEN201703172323_NAME` + 01: TOKEN201703172323_VALUEE$TOKEN201703172323_NAME + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/002-it-does-not-expand-braces-2 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout {1..2}'{1..2}' + + STDOUT: + FAILURE expected_to match_regex `1[{]1..2}@2[{]1..2}@` + 01: {1..2}{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/003-it-does-not-expand-braces-3 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout '{1..2}'{1..2} + + STDOUT: + FAILURE expected_to match_regex `[{]1..2}1@[{]1..2}2@` + 01: {1..2}{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/004-it-does-not-expand-braces-4 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout '{1..2}'{1..2}'{1..2}'{1..2}'{1..2}'{1..2} + + STDOUT: + FAILURE expected_to match_regex `[{]1..2}1[{]1..2}1[{]1..2}1@[{]1..2}1[{]1..2}1[{]1..2}2@[{]1..2}1[{]1..2}2[{]1..2}1@[{]1..2}1[{]1..2}2[{]1..2}2@[{]1..2}2[{]1..2}1[{]1..2}1@[{]1..2}2[{]1..2}1[{]1..2}2@[{]1..2}2[{]1..2}2[{]1..2}1@[{]1..2}2[{]1..2}2[{]1..2}2@` + 01: {1..2}{1..2}{1..2}{1..2}{1..2}{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/005-it-does-not-expand-braces-5 (FAILED) + + Description: + The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. + + STDIN: + 01: ./write_all_arguments_on_stdout '{1..2}' {1..2} '{1..2}' '{1..2}' + + STDOUT: + FAILURE expected_to match_regex `[{]1..2}@1@2@[{]1..2}@[{]1..2}@` + 01: {1..2}@{1..2}@{1..2}@{1..2}@ + + STDERR: + (no output) + +---------------------------------------------------------------- + +42sh/subshell/mixed/inline-environment-variable/001-modifies-the-child-environment-only-1 (FAILED) + + Description: + The purpose of this test is to check that declaring a variable and specifying a binary in a subshell does not result in local variable declaration or a modified parent shell's environment, but only a modified child's environment. + + STDIN: + 01: (TOKEN201703172323_NAME=TOKEN201703172323_VALUE ./display_env) + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE$` once + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 08: TERM_PROGRAM_VERSION=3.0.10 + 09: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 10: ZSH=/Users/ariard/.oh-my-zsh + 11: USER=ariard + 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 14: PAGER=less + 15: TMUX=/private/tmp/tmux-18965/default,83855,1 + 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 17: LSCOLORS=Gxfxcxdxbxegedabagacad + 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 19: MAIL=ariard@student.42.fr + 20: PWD=/Users/ariard/42shelltest-tmp/tmp + 21: LANG=en_US.UTF-8 + 22: ITERM_PROFILE=Default + 23: XPC_FLAGS=0x0 + 24: TMUX_PANE=%8 + 25: XPC_SERVICE_NAME=0 + 26: SHLVL=4 + 27: HOME=/Users/ariard + 28: COLORFGBG=7;0 + 29: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 30: LOGNAME=ariard + 31: LESS=-R + 32: LC_CTYPE=en_US.UTF-8 + 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 34: OLDPWD=/Users/ariard/42shelltest-tmp + 35: _=/Users/ariard/Projects/42sh/42sh + 36: ?=127 + 37: ------------------------------ + 38: TOTAL ENVIRONMENT VARIABLES: 35 + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: TOKEN201703172323_NAME=TOKEN201703172323_VALUE + +---------------------------------------------------------------- + +42sh/subshell/mixed/inline-environment-variable/002-modifies-the-child-environment-only-2 (FAILED) + + Description: + The purpose of this test is to check that declaring a variable and specifying a binary in a subshell does not result in local variable declaration or a modified parent shell's environment, but only a modified child's environment. + + STDIN: + 01: ( (TOKEN201703172323_NAME=TOKEN201703172323_VALUE ./display_env) ; ./display_env) ; ./display_env + 02:  + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_NAME=TOKEN201703172323_VALUE$` once + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 08: TERM_PROGRAM_VERSION=3.0.10 + 09: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 10: ZSH=/Users/ariard/.oh-my-zsh + 11: USER=ariard + 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 14: PAGER=less + 15: TMUX=/private/tmp/tmux-18965/default,83855,1 + 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 17: LSCOLORS=Gxfxcxdxbxegedabagacad + 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 19: MAIL=ariard@student.42.fr + 20: PWD=/Users/ariard/42shelltest-tmp/tmp + 21: LANG=en_US.UTF-8 + 22: ITERM_PROFILE=Default + 23: XPC_FLAGS=0x0 + 24: TMUX_PANE=%8 + 25: XPC_SERVICE_NAME=0 + 26: SHLVL=4 + 27: HOME=/Users/ariard + 28: COLORFGBG=7;0 + 29: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 30: LOGNAME=ariard + 31: LESS=-R + 32: LC_CTYPE=en_US.UTF-8 + 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 34: OLDPWD=/Users/ariard/42shelltest-tmp + 35: _=/Users/ariard/Projects/42sh/42sh + 36: ?=127 + 37: ------------------------------ + 38: TOTAL ENVIRONMENT VARIABLES: 35 + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: TOKEN201703172323_NAME=TOKEN201703172323_VALUE + +---------------------------------------------------------------- + +42sh/subshell/mixed/piping/003-imbricated-subshells-and-pipes (FAILED) + + Description: + The purpose of this test is to check that pipes and subshells run twice together in harmony. + + STDIN: + 01: ( ( (cd / ; /Users/ariard/42shelltest-tmp/tmp/display_pwd) | ./read_on_stdin) ) | ( ( (./read_on_stdin) ) | ./read_on_stdin ) + 02: ./write_on_stdout TOKEN201703172323 + + STDOUT: + SUCCESS expected_to_not match_regex `/Users/ariard/42shelltest-tmp/tmp` + FAILURE expected_to match_regex `^PWD:/:PWD@@@$` + SUCCESS expected_to match_regex `TOKEN201703172323` + 01: TOKEN201703172323 + + STDERR: + FAILURE expected_to be_empty + 01: Broken pipe + +---------------------------------------------------------------- + +bonuses/inline-environment-variable/001-modifies-child-environment-1 (FAILED) + + Description: + The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. + + Before test: + 01: unset "TOKEN201703172323_VARIABLE" + + STDIN: + 01: TOKEN201703172323_VARIABLE=TOKEN201703172323_VALUE ./display_env + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_VARIABLE=TOKEN201703172323_VALUE$` once + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 08: TERM_PROGRAM_VERSION=3.0.10 + 09: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 10: ZSH=/Users/ariard/.oh-my-zsh + 11: USER=ariard + 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 14: PAGER=less + 15: TMUX=/private/tmp/tmux-18965/default,83855,1 + 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 17: LSCOLORS=Gxfxcxdxbxegedabagacad + 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 19: MAIL=ariard@student.42.fr + 20: PWD=/Users/ariard/42shelltest-tmp/tmp + 21: LANG=en_US.UTF-8 + 22: ITERM_PROFILE=Default + 23: XPC_FLAGS=0x0 + 24: TMUX_PANE=%8 + 25: XPC_SERVICE_NAME=0 + 26: SHLVL=4 + 27: HOME=/Users/ariard + 28: COLORFGBG=7;0 + 29: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 30: LOGNAME=ariard + 31: LESS=-R + 32: LC_CTYPE=en_US.UTF-8 + 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 34: OLDPWD=/Users/ariard/42shelltest-tmp + 35: _=/Users/ariard/Projects/42sh/42sh + 36: ?=127 + 37: ------------------------------ + 38: TOTAL ENVIRONMENT VARIABLES: 35 + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: TOKEN201703172323_VARIABLE=TOKEN201703172323_VALUE + +---------------------------------------------------------------- + +bonuses/inline-environment-variable/002-modifies-child-environment-2 (FAILED) + + Description: + The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. + + Before test: + 01: unset "TOKEN201703172323_VARIABLE" + + STDIN: + 01: TOKEN201703172323_VARIABLE1=TOKEN201703172323_VALUE1 TOKEN201703172323_VARIABLE2=TOKEN201703172323_VALUE2 TOKEN201703172323_VARIABLE3=TOKEN201703172323_VALUE3 ./display_env + 02: ./display_env + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323_VARIABLE1=TOKEN201703172323_VALUE1$` once + FAILURE expected_to match_regex `^TOKEN201703172323_VARIABLE2=TOKEN201703172323_VALUE2$` once + FAILURE expected_to match_regex `^TOKEN201703172323_VARIABLE3=TOKEN201703172323_VALUE3$` once + 01: ------------------------------ + 02: TERM_PROGRAM=iTerm.app + 03: TERM=screen-256color + 04: SHELL=/bin/zsh + 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp + 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ + 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.uRjg1YTz1a/Render + 08: TERM_PROGRAM_VERSION=3.0.10 + 09: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 10: ZSH=/Users/ariard/.oh-my-zsh + 11: USER=ariard + 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 14: PAGER=less + 15: TMUX=/private/tmp/tmux-18965/default,83855,1 + 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches + 17: LSCOLORS=Gxfxcxdxbxegedabagacad + 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin + 19: MAIL=ariard@student.42.fr + 20: PWD=/Users/ariard/42shelltest-tmp/tmp + 21: LANG=en_US.UTF-8 + 22: ITERM_PROFILE=Default + 23: XPC_FLAGS=0x0 + 24: TMUX_PANE=%8 + 25: XPC_SERVICE_NAME=0 + 26: SHLVL=4 + 27: HOME=/Users/ariard + 28: COLORFGBG=7;0 + 29: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 30: LOGNAME=ariard + 31: LESS=-R + 32: LC_CTYPE=en_US.UTF-8 + 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ + 34: OLDPWD=/Users/ariard/42shelltest-tmp + 35: _=/Users/ariard/Projects/42sh/42sh + 36: ?=127 + 37: ------------------------------ + 38: TOTAL ENVIRONMENT VARIABLES: 35 + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: TOKEN201703172323_VARIABLE1=TOKEN201703172323_VALUE1 + +---------------------------------------------------------------- + +bonuses/inline-environment-variable/003-modifies-PATH-only (FAILED) + + Description: + The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. + + Before test: + 01: rm -rf "temporary_directory" + 02: mkdir -p "temporary_directory" + 03: cd "temporary_directory" + + STDIN: + 01: PATH=.. write_on_stdout TOKEN201703172323 + 02: exit_with_status 42 + + STDOUT: + FAILURE expected_to match_regex `^TOKEN201703172323$` + (no output) + + STDERR: + SUCCESS expected_to_not be_empty + SUCCESS might match_regex `[Cc]ommand not found` + 01: minishell: command not found: PATH=.. + 02: minishell: command not found: exit_with_status + + MISC: + SUCCESS expected_to_not exit_with_status `42` + SUCCESS expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +bonuses/separators/and/errors/001-parse-error-at-beginning (WARNING) + + Description: + 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. + + STDIN: + 01: && ./write_on_stdout TOKEN201703172323 + + STDOUT: + SUCCESS might_not match_regex `TOKEN201703172323` + SUCCESS might be_empty + (no output) + + STDERR: + SUCCESS might_not be_empty + SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` + 01: syntax error near unexpected token `&&' + + MISC: + WARNING might_not exit_with_status `0` + +---------------------------------------------------------------- + +bonuses/separators/and/errors/002-parse-error-too-much-symbol (FAILED) + + Description: + 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. + + STDIN: + 01: ./write_on_stdout TOKEN201703172323 &&& ./write_on_stdout TOKEN201703172323 + + STDOUT: + SUCCESS might_not match_regex `TOKEN201703172323` + SUCCESS might be_empty + (no output) + + STDERR: + SUCCESS might_not be_empty + SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` + 01: syntax error near unexpected token `&' + + MISC: + FAILURE expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +bonuses/separators/or/errors/001-parse-error-at-beginning (WARNING) + + Description: + 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. + + STDIN: + 01: || ./write_on_stdout TOKEN201703172323 + + STDOUT: + SUCCESS might be_empty + (no output) + + STDERR: + SUCCESS might_not be_empty + SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` + 01: syntax error near unexpected token `||' + + MISC: + WARNING might_not exit_with_status `0` + +---------------------------------------------------------------- + +bonuses/separators/or/errors/002-parse-error-too-much-symbol (WARNING) + + Description: + 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. + + STDIN: + 01: ./write_on_stdout TOKEN201703172323 ||| ./write_on_stdout TOKEN201703172323 + + STDOUT: + SUCCESS might be_empty + (no output) + + STDERR: + SUCCESS might_not be_empty + SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` + 01: syntax error near unexpected token `|' + + MISC: + WARNING might_not exit_with_status `0` + +---------------------------------------------------------------- + +bonuses/tilde-expansion/003-expanded-with-PWD-1 (FAILED) + + Description: + 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 `+`. + + Before test: + 01: export "HOME=/TOKEN201703172323" + + STDIN: + 01: ./write_on_stdout ~+ + + STDOUT: + SUCCESS expected_to_not match_regex `~[+]` + FAILURE expected_to_not match_regex `/TOKEN201703172323[+]` + FAILURE expected_to match_regex `^/Users/ariard/42shelltest-tmp/tmp$` + 01: /TOKEN201703172323+ + + STDERR: + (no output) + +---------------------------------------------------------------- + +bonuses/tilde-expansion/004-expanded-with-PWD-2 (FAILED) + + Description: + 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 `+`. + + Before test: + 01: export "HOME=/TOKEN201703172323" + + STDIN: + 01: ./write_on_stdout ~+/TOKEN201703172323_SUBDIRECTORY + + STDOUT: + SUCCESS expected_to_not match_regex `~+/TOKEN201703172323_SUBDIRECTORY` + FAILURE expected_to_not match_regex `/TOKEN201703172323[+]/TOKEN201703172323_SUBDIRECTORY` + FAILURE expected_to match_regex `^/Users/ariard/42shelltest-tmp/tmp/TOKEN201703172323_SUBDIRECTORY$` + 01: /TOKEN201703172323+/TOKEN201703172323_SUBDIRECTORY + + STDERR: + (no output) + +---------------------------------------------------------------- + +bonuses/tilde-expansion/005-expanded-with-OLDPWD-1 (FAILED) + + Description: + 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 `+`. + + Before test: + 01: rm -rf "./TOKEN201703172323_SUBDIRECTORY" + 02: mkdir "./TOKEN201703172323_SUBDIRECTORY" + 03: export "HOME=/TOKEN201703172323" + + STDIN: + 01: cd ./TOKEN201703172323_SUBDIRECTORY + 02: /Users/ariard/42shelltest-tmp/tmp/write_on_stdout ~- + + STDOUT: + SUCCESS expected_to_not match_regex `~-` + FAILURE expected_to_not match_regex `/TOKEN201703172323-` + FAILURE expected_to match_regex `^/Users/ariard/42shelltest-tmp/tmp$` + 01: /TOKEN201703172323- + + STDERR: + (no output) + +---------------------------------------------------------------- + +bonuses/tilde-expansion/006-expanded-with-OLDPWD-2 (FAILED) + + Description: + 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 `+`. + + Before test: + 01: rm -rf "./TOKEN201703172323_SUBDIRECTORY" + 02: mkdir "./TOKEN201703172323_SUBDIRECTORY" + 03: export "HOME=/TOKEN201703172323" + + STDIN: + 01: cd ./TOKEN201703172323_SUBDIRECTORY + 02: /Users/ariard/42shelltest-tmp/tmp/write_on_stdout ~-/TOKEN201703172323_OTHERDIRECTORY + + STDOUT: + SUCCESS expected_to_not match_regex `~-/TOKEN201703172323_OTHERDIRECTORY` + FAILURE expected_to_not match_regex `/TOKEN201703172323-/TOKEN201703172323_OTHERDIRECTORY` + FAILURE expected_to match_regex `^/Users/ariard/42shelltest-tmp/tmp/TOKEN201703172323_OTHERDIRECTORY$` + 01: /TOKEN201703172323-/TOKEN201703172323_OTHERDIRECTORY + + STDERR: + (no output) + +---------------------------------------------------------------- + +bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1 (FAILED) + + Description: + 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. + + Before test: + 01: export "HOME=/TOKEN201703172323" + + STDIN: + 01: ./write_on_stdout ~~ + + STDOUT: + FAILURE expected_to match_regex `^~~$` + FAILURE expected_to_not match_regex `/TOKEN201703172323` + 01: /TOKEN201703172323~ + + STDERR: + (no output) + +---------------------------------------------------------------- + +bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2 (FAILED) + + Description: + 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. + + Before test: + 01: export "HOME=/TOKEN201703172323" + + STDIN: + 01: ./write_on_stdout ~TOKEN201703172323_UNKNOWNUSER + + STDOUT: + FAILURE expected_to match_regex `^~TOKEN201703172323_UNKNOWNUSER$` + FAILURE expected_to_not match_regex `/TOKEN201703172323TOKEN201703172323_UNKNOWNUSER` + 01: /TOKEN201703172323TOKEN201703172323_UNKNOWNUSER + + STDERR: + (no output) + +---------------------------------------------------------------- + +bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD (FAILED) + + Description: + 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 `/`. + + Before test: + 01: export "HOME=/TOKEN201703172323" + + STDIN: + 01: ./write_on_stdout ~+TOKEN201703172323_SUBDIRECTORY + + STDOUT: + FAILURE expected_to match_regex `^~[+]TOKEN201703172323_SUBDIRECTORY$` + FAILURE expected_to_not match_regex `/TOKEN201703172323[+]TOKEN201703172323_SUBDIRECTORY` + SUCCESS expected_to_not match_regex `/Users/ariard/42shelltest-tmp/tmpTOKEN201703172323_SUBDIRECTORY` + 01: /TOKEN201703172323+TOKEN201703172323_SUBDIRECTORY + + STDERR: + (no output) + +---------------------------------------------------------------- + +bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD (FAILED) + + Description: + 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 `/`. + + Before test: + 01: rm -rf "./TOKEN201703172323_SUBDIRECTORY" + 02: mkdir "./TOKEN201703172323_SUBDIRECTORY" + 03: export "HOME=/TOKEN201703172323" + + STDIN: + 01: cd ./TOKEN201703172323_SUBDIRECTORY + 02: /Users/ariard/42shelltest-tmp/tmp/write_on_stdout ~-TOKEN201703172323_OTHERDIRECTORY + + STDOUT: + FAILURE expected_to match_regex `^~-TOKEN201703172323_OTHERDIRECTORY$` + SUCCESS expected_to_not match_regex `/TOKEN201703172323-/TOKEN201703172323_OTHERDIRECTORY` + SUCCESS expected_to_not match_regex `/Users/ariard/42shelltest-tmp/tmp/TOKEN201703172323_OTHERDIRECTORY` + 01: /TOKEN201703172323-TOKEN201703172323_OTHERDIRECTORY + + STDERR: + (no output) + +---------------------------------------------------------------- + +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 "TOKEN201703172323" + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: write_on_stdout + + MISC: + FAILURE expected_to exit_with_status `0` + +---------------------------------------------------------------- + +minishell/binary/006-binary-undefined-path (FAILED) + + Description: + The purpose of this test is to check that the Shell retrieves the default value of the environment variable PATH if not set. This test depends on the presence of the UNIX binary `ls`, located in a path within the default environment variable PATH. + + Before test: + 01: rm -rf "TOKEN201703172323_006-BINARY-UNDEFINED-PATH" + 02: touch "TOKEN201703172323_006-BINARY-UNDEFINED-PATH" + 03: unset PATH + + STDIN: + 01: ls + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323_006-BINARY-UNDEFINED-PATH` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: minishell: command not found: ls + + 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: minishell: ./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/42shelltest-tmp/tmp/display_pwd + 03: /Users/ariard/42shelltest-tmp/tmp/display_env + + STDOUT: + SUCCESS expected_to match_regex `PWD:/Users/ariard/42shelltest-tmp/tmp/sub_directory:PWD$` + FAILURE expected_to match_regex `^PWD=/Users/ariard/42shelltest-tmp/tmp/symbolic_link$` + 01: PWD:/Users/ariard/42shelltest-tmp/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.uRjg1YTz1a/Render + 09: TERM_PROGRAM_VERSION=3.0.10 + 10: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 11: ZSH=/Users/ariard/.oh-my-zsh + 12: USER=ariard + 13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 15: PAGER=less + 16: TMUX=/private/tmp/tmux-18965/default,83855,1 + 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/42shelltest-tmp/tmp/sub_directory + 22: LANG=en_US.UTF-8 + 23: ITERM_PROFILE=Default + 24: XPC_FLAGS=0x0 + 25: TMUX_PANE=%8 + 26: XPC_SERVICE_NAME=0 + 27: SHLVL=4 + 28: HOME=/Users/ariard + 29: COLORFGBG=7;0 + 30: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 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/42shelltest-tmp/tmp + 36: _=/Users/ariard/Projects/42sh/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/42shelltest-tmp/tmp/display_pwd + 03: /Users/ariard/42shelltest-tmp/tmp/display_env + + STDOUT: + SUCCESS expected_to match_regex `PWD:/Users/ariard/42shelltest-tmp/tmp/sub_directory:PWD$` + FAILURE expected_to match_regex `^PWD=/Users/ariard/42shelltest-tmp/tmp/symbolic_link2$` + 01: PWD:/Users/ariard/42shelltest-tmp/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.uRjg1YTz1a/Render + 09: TERM_PROGRAM_VERSION=3.0.10 + 10: TERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 11: ZSH=/Users/ariard/.oh-my-zsh + 12: USER=ariard + 13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.lQz9opv8hX/Listeners + 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 15: PAGER=less + 16: TMUX=/private/tmp/tmux-18965/default,83855,1 + 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/42shelltest-tmp/tmp/sub_directory + 22: LANG=en_US.UTF-8 + 23: ITERM_PROFILE=Default + 24: XPC_FLAGS=0x0 + 25: TMUX_PANE=%8 + 26: XPC_SERVICE_NAME=0 + 27: SHLVL=4 + 28: HOME=/Users/ariard + 29: COLORFGBG=7;0 + 30: ITERM_SESSION_ID=w0t0p1:012161CB-942E-417B-AD70-740FF5490A87 + 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/42shelltest-tmp/tmp + 36: _=/Users/ariard/Projects/42sh/42sh + 37: ?=0 + 38: ------------------------------ + 39: TOTAL ENVIRONMENT VARIABLES: 35 + + STDERR: + SUCCESS expected_to be_empty + (no output) + +---------------------------------------------------------------- + +minishell/builtins/cd/errors/001-not-a-directory (WARNING) + + Description: + The purpose of this test is to check that using a file name as first argument with the builtin `cd` results in error and not changing current directory. + + Before test: + 01: touch "./not_a_directory" + + STDIN: + 01: cd not_a_directory + 02: /Users/ariard/42shelltest-tmp/tmp/display_pwd + + STDOUT: + SUCCESS expected_to match_regex `PWD:/Users/ariard/42shelltest-tmp/tmp:PWD` + 01: PWD:/Users/ariard/42shelltest-tmp/tmp:PWD + + STDERR: + SUCCESS expected_to_not be_empty + WARNING might match_regex `[Nn]ot a directory` + 01: cd: no such file or directory: not_a_directory + +---------------------------------------------------------------- + +minishell/builtins/cd/errors/003-permission-denied (WARNING) + + Description: + The purpose of this test is to check that using a directory without any permission as first argument with the builtin `cd` results in error and not changing current directory. + + Before test: + 01: if [ -d "./permission_denied" ]; then chmod 777 "./permission_denied"; fi + 02: rm -rf "./permission_denied" + 03: mkdir -m 0 "./permission_denied" + + STDIN: + 01: cd permission_denied + 02: /Users/ariard/42shelltest-tmp/tmp/display_pwd + + STDOUT: + SUCCESS expected_to match_regex `PWD:/Users/ariard/42shelltest-tmp/tmp:PWD` + 01: PWD:/Users/ariard/42shelltest-tmp/tmp:PWD + + STDERR: + SUCCESS expected_to_not be_empty + WARNING might match_regex `[Pp]ermission denied` + 01: cd: no such file or directory: permission_denied + + After test: + 01: if [ -d "./permission_denied" ]; then chmod 777 "./permission_denied"; fi + 02: rm -rf "./permission_denied" + +---------------------------------------------------------------- + +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/42shelltest-tmp/tmp/display_pwd + + STDOUT: + SUCCESS expected_to match_regex `PWD:/Users/ariard/42shelltest-tmp/tmp:PWD` + 01: PWD:/Users/ariard/42shelltest-tmp/tmp:PWD + + STDERR: + SUCCESS expected_to_not be_empty + WARNING might match_regex `[Tt]oo many.*symbolic links` + 01: cd: no such file or directory: symbolic_link1 + +---------------------------------------------------------------- + +minishell/builtins/env/003-ignore-environment (FAILED) + + Description: + The purpose of this test is to check that using the option `-i` with the builtin `env` results in an empty environment sent to the given command. + + STDIN: + 01: env -i ./display_env + + STDOUT: + FAILURE expected_to match_regex `TOTAL ENVIRONMENT VARIABLES: 0` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: minishell: no such file or directory: ./display_env + +---------------------------------------------------------------- + +minishell/builtins/env/005-set-variables (FAILED) + + Description: + The purpose of this test is to check that the builtin `env` can modify or set multiple environment variables before executing the given command. + + Before test: + 01: export VARTEST1="OLD_VALUE" + + STDIN: + 01: env VARTEST1=TOKEN201703172323_1 VARTEST2=TOKEN201703172323_2 VARTEST3=TOKEN201703172323_3 ./display_env + + STDOUT: + FAILURE expected_to match_regex `VARTEST1=TOKEN201703172323_1` + FAILURE expected_to match_regex `VARTEST2=TOKEN201703172323_2` + FAILURE expected_to match_regex `VARTEST3=TOKEN201703172323_3` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: minishell: no such file or directory: ./display_env + +---------------------------------------------------------------- + +minishell/builtins/env/errors/001-command-not-found (FAILED) + + 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: minishell: no such file or directory: ./invalid_binary + + MISC: + FAILURE expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +minishell/builtins/env/errors/002-illegal-option (FAILED) + + Description: + The purpose of this test is to check that using the builtin `env` with an invalid option results in an error and failure exit status. + + Before test: + 01: rm -f -- "-w" + + STDIN: + 01: env -w + + STDOUT: + (no output) + + STDERR: + SUCCESS expected_to_not be_empty + WARNING might match_regex `([Ii]nvalid|[Ii]llegal) (option|argument)` + 01: env: option requires an argument -- w + 02: usage: env [-iv] [-P utilpath] [-S string] [-u name] + 03: [name=value ...] [utility [argument ...]] + + MISC: + FAILURE expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +minishell/builtins/env/multiple-options/001-ignore-environment-and-set-variable (FAILED) + + Description: + The purpose of this test is to check that `env -i` works if we use a second argument to set an environment variable, we are also checking if this command unset environments variables for a given binary. + + STDIN: + 01: env -i TESTVARIABLE=TOKEN201703172323 ./display_env + + STDOUT: + FAILURE expected_to match_regex `TESTVARIABLE=TOKEN201703172323` + FAILURE expected_to match_regex `TOTAL ENVIRONMENT VARIABLES: 1` + (no output) + + STDERR: + FAILURE expected_to be_empty + 01: minishell: no such file or directory: ./display_env + +---------------------------------------------------------------- + +minishell/builtins/exit/errors/001-too-many-args (FAILED) + + 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 TOKEN201703172323 + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703172323` + (no output) + + STDERR: + FAILURE expected_to_not be_empty + WARNING might match_regex `([Tt]oo many arguments|[Aa]rgument list too long)` + (no output) + + MISC: + FAILURE expected_to exit_with_status `0` + +---------------------------------------------------------------- + +minishell/builtins/exit/errors/002-non-numeric-argument (FAILED) + + Description: + The purpose of this test is to check that using a non-numeric argument with the builtin `exit` results in the Shell termination and an error on standard error. + + STDIN: + 01: exit abc + 02: ./write_on_stdout TOKEN201703172323 + + STDOUT: + SUCCESS expected_to_not match_regex `TOKEN201703172323` + (no output) + + STDERR: + WARNING might_not be_empty + WARNING might match_regex `[Nn]umeric argument required` + (no output) + + MISC: + FAILURE expected_to_not exit_with_status `0` + +---------------------------------------------------------------- + +minishell/builtins/setenv/004-invalid-identifier (FAILED) + + Description: + The purpose of this test is to check that using a wrong variable name with the builtin `setenv` (or `export`) results in error. + + STDIN: + 01: setenv 42 + 02: export 42 + + STDOUT: + SUCCESS might be_empty + (no output) + + STDERR: + FAILURE expected_to_not be_empty + WARNING might match_regex `(not.*identifier|must begin.*letter)` + (no output) + +Total tests: 296 +Total failed tests: 105 +Total pending tests: 3 diff --git a/42sh/42shelltest-tmp/spec/README.md b/42sh/42shelltest-tmp/spec/README.md new file mode 100644 index 00000000..dba95403 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/README.md @@ -0,0 +1,6 @@ +# spec + +* [21sh](./21sh) +* [42sh](./42sh) +* [bonuses](./bonuses) +* [minishell](./minishell) diff --git a/42sh/42shelltest-tmp/spec/bonuses/README.md b/42sh/42shelltest-tmp/spec/bonuses/README.md new file mode 100644 index 00000000..9c789434 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/README.md b/42sh/42shelltest-tmp/spec/bonuses/builtins/README.md new file mode 100644 index 00000000..bc79927e --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/builtins/README.md @@ -0,0 +1,5 @@ +# builtins + +*[spec > bonuses](..) > builtins* + +* [env](./env) diff --git a/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/README.md b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/README.md new file mode 100644 index 00000000..3a763d0a --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/README.md @@ -0,0 +1,63 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/before_exec b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/before_exec new file mode 100644 index 00000000..b5017f3b --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/before_exec @@ -0,0 +1 @@ +export TESTVARIABLE="${GLOBAL_TOKEN}" diff --git a/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/description b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/description new file mode 100644 index 00000000..6d2bc3a8 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/non-posix b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/non-posix new file mode 100644 index 00000000..8b9aeabf --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/pending b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stderr b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stdin b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stdin new file mode 100644 index 00000000..96a4be3f --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stdin @@ -0,0 +1 @@ +env -u HOME -u PATH -u TESTVARIABLE ./display_env diff --git a/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stdout b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/001-unset-variables/stdout new file mode 100644 index 00000000..93c94f83 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md new file mode 100644 index 00000000..2061f8c0 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md @@ -0,0 +1,63 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec new file mode 100644 index 00000000..072acc45 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/description b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/description new file mode 100644 index 00000000..d1d70325 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/non-posix b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/non-posix new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/pending b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr new file mode 100644 index 00000000..c703fdc6 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin new file mode 100644 index 00000000..afb12db8 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout new file mode 100644 index 00000000..4afc77a6 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/builtins/env/README.md b/42sh/42shelltest-tmp/spec/bonuses/builtins/env/README.md new file mode 100644 index 00000000..905bafab --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md new file mode 100644 index 00000000..ebadd59e --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md @@ -0,0 +1,62 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec new file mode 100644 index 00000000..3d157a65 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec @@ -0,0 +1 @@ +unset "${GLOBAL_TOKEN}_VARIABLE" diff --git a/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin new file mode 100644 index 00000000..ac8a9dc1 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout new file mode 100644 index 00000000..d0fe972f --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md new file mode 100644 index 00000000..11e1e15e --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md @@ -0,0 +1,64 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec new file mode 100644 index 00000000..3d157a65 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec @@ -0,0 +1 @@ +unset "${GLOBAL_TOKEN}_VARIABLE" diff --git a/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin new file mode 100644 index 00000000..41cea892 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout new file mode 100644 index 00000000..37f7aa70 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md new file mode 100644 index 00000000..da2c274f --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md @@ -0,0 +1,73 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec new file mode 100644 index 00000000..6da5ae48 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc new file mode 100644 index 00000000..b982085d --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr new file mode 100644 index 00000000..e259629c --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin new file mode 100644 index 00000000..e318f09a --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout new file mode 100644 index 00000000..ba5eb86a --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout @@ -0,0 +1 @@ +expected_to match_regex "^${GLOBAL_TOKEN}$" diff --git a/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/README.md b/42sh/42shelltest-tmp/spec/bonuses/inline-environment-variable/README.md new file mode 100644 index 00000000..b210b586 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/README.md b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/README.md new file mode 100644 index 00000000..6c5fa14c --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/README.md @@ -0,0 +1,70 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec new file mode 100644 index 00000000..21a08a3e --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec @@ -0,0 +1 @@ +rm -f "new_file_stderr_and_stdout" diff --git a/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/description b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/description new file mode 100644 index 00000000..9f258f1d --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/hard b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/hard new file mode 100644 index 00000000..ac178a36 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/hard @@ -0,0 +1 @@ +This test only succeed with the reference ZSH. diff --git a/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/misc b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/misc new file mode 100644 index 00000000..5ff4505a --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix new file mode 100644 index 00000000..c009338b --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/pending b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stderr b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stderr new file mode 100644 index 00000000..954fde45 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stderr @@ -0,0 +1 @@ +expected_to_not match_regex "${GLOBAL_TOKEN}_stderr" diff --git a/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stdin b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stdin new file mode 100644 index 00000000..95ebe4a6 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stdout b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stdout new file mode 100644 index 00000000..edd840fd --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/redirections/001-append-twice-outputs-together/stdout @@ -0,0 +1 @@ +expected_to_not match_regex "${GLOBAL_TOKEN}_stdout" diff --git a/42sh/42shelltest-tmp/spec/bonuses/redirections/README.md b/42sh/42shelltest-tmp/spec/bonuses/redirections/README.md new file mode 100644 index 00000000..3fb4835b --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/README.md new file mode 100644 index 00000000..baa8d80a --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/README.md @@ -0,0 +1,7 @@ +# separators + +*[spec > bonuses](..) > separators* + +* [and](./and) +* [mixed](./mixed) +* [or](./or) diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/README.md new file mode 100644 index 00000000..fac73ee7 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/README.md @@ -0,0 +1,55 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/description b/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/description new file mode 100644 index 00000000..6c60d378 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/stdin new file mode 100644 index 00000000..793e144e --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/and/001-run-twice/stdout new file mode 100644 index 00000000..65f5ef3a --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/README.md new file mode 100644 index 00000000..b365c1ab --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/README.md @@ -0,0 +1,63 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/description b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/description new file mode 100644 index 00000000..f85a5e86 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/misc new file mode 100644 index 00000000..cdd865a4 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/misc @@ -0,0 +1 @@ +might exit_with_status "42" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/stdin new file mode 100644 index 00000000..486986fc --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/and/002-do-not-run-second/stdout new file mode 100644 index 00000000..b01a27a5 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/README.md new file mode 100644 index 00000000..8f02b390 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/README.md @@ -0,0 +1,62 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/description b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/description new file mode 100644 index 00000000..9d47e372 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/misc new file mode 100644 index 00000000..1983dc76 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/misc @@ -0,0 +1 @@ +expected_to exit_with_status "42" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/stdin new file mode 100644 index 00000000..ade933dd --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/and/003-run-until-failing/stdout new file mode 100644 index 00000000..16c3d329 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/and/README.md new file mode 100644 index 00000000..0465749c --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md new file mode 100644 index 00000000..0f0af336 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md @@ -0,0 +1,65 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description new file mode 100644 index 00000000..680a6627 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin new file mode 100644 index 00000000..dc4ada22 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin @@ -0,0 +1 @@ +&& ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout new file mode 100644 index 00000000..f78d19db --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md new file mode 100644 index 00000000..f2c640f6 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md @@ -0,0 +1,65 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description new file mode 100644 index 00000000..00c27154 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc new file mode 100644 index 00000000..55d07cd5 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin new file mode 100644 index 00000000..d43aa5f0 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout new file mode 100644 index 00000000..f78d19db --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/and/errors/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/and/errors/README.md new file mode 100644 index 00000000..60f1730e --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/README.md new file mode 100644 index 00000000..80ffeffc --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/README.md @@ -0,0 +1,61 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/description b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stdin new file mode 100644 index 00000000..ead446bc --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/001-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/README.md new file mode 100644 index 00000000..254641b3 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/README.md @@ -0,0 +1,61 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/description b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stdin new file mode 100644 index 00000000..7513ed7b --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/002-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/README.md new file mode 100644 index 00000000..1fe553ef --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/README.md @@ -0,0 +1,61 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/description b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stdin new file mode 100644 index 00000000..e695ff1a --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/003-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/README.md new file mode 100644 index 00000000..50c645e9 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/README.md @@ -0,0 +1,61 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/description b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/misc new file mode 100644 index 00000000..82d70611 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "21" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stdin new file mode 100644 index 00000000..29391e99 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stdout new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/004-or-and/stdout @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/README.md new file mode 100644 index 00000000..608bfc49 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/README.md @@ -0,0 +1,61 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/description b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/misc new file mode 100644 index 00000000..82d70611 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "21" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stdin new file mode 100644 index 00000000..6d9fee3a --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/005-or-and/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/README.md new file mode 100644 index 00000000..41fe8559 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/README.md @@ -0,0 +1,61 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/description b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stdin new file mode 100644 index 00000000..7dab07c6 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/006-or-and/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/mixed/README.md new file mode 100644 index 00000000..a6863e70 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/README.md new file mode 100644 index 00000000..5dded6f3 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/README.md @@ -0,0 +1,55 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/description b/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/description new file mode 100644 index 00000000..faf0dca8 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/stdin new file mode 100644 index 00000000..e167faf4 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/or/001-run-first-only/stdout new file mode 100644 index 00000000..195b1a22 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/README.md new file mode 100644 index 00000000..1e255e4c --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/README.md @@ -0,0 +1,61 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/description b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/description new file mode 100644 index 00000000..f8892296 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/misc new file mode 100644 index 00000000..fd805999 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/misc @@ -0,0 +1 @@ +might exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stdin new file mode 100644 index 00000000..fc0472c0 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stdout new file mode 100644 index 00000000..bbdd98ff --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/002-run-second-only/stdout @@ -0,0 +1 @@ +might match_regex "${GLOBAL_TOKEN}" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/README.md new file mode 100644 index 00000000..0797860a --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/README.md @@ -0,0 +1,62 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/description b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/description new file mode 100644 index 00000000..960a362b --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/stdin new file mode 100644 index 00000000..0f675560 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/or/003-run-until-succeeding/stdout new file mode 100644 index 00000000..16c3d329 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/or/README.md new file mode 100644 index 00000000..a3b10c36 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md new file mode 100644 index 00000000..54b503ed --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md @@ -0,0 +1,64 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description new file mode 100644 index 00000000..d29fb8ad --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin new file mode 100644 index 00000000..9dfc6dbd --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin @@ -0,0 +1 @@ +|| ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md new file mode 100644 index 00000000..429f2119 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md @@ -0,0 +1,65 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description new file mode 100644 index 00000000..940ef752 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr new file mode 100644 index 00000000..a6382d38 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin new file mode 100644 index 00000000..782254a3 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/README.md b/42sh/42shelltest-tmp/spec/bonuses/separators/or/errors/README.md new file mode 100644 index 00000000..babe06e9 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md new file mode 100644 index 00000000..8a45a52c --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md @@ -0,0 +1,55 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description new file mode 100644 index 00000000..53e01191 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin new file mode 100644 index 00000000..69307f14 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~ diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout new file mode 100644 index 00000000..3c9d4ab8 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md new file mode 100644 index 00000000..cb16c351 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md @@ -0,0 +1,55 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description new file mode 100644 index 00000000..2c601af5 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin new file mode 100644 index 00000000..b806e8d9 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~/${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout new file mode 100644 index 00000000..ddeb1db3 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md new file mode 100644 index 00000000..3aa1a1e6 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md @@ -0,0 +1,56 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description new file mode 100644 index 00000000..545ed856 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin new file mode 100644 index 00000000..c2315545 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+ diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout new file mode 100644 index 00000000..ec00fafb --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md new file mode 100644 index 00000000..4f13fd38 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md @@ -0,0 +1,56 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description new file mode 100644 index 00000000..545ed856 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin new file mode 100644 index 00000000..019c6cf9 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+/${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout new file mode 100644 index 00000000..23a27406 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md new file mode 100644 index 00000000..7bbb14fd --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md @@ -0,0 +1,59 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description new file mode 100644 index 00000000..1cb05172 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin new file mode 100644 index 00000000..c9e75916 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout new file mode 100644 index 00000000..ff80be6f --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md new file mode 100644 index 00000000..d6e59670 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md @@ -0,0 +1,59 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description new file mode 100644 index 00000000..1cb05172 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin new file mode 100644 index 00000000..76895961 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout new file mode 100644 index 00000000..1dbf719e --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/README.md new file mode 100644 index 00000000..5c02470e --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md new file mode 100644 index 00000000..4b7be101 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md @@ -0,0 +1,55 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/before_exec b/42sh/42shelltest-tmp/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/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description new file mode 100644 index 00000000..739f0907 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin new file mode 100644 index 00000000..fd5167ce --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~~ diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout new file mode 100644 index 00000000..3160a089 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md new file mode 100644 index 00000000..855ca035 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md @@ -0,0 +1,55 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/before_exec b/42sh/42shelltest-tmp/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/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description new file mode 100644 index 00000000..739f0907 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin new file mode 100644 index 00000000..3c0b74c7 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout new file mode 100644 index 00000000..9a73fcf0 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md new file mode 100644 index 00000000..065e5648 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md @@ -0,0 +1,56 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description new file mode 100644 index 00000000..832e877c --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin new file mode 100644 index 00000000..f0cc2677 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout new file mode 100644 index 00000000..53269842 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md new file mode 100644 index 00000000..e9813426 --- /dev/null +++ b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md @@ -0,0 +1,59 @@ +# 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: + + +* **[./create_file](http://github.com/we-sh/42ShellTester/tree/master/support/create-file)** -> A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" +* **[./delete_file](http://github.com/we-sh/42ShellTester/tree/master/support/delete-file)** -> A binary that delete all files called in argument. +* **[./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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description new file mode 100644 index 00000000..fad1aead --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin new file mode 100644 index 00000000..4c3cec62 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout new file mode 100644 index 00000000..1ed88c70 --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/README.md b/42sh/42shelltest-tmp/spec/bonuses/tilde-expansion/not-expanded/README.md new file mode 100644 index 00000000..bdb7eabc --- /dev/null +++ b/42sh/42shelltest-tmp/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/42shelltest-tmp/support/Makefile b/42sh/42shelltest-tmp/support/Makefile new file mode 100644 index 00000000..a6f36b46 --- /dev/null +++ b/42sh/42shelltest-tmp/support/Makefile @@ -0,0 +1,31 @@ +TARGET_DIR=../../tmp + +all: + make TARGET_DIR=$(TARGET_DIR) -C ./display-env + make TARGET_DIR=$(TARGET_DIR) -C ./display-program-name + make TARGET_DIR=$(TARGET_DIR) -C ./display-pwd + make TARGET_DIR=$(TARGET_DIR) -C ./exit-with-status + make TARGET_DIR=$(TARGET_DIR) -C ./read-on-stdin + make TARGET_DIR=$(TARGET_DIR) -C ./sleep-and-exit-with-status + make TARGET_DIR=$(TARGET_DIR) -C ./sleep-and-write-on-stderr + make TARGET_DIR=$(TARGET_DIR) -C ./write-all-arguments-on-stdout + make TARGET_DIR=$(TARGET_DIR) -C ./write-on-stderr + make TARGET_DIR=$(TARGET_DIR) -C ./write-on-stdout + make TARGET_DIR=$(TARGET_DIR) -C ./write-on-stdout-and-stderr + make TARGET_DIR=$(TARGET_DIR) -C ./create-file + make TARGET_DIR=$(TARGET_DIR) -C ./delete-file + +re: fclean all + +fclean: + make TARGET_DIR=$(TARGET_DIR) fclean -C ./display-env + make TARGET_DIR=$(TARGET_DIR) fclean -C ./display-program-name + make TARGET_DIR=$(TARGET_DIR) fclean -C ./display-pwd + make TARGET_DIR=$(TARGET_DIR) fclean -C ./exit-with-status + make TARGET_DIR=$(TARGET_DIR) fclean -C ./read-on-stdin + make TARGET_DIR=$(TARGET_DIR) fclean -C ./sleep-and-exit-with-status + make TARGET_DIR=$(TARGET_DIR) fclean -C ./sleep-and-write-on-stderr + make TARGET_DIR=$(TARGET_DIR) fclean -C ./write-all-arguments-on-stdout + make TARGET_DIR=$(TARGET_DIR) fclean -C ./write-on-stderr + make TARGET_DIR=$(TARGET_DIR) fclean -C ./create-file + make TARGET_DIR=$(TARGET_DIR) fclean -C ./delete-file diff --git a/42sh/42shelltest-tmp/support/create-file/Makefile b/42sh/42shelltest-tmp/support/create-file/Makefile new file mode 100644 index 00000000..2b1425d1 --- /dev/null +++ b/42sh/42shelltest-tmp/support/create-file/Makefile @@ -0,0 +1,12 @@ +NAME=create-file +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/create-file/README.md b/42sh/42shelltest-tmp/support/create-file/README.md new file mode 100644 index 00000000..826dd1ec --- /dev/null +++ b/42sh/42shelltest-tmp/support/create-file/README.md @@ -0,0 +1,24 @@ +# ./create_file + +A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" + +```c +#include +#include + +int main(int argc, char **argv) +{ + char *name; + static char filename[1000]; + + (void)argc; + if (!argv[1]) + strcat(filename, "TOKEN"); + else + strcat(filename, argv[1]); + name = "_FILE"; + strcat(filename, name); + creat(filename, 0644); + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/create-file/description b/42sh/42shelltest-tmp/support/create-file/description new file mode 100644 index 00000000..16c774d5 --- /dev/null +++ b/42sh/42shelltest-tmp/support/create-file/description @@ -0,0 +1 @@ +A binary that creates file named argv[1] + "_FILE" If argv[1] is not set, the file is named "TOKEN_FILE" diff --git a/42sh/42shelltest-tmp/support/create-file/main.c b/42sh/42shelltest-tmp/support/create-file/main.c new file mode 100644 index 00000000..a00b65fc --- /dev/null +++ b/42sh/42shelltest-tmp/support/create-file/main.c @@ -0,0 +1,18 @@ +#include +#include + +int main(int argc, char **argv) +{ + char *name; + static char filename[1000]; + + (void)argc; + if (!argv[1]) + strcat(filename, "TOKEN"); + else + strcat(filename, argv[1]); + name = "_FILE"; + strcat(filename, name); + creat(filename, 0644); + return (0); +} diff --git a/42sh/42shelltest-tmp/support/delete-file/Makefile b/42sh/42shelltest-tmp/support/delete-file/Makefile new file mode 100644 index 00000000..31aa7711 --- /dev/null +++ b/42sh/42shelltest-tmp/support/delete-file/Makefile @@ -0,0 +1,12 @@ +NAME=delete-file +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/delete-file/README.md b/42sh/42shelltest-tmp/support/delete-file/README.md new file mode 100644 index 00000000..f82c81f4 --- /dev/null +++ b/42sh/42shelltest-tmp/support/delete-file/README.md @@ -0,0 +1,23 @@ +# ./delete_file + +A binary that delete all files called in argument. + +```c +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + char buf[PATH_MAX + 1]; + + while (argc > 0) + { + bzero(buf, PATH_MAX + 1); + realpath(argv[argc--], buf); + remove(buf); + } + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/delete-file/description b/42sh/42shelltest-tmp/support/delete-file/description new file mode 100644 index 00000000..11d62594 --- /dev/null +++ b/42sh/42shelltest-tmp/support/delete-file/description @@ -0,0 +1 @@ +A binary that delete all files called in argument. diff --git a/42sh/42shelltest-tmp/support/delete-file/main.c b/42sh/42shelltest-tmp/support/delete-file/main.c new file mode 100644 index 00000000..3ea74f79 --- /dev/null +++ b/42sh/42shelltest-tmp/support/delete-file/main.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + char buf[PATH_MAX + 1]; + + while (argc > 0) + { + bzero(buf, PATH_MAX + 1); + realpath(argv[argc--], buf); + remove(buf); + } + return (0); +} diff --git a/42sh/42shelltest-tmp/support/display-env/Makefile b/42sh/42shelltest-tmp/support/display-env/Makefile new file mode 100644 index 00000000..d2691951 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-env/Makefile @@ -0,0 +1,12 @@ +NAME=display_env +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/display-env/README.md b/42sh/42shelltest-tmp/support/display-env/README.md new file mode 100644 index 00000000..3b363278 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-env/README.md @@ -0,0 +1,28 @@ +# ./display_env + +A binary that iterates on `**envp` and write each element on standard output. + +```c +#include +#include +#include + +int main(int argc, char **argv, char **envp) +{ + int i; + + i = 0; + (void)argc; + (void)argv; + write(1, "------------------------------\n", 31); + while (envp[i]) + { + write(1, envp[i], strlen(envp[i])); + write(1, "\n", 1); + i++; + } + write(1, "------------------------------\n", 31); + printf("TOTAL ENVIRONMENT VARIABLES: %d\n", i); + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/display-env/description b/42sh/42shelltest-tmp/support/display-env/description new file mode 100644 index 00000000..8ea7d9c4 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-env/description @@ -0,0 +1 @@ +A binary that iterates on `**envp` and write each element on standard output. diff --git a/42sh/42shelltest-tmp/support/display-env/main.c b/42sh/42shelltest-tmp/support/display-env/main.c new file mode 100644 index 00000000..95bfa3a1 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-env/main.c @@ -0,0 +1,22 @@ +#include +#include +#include + +int main(int argc, char **argv, char **envp) +{ + int i; + + i = 0; + (void)argc; + (void)argv; + write(1, "------------------------------\n", 31); + while (envp[i]) + { + write(1, envp[i], strlen(envp[i])); + write(1, "\n", 1); + i++; + } + write(1, "------------------------------\n", 31); + printf("TOTAL ENVIRONMENT VARIABLES: %d\n", i); + return (0); +} diff --git a/42sh/42shelltest-tmp/support/display-program-name/Makefile b/42sh/42shelltest-tmp/support/display-program-name/Makefile new file mode 100644 index 00000000..6cf460d1 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-program-name/Makefile @@ -0,0 +1,12 @@ +NAME=display_program_name +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/display-program-name/README.md b/42sh/42shelltest-tmp/support/display-program-name/README.md new file mode 100644 index 00000000..54fba524 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-program-name/README.md @@ -0,0 +1,16 @@ +# ./display_program_name + +A binary that writes its name on standard ouput. + +```c +#include +#include + +int main(int ac, char **av) +{ + (void)ac; + write(1, av[0], strlen(av[0])); + write(1, "\n", 1); + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/display-program-name/description b/42sh/42shelltest-tmp/support/display-program-name/description new file mode 100644 index 00000000..67f56943 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-program-name/description @@ -0,0 +1 @@ +A binary that writes its name on standard ouput. diff --git a/42sh/42shelltest-tmp/support/display-program-name/main.c b/42sh/42shelltest-tmp/support/display-program-name/main.c new file mode 100644 index 00000000..3c3d8c9b --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-program-name/main.c @@ -0,0 +1,10 @@ +#include +#include + +int main(int ac, char **av) +{ + (void)ac; + write(1, av[0], strlen(av[0])); + write(1, "\n", 1); + return (0); +} diff --git a/42sh/42shelltest-tmp/support/display-pwd/Makefile b/42sh/42shelltest-tmp/support/display-pwd/Makefile new file mode 100644 index 00000000..3f67de1c --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-pwd/Makefile @@ -0,0 +1,12 @@ +NAME=display_pwd +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/display-pwd/README.md b/42sh/42shelltest-tmp/support/display-pwd/README.md new file mode 100644 index 00000000..6f1a2b1f --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-pwd/README.md @@ -0,0 +1,19 @@ +# ./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`. + +```c +#include +#include + +int main(void) +{ + char *pwd; + + pwd = getcwd(NULL, 0); + write(1, "PWD:", 4); + write(1, pwd, strlen(pwd)); + write(1, ":PWD\n", 5); + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/display-pwd/description b/42sh/42shelltest-tmp/support/display-pwd/description new file mode 100644 index 00000000..3ed81da3 --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-pwd/description @@ -0,0 +1 @@ +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`. diff --git a/42sh/42shelltest-tmp/support/display-pwd/main.c b/42sh/42shelltest-tmp/support/display-pwd/main.c new file mode 100644 index 00000000..4577602e --- /dev/null +++ b/42sh/42shelltest-tmp/support/display-pwd/main.c @@ -0,0 +1,13 @@ +#include +#include + +int main(void) +{ + char *pwd; + + pwd = getcwd(NULL, 0); + write(1, "PWD:", 4); + write(1, pwd, strlen(pwd)); + write(1, ":PWD\n", 5); + return (0); +} diff --git a/42sh/42shelltest-tmp/support/exit-with-status/Makefile b/42sh/42shelltest-tmp/support/exit-with-status/Makefile new file mode 100644 index 00000000..ff89498a --- /dev/null +++ b/42sh/42shelltest-tmp/support/exit-with-status/Makefile @@ -0,0 +1,12 @@ +NAME=exit_with_status +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/exit-with-status/README.md b/42sh/42shelltest-tmp/support/exit-with-status/README.md new file mode 100644 index 00000000..03ff819a --- /dev/null +++ b/42sh/42shelltest-tmp/support/exit-with-status/README.md @@ -0,0 +1,15 @@ +# ./exit_with_status + +A binary that immediately exits with the status given as first argument. + +```c +#include + +int main(int argc, char **argv) +{ + (void)argc; + if (argc == 2) + return (atoi(argv[1])); + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/exit-with-status/description b/42sh/42shelltest-tmp/support/exit-with-status/description new file mode 100644 index 00000000..cc796af3 --- /dev/null +++ b/42sh/42shelltest-tmp/support/exit-with-status/description @@ -0,0 +1 @@ +A binary that immediately exits with the status given as first argument. diff --git a/42sh/42shelltest-tmp/support/exit-with-status/main.c b/42sh/42shelltest-tmp/support/exit-with-status/main.c new file mode 100644 index 00000000..b79772e5 --- /dev/null +++ b/42sh/42shelltest-tmp/support/exit-with-status/main.c @@ -0,0 +1,9 @@ +#include + +int main(int argc, char **argv) +{ + (void)argc; + if (argc == 2) + return (atoi(argv[1])); + return (0); +} diff --git a/42sh/42shelltest-tmp/support/read-on-stdin-once/Makefile b/42sh/42shelltest-tmp/support/read-on-stdin-once/Makefile new file mode 100644 index 00000000..b041522a --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin-once/Makefile @@ -0,0 +1,12 @@ +NAME=read_on_stdin_once +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/read-on-stdin-once/README.md b/42sh/42shelltest-tmp/support/read-on-stdin-once/README.md new file mode 100644 index 00000000..69399bf0 --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin-once/README.md @@ -0,0 +1,27 @@ +# ./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. + +```c +#include +#include + +int main(void) +{ + char buf[1]; + int ret; + + while ((ret = read(0, buf, 1)) > 0) + { + if (buf[0] == '\n') + write(1, "@", 1); + write(1, buf, ret); + } + if (ret < 0) + { + write(2, "STDIN READ ERROR\n", 17); + return (1); + } + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/read-on-stdin-once/description b/42sh/42shelltest-tmp/support/read-on-stdin-once/description new file mode 100644 index 00000000..801c328f --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin-once/description @@ -0,0 +1 @@ +A binary that reads 1024 bytes 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. Reads only a once. diff --git a/42sh/42shelltest-tmp/support/read-on-stdin-once/main.c b/42sh/42shelltest-tmp/support/read-on-stdin-once/main.c new file mode 100644 index 00000000..d1ca00d1 --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin-once/main.c @@ -0,0 +1,20 @@ +#include +#include + +int main(void) +{ + char buf[1024]; + int ret; + + if ((ret = read(0, buf, 1024))) + { + write(1, buf, ret); + write(1, "@", 1); + } + if (ret < 0) + { + write(2, "STDIN READ ERROR\n", 17); + return (1); + } + return (0); +} diff --git a/42sh/42shelltest-tmp/support/read-on-stdin/Makefile b/42sh/42shelltest-tmp/support/read-on-stdin/Makefile new file mode 100644 index 00000000..4cf56248 --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin/Makefile @@ -0,0 +1,12 @@ +NAME=read_on_stdin +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/read-on-stdin/README.md b/42sh/42shelltest-tmp/support/read-on-stdin/README.md new file mode 100644 index 00000000..69399bf0 --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin/README.md @@ -0,0 +1,27 @@ +# ./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. + +```c +#include +#include + +int main(void) +{ + char buf[1]; + int ret; + + while ((ret = read(0, buf, 1)) > 0) + { + if (buf[0] == '\n') + write(1, "@", 1); + write(1, buf, ret); + } + if (ret < 0) + { + write(2, "STDIN READ ERROR\n", 17); + return (1); + } + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/read-on-stdin/description b/42sh/42shelltest-tmp/support/read-on-stdin/description new file mode 100644 index 00000000..e5f02ab5 --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin/description @@ -0,0 +1 @@ +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. diff --git a/42sh/42shelltest-tmp/support/read-on-stdin/main.c b/42sh/42shelltest-tmp/support/read-on-stdin/main.c new file mode 100644 index 00000000..1bbe6af9 --- /dev/null +++ b/42sh/42shelltest-tmp/support/read-on-stdin/main.c @@ -0,0 +1,21 @@ +#include +#include + +int main(void) +{ + char buf[1]; + int ret; + + while ((ret = read(0, buf, 1)) > 0) + { + if (buf[0] == '\n') + write(1, "@", 1); + write(1, buf, ret); + } + if (ret < 0) + { + write(2, "STDIN READ ERROR\n", 17); + return (1); + } + return (0); +} diff --git a/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/Makefile b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/Makefile new file mode 100644 index 00000000..c73f1aed --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/Makefile @@ -0,0 +1,12 @@ +NAME=sleep_and_exit_with_status +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/README.md b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/README.md new file mode 100644 index 00000000..1fd5254f --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/README.md @@ -0,0 +1,22 @@ +# ./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. + +```c +#include +#include +#include + +int main(int argc, char **argv) +{ + int seconds; + + seconds = 1; + if (argc > 1) + seconds = atoi(argv[1]); + sleep(seconds); + if (argc > 2) + return (atoi(argv[2])); + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/description b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/description new file mode 100644 index 00000000..0717f2fd --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/description @@ -0,0 +1 @@ +A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. diff --git a/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/main.c b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/main.c new file mode 100644 index 00000000..32f90c46 --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-exit-with-status/main.c @@ -0,0 +1,16 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + int seconds; + + seconds = 1; + if (argc > 1) + seconds = atoi(argv[1]); + sleep(seconds); + if (argc > 2) + return (atoi(argv[2])); + return (0); +} diff --git a/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/Makefile b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/Makefile new file mode 100644 index 00000000..39311aca --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/Makefile @@ -0,0 +1,12 @@ +NAME=sleep_and_write_on_stderr +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/README.md b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/README.md new file mode 100644 index 00000000..5ce004e5 --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/README.md @@ -0,0 +1,24 @@ +# ./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. + +```c +#include +#include +#include + +int main(int argc, char **argv) +{ + int seconds; + + seconds = 1; + if (argc > 1) + seconds = atoi(argv[1]); + sleep(seconds); + if (argc > 2) + { + write(2, argv[2], strlen(argv[2])); + } + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/description b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/description new file mode 100644 index 00000000..a4852ae2 --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/description @@ -0,0 +1 @@ +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. diff --git a/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/main.c b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/main.c new file mode 100644 index 00000000..b9c77a68 --- /dev/null +++ b/42sh/42shelltest-tmp/support/sleep-and-write-on-stderr/main.c @@ -0,0 +1,18 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + int seconds; + + seconds = 1; + if (argc > 1) + seconds = atoi(argv[1]); + sleep(seconds); + if (argc > 2) + { + write(2, argv[2], strlen(argv[2])); + } + return (0); +} diff --git a/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/Makefile b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/Makefile new file mode 100644 index 00000000..2ef23814 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/Makefile @@ -0,0 +1,12 @@ +NAME=write_all_arguments_on_stdout +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/README.md b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/README.md new file mode 100644 index 00000000..0dc66c74 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/README.md @@ -0,0 +1,28 @@ +# ./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". + +```c +#include +#include + +int main(int argc, char **argv) +{ + if (argc >= 2) + { + argv++; + while (*argv) + { + write(1, *argv, strlen(*argv)); + write(1, "@", 1); + argv++; + } + write(1, "\n", 1); + } + else + { + write(1, "nothing to be written on stdout\n", 32); + } + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/description b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/description new file mode 100644 index 00000000..5e8a8ec3 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/description @@ -0,0 +1 @@ +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". diff --git a/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/main.c b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/main.c new file mode 100644 index 00000000..f274e832 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-all-arguments-on-stdout/main.c @@ -0,0 +1,22 @@ +#include +#include + +int main(int argc, char **argv) +{ + if (argc >= 2) + { + argv++; + while (*argv) + { + write(1, *argv, strlen(*argv)); + write(1, "@", 1); + argv++; + } + write(1, "\n", 1); + } + else + { + write(1, "nothing to be written on stdout\n", 32); + } + return (0); +} diff --git a/42sh/42shelltest-tmp/support/write-on-stderr/Makefile b/42sh/42shelltest-tmp/support/write-on-stderr/Makefile new file mode 100644 index 00000000..a754e806 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stderr/Makefile @@ -0,0 +1,12 @@ +NAME=write_on_stderr +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/write-on-stderr/README.md b/42sh/42shelltest-tmp/support/write-on-stderr/README.md new file mode 100644 index 00000000..6a704fb8 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stderr/README.md @@ -0,0 +1,25 @@ +# ./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`. + +```c +#include +#include +#include + +int main(int argc, char **argv) +{ + if (argc > 1) + { + write(2, argv[1], strlen(argv[1])); + write(2, "\n", 1); + } + else + { + write(2, "write on stderr\n", 16); + } + if (argc == 3) + return (atoi(argv[2])); + return (1); +} +``` diff --git a/42sh/42shelltest-tmp/support/write-on-stderr/description b/42sh/42shelltest-tmp/support/write-on-stderr/description new file mode 100644 index 00000000..3095b703 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stderr/description @@ -0,0 +1 @@ +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`. diff --git a/42sh/42shelltest-tmp/support/write-on-stderr/main.c b/42sh/42shelltest-tmp/support/write-on-stderr/main.c new file mode 100644 index 00000000..2c917f48 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stderr/main.c @@ -0,0 +1,19 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + if (argc > 1) + { + write(2, argv[1], strlen(argv[1])); + write(2, "\n", 1); + } + else + { + write(2, "write on stderr\n", 16); + } + if (argc == 3) + return (atoi(argv[2])); + return (1); +} diff --git a/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/Makefile b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/Makefile new file mode 100644 index 00000000..d10c9daf --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/Makefile @@ -0,0 +1,12 @@ +NAME=write_on_stdout_and_stderr +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/README.md b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/README.md new file mode 100644 index 00000000..a0460a0d --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/README.md @@ -0,0 +1,25 @@ +# ./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". + +```c +#include +#include + +int main(int argc, char **argv) +{ + if (argc == 3) + { + write(1, argv[1], strlen(argv[1])); + write(1, "\n", 1); + write(2, argv[2], strlen(argv[2])); + write(2, "\n", 1); + } + else + { + write(1, "write on stdout\n", 16); + write(2, "write on stderr\n", 16); + } + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/description b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/description new file mode 100644 index 00000000..d5e369af --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/description @@ -0,0 +1 @@ +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/42shelltest-tmp/support/write-on-stdout-and-stderr/main.c b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/main.c new file mode 100644 index 00000000..96058cdc --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout-and-stderr/main.c @@ -0,0 +1,19 @@ +#include +#include + +int main(int argc, char **argv) +{ + if (argc == 3) + { + write(1, argv[1], strlen(argv[1])); + write(1, "\n", 1); + write(2, argv[2], strlen(argv[2])); + write(2, "\n", 1); + } + else + { + write(1, "write on stdout\n", 16); + write(2, "write on stderr\n", 16); + } + return (0); +} diff --git a/42sh/42shelltest-tmp/support/write-on-stdout/Makefile b/42sh/42shelltest-tmp/support/write-on-stdout/Makefile new file mode 100644 index 00000000..741b593b --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout/Makefile @@ -0,0 +1,12 @@ +NAME=write_on_stdout +TARGET_DIR=. + +$(NAME): all + +all: + gcc -Wall -Werror -Wextra main.c -o "$(TARGET_DIR)/$(NAME)" + +fclean: + rm -f "$(TARGET_DIR)/$(NAME)" + +re: fclean all diff --git a/42sh/42shelltest-tmp/support/write-on-stdout/README.md b/42sh/42shelltest-tmp/support/write-on-stdout/README.md new file mode 100644 index 00000000..978d1326 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout/README.md @@ -0,0 +1,22 @@ +# ./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". + +```c +#include +#include + +int main(int argc, char **argv) +{ + if (argc == 2) + { + write(1, argv[1], strlen(argv[1])); + write(1, "\n", 1); + } + else + { + write(1, "write on stdout\n", 16); + } + return (0); +} +``` diff --git a/42sh/42shelltest-tmp/support/write-on-stdout/description b/42sh/42shelltest-tmp/support/write-on-stdout/description new file mode 100644 index 00000000..69367f59 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout/description @@ -0,0 +1 @@ +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". diff --git a/42sh/42shelltest-tmp/support/write-on-stdout/main.c b/42sh/42shelltest-tmp/support/write-on-stdout/main.c new file mode 100644 index 00000000..eb342002 --- /dev/null +++ b/42sh/42shelltest-tmp/support/write-on-stdout/main.c @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char **argv) +{ + if (argc == 2) + { + write(1, argv[1], strlen(argv[1])); + write(1, "\n", 1); + } + else + { + write(1, "write on stdout\n", 16); + } + return (0); +} diff --git a/42sh/42shelltest-tmp/tasks/generate_readmes.sh b/42sh/42shelltest-tmp/tasks/generate_readmes.sh new file mode 100644 index 00000000..0f572155 --- /dev/null +++ b/42sh/42shelltest-tmp/tasks/generate_readmes.sh @@ -0,0 +1,181 @@ +#!/bin/bash + +GLOBAL_INSTALLDIR="$(pwd)" +GLOBAL_TMP_DIRECTORY="${GLOBAL_INSTALLDIR}/tmp" +GLOBAL_LOCALBRANCH=$(git branch | awk '$0 ~ /^\*/ {print $2; exit}') +GLOBAL_LIST_OF_TESTS= +GLOBAL_TOTAL_TESTS=0 +GLOBAL_SUPPORT_BINARIES_LIST="" +GLOBAL_SUPPORT_BINARIES_LIST2="" + +if [ "${GLOBAL_LOCALBRANCH}" != "master" ] +then + printf "%s\n" "Task error: must be run in master branch to ensure pull requests to keep clean" + exit 1 +fi + +if [ -f "./tasks/${BASH_SOURCE[0]}" ] +then + printf "%s\n" "Task error: must be run from install directory" + exit 1 +fi + +run_create_support_binaries_readme() +{ + local SUPPORT_FILE + local README + local SUPPORT_FILE_NAME + + for SUPPORT_FILE in ./support/* + do + if [ -d "${SUPPORT_FILE}" ] + then + + README="${SUPPORT_FILE}/README.md" + SUPPORT_MAIN="${SUPPORT_FILE}/main.c" + SUPPORT_DESCRIPTION="${SUPPORT_FILE}/description" + SUPPORT_DIR_NAME="${SUPPORT_FILE##*/}" + SUPPORT_BINARY_NAME="${SUPPORT_DIR_NAME//-/_}" + + printf "# %s\n\n" "./${SUPPORT_BINARY_NAME}" >"${README}" + [ -f "${SUPPORT_DESCRIPTION}" ] && printf "%s\n\n" "$(cat "${SUPPORT_DESCRIPTION}")" >>"${README}" + printf "\`\`\`c\n%s\n\`\`\`\n" "$(cat "${SUPPORT_MAIN}")" >>"${README}" + + GLOBAL_SUPPORT_BINARIES_LIST="$(printf "%s\n%s" "${GLOBAL_SUPPORT_BINARIES_LIST}" "* **[./${SUPPORT_BINARY_NAME}](http://github.com/we-sh/42ShellTester/tree/master/support/${SUPPORT_DIR_NAME})** -> $(cat "${SUPPORT_DESCRIPTION}")")" + GLOBAL_SUPPORT_BINARIES_LIST2="${GLOBAL_SUPPORT_BINARIES_LIST2}\n\052 **[./${SUPPORT_BINARY_NAME}](http://github.com/we-sh/42ShellTester/tree/master/support/${SUPPORT_DIR_NAME})**: $(cat "${SUPPORT_DESCRIPTION}")" + + fi + done +} + +run_create_support_binaries_readme + +run_create_readme() +{ + local INDEX="${1}" + local TEST="${2}" + local TEST_NAME="${TEST##*/}" + local TEST_FULLNAME="${TEST##*spec/}" + local PARENT_DIR_NAME="${TEST%/*}" + local README="${TEST}/README.md" + + (( GLOBAL_TOTAL_TESTS= GLOBAL_TOTAL_TESTS + 1 )) + + printf "# %s\n\n" "${TEST_NAME}" >"${README}" + printf "*[%s](%s) > %s*\n\n" "${PARENT_DIR_NAME//\// > }" ".." "${DIR_NAME}" >>"${README}" + + if [ -f "${TEST}/description" ]; then cat "${TEST}/description" >>"${README}"; fi + + if [ -f "${TEST}/before_exec" ] + then + printf "### What is done before test\n\n\`\`\`bash\n" >>"${README}" + cat "${TEST}/before_exec" >>"${README}" + printf "\n\`\`\`\n\n" >>"${README}" + fi + + printf "### Shell commands that are sent to the standard entry\n\n\`\`\`bash\n" >>"${README}" + cat "${TEST}/stdin" >>"${README}" + printf "\n\`\`\`\n\n" >>"${README}" + + if [ -f "${TEST}/stdout" ] + then + printf "### What is expected on standard output\n\n\`\`\`bash\n" >>"${README}" + cat "${TEST}/stdout" >>"${README}" + printf "\n\`\`\`\n\n" >>"${README}" + fi + + if [ -f "${TEST}/stderr" ] + then + printf "### What is expected on error output\n\n\`\`\`bash\n" >>"${README}" + cat "${TEST}/stderr" >>"${README}" + printf "\n\`\`\`\n\n" >>"${README}" + fi + + if [ -f "${TEST}/misc" ] + then + printf "### What miscellaneous behaviors are expected\n\n\`\`\`bash\n" >>"${README}" + cat "${TEST}/misc" >>"${README}" + printf "\n\`\`\`\n\n" >>"${README}" + fi + + printf "### Variables\n\nThe following variables may appear in this test:\n\n" >>"${README}" + printf "* \${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester\n" >>"${README}" + printf "* \${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed\n" >>"${README}" + printf "* \${**GLOBAL_TOKEN**} -> A token that changes value at launch time\n" >>"${README}" + printf "* \${**PATH**} -> The standard environment variable PATH\n" >>"${README}" + printf "* \${**HOME**} -> The standard environment variable HOME\n\n" >>"${README}" + + printf "### Support binaries\n\nThe following binaries may appear in this test:\n\n%s\n" "${GLOBAL_SUPPORT_BINARIES_LIST}" >>"${README}" +} + +run_browse_directory() +{ + local -i INDEX=${1} + local DIR="${2}" + local DIR_NAME="${DIR##*/}" + local DIR_FULLNAME="${DIR##*spec/}" + local PARENT_DIR_NAME="${DIR%/*}" + local README="${DIR}/README.md" + local SUBDIR + local IMGS="" + + if [ -f "${DIR}/stdin" ] + then + [ -f "${DIR}/non-posix" ] && IMGS=" " + [ -f "${DIR}/hard" ] && IMGS="${IMGS} " + [ -f "${DIR}/pending" ] && IMGS="${IMGS} " + GLOBAL_LIST_OF_TESTS="${GLOBAL_LIST_OF_TESTS}$(printf "% $(( INDEX * 2 ))s\052 [%s](%s)" "" "${DIR_NAME}${IMGS}" "${DIR}")\n" + run_create_readme "${INDEX}" "${DIR}" + else + + [ "${INDEX}" != "-1" ] && GLOBAL_LIST_OF_TESTS="${GLOBAL_LIST_OF_TESTS}$(printf "% $(( INDEX * 2 ))s\052 **[%s/](%s)**" "" "${DIR_NAME}" "${DIR}")\n" + + printf "# %s\n\n" "${DIR_NAME}" >"${README}" + [ "${INDEX}" != "-1" ] && printf "*[%s](%s) > %s*\n\n" "${PARENT_DIR_NAME//\// > }" ".." "${DIR_NAME}" >>"${README}" + + for SUBDIR in $(ls -1 "${DIR}") + do + if [ -d "${DIR}/${SUBDIR}" ] + then + printf "\052 [%s](%s)\n" "${SUBDIR}" "./${SUBDIR}" >>"${README}" + run_browse_directory "$(( INDEX + 1 ))" "${DIR}/${SUBDIR}" + fi + done + + fi +} + +run_browse_directory -1 "spec" + +awk -v SUPPORT_BINARIES_LIST="${GLOBAL_SUPPORT_BINARIES_LIST2}\n" -v LIST="${GLOBAL_LIST_OF_TESTS}" -v GLOBAL_TOTAL_TESTS="${GLOBAL_TOTAL_TESTS}" ' +BEGIN { + INSERT_DATA=0 +} +INSERT_DATA == 0 { + print +} +$0 ~ // { + INSERT_DATA=1; + print "42ShellTester is currently packaged with **"GLOBAL_TOTAL_TESTS" tests**." +} +$0 ~ // { + INSERT_DATA=0; + print +} +$0 ~ // { + INSERT_DATA=1; + print SUPPORT_BINARIES_LIST +} +$0 ~ // { + INSERT_DATA=0; + print +} +$0 ~ // { + INSERT_DATA=1; + print LIST +} +$0 ~ // { + INSERT_DATA=0; + print +} +' README.md > README.new.md && rm -f README.md && mv README.new.md README.md