Skip to content

Commit

Permalink
add tests invalid patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
jgigault committed Jan 20, 2017
1 parent 4143f2b commit 7dac9d3
Show file tree
Hide file tree
Showing 32 changed files with 278 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@
It brings you an easy way to **add**, **maintain** and **run** integration tests, helping you to work step by step on your Shell implementation.

<!--START_TOTAL_TESTS-->
42ShellTester is currently packaged with **273 tests**.
42ShellTester is currently packaged with **277 tests**.
<!--END_TOTAL_TESTS-->

## Install
Expand Down Expand Up @@ -173,6 +173,11 @@ Also display tests that succeed (hidden by default).
* [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)
Expand Down
1 change: 1 addition & 0 deletions spec/42sh/globbing/brace-expansion/README.md
Expand Up @@ -3,5 +3,6 @@
*[spec > 42sh > globbing](..) > brace-expansion*

* [ascii-range](./ascii-range)
* [errors](./errors)
* [list-of-values](./list-of-values)
* [numeric-range](./numeric-range)
@@ -0,0 +1,59 @@
# 001-invalid-pattern-1

*[spec > 42sh > globbing > brace-expansion > errors](..) > 001-invalid-pattern-1*

The purpose of this test is to check that invalid braces expansion patterns does not result in error.
### Shell commands that are sent to the standard entry

```bash
./write_on_stdout {A}

```

### What is expected on standard output

```bash
expected_to match_regex "^{A}$"

```

### What is expected on error output

```bash
expected_to be_empty

```

### What miscellaneous behaviors are expected

```bash
expected_to exit_with_status "0"

```

### Variables

The following variables may appear in this test:

* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME

### Support binaries

The following binaries may appear in this test:


* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".
@@ -0,0 +1 @@
The purpose of this test is to check that invalid braces expansion patterns does not result in error.
@@ -0,0 +1 @@
expected_to exit_with_status "0"
@@ -0,0 +1 @@
expected_to be_empty
@@ -0,0 +1 @@
./write_on_stdout {A}
@@ -0,0 +1 @@
expected_to match_regex "^{A}$"
@@ -0,0 +1,59 @@
# 002-invalid-pattern-2

*[spec > 42sh > globbing > brace-expansion > errors](..) > 002-invalid-pattern-2*

The purpose of this test is to check that invalid braces expansion patterns does not result in error.
### Shell commands that are sent to the standard entry

```bash
./write_on_stdout {B..}

```

### What is expected on standard output

```bash
expected_to match_regex "^{B..}$"

```

### What is expected on error output

```bash
expected_to be_empty

```

### What miscellaneous behaviors are expected

```bash
expected_to exit_with_status "0"

```

### Variables

The following variables may appear in this test:

* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME

### Support binaries

The following binaries may appear in this test:


* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".
@@ -0,0 +1 @@
The purpose of this test is to check that invalid braces expansion patterns does not result in error.
@@ -0,0 +1 @@
expected_to exit_with_status "0"
@@ -0,0 +1 @@
expected_to be_empty
@@ -0,0 +1 @@
./write_on_stdout {B..}
@@ -0,0 +1 @@
expected_to match_regex "^{B..}$"
@@ -0,0 +1,59 @@
# 003-invalid-pattern-3

*[spec > 42sh > globbing > brace-expansion > errors](..) > 003-invalid-pattern-3*

The purpose of this test is to check that invalid braces expansion patterns does not result in error.
### Shell commands that are sent to the standard entry

```bash
./write_on_stdout {..C}

```

### What is expected on standard output

```bash
expected_to match_regex "^{..C}$"

```

### What is expected on error output

```bash
expected_to be_empty

```

### What miscellaneous behaviors are expected

```bash
expected_to exit_with_status "0"

```

### Variables

The following variables may appear in this test:

* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME

### Support binaries

The following binaries may appear in this test:


* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".
@@ -0,0 +1 @@
The purpose of this test is to check that invalid braces expansion patterns does not result in error.
@@ -0,0 +1 @@
expected_to exit_with_status "0"
@@ -0,0 +1 @@
expected_to be_empty
@@ -0,0 +1 @@
./write_on_stdout {..C}
@@ -0,0 +1 @@
expected_to match_regex "^{..C}$"
@@ -0,0 +1,59 @@
# 004-invalid-pattern-4

*[spec > 42sh > globbing > brace-expansion > errors](..) > 004-invalid-pattern-4*

The purpose of this test is to check that invalid braces expansion patterns does not result in error.
### Shell commands that are sent to the standard entry

```bash
./write_on_stdout {Q..C..1}

```

### What is expected on standard output

```bash
expected_to match_regex "^{Q..C..1}$"

```

### What is expected on error output

```bash
expected_to be_empty

```

### What miscellaneous behaviors are expected

```bash
expected_to exit_with_status "0"

```

### Variables

The following variables may appear in this test:

* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester
* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed
* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time
* ${**PATH**} -> The standard environment variable PATH
* ${**HOME**} -> The standard environment variable HOME

### Support binaries

The following binaries may appear in this test:


* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output.
* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput.
* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`.
* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument.
* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error.
* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument.
* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL.
* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout".
* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`.
* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout".
* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr".
@@ -0,0 +1 @@
The purpose of this test is to check that invalid braces expansion patterns does not result in error.
@@ -0,0 +1 @@
expected_to exit_with_status "0"
@@ -0,0 +1 @@
expected_to be_empty
@@ -0,0 +1 @@
./write_on_stdout {Q..C..1}
@@ -0,0 +1 @@
expected_to match_regex "^{Q..C..1}$"
8 changes: 8 additions & 0 deletions spec/42sh/globbing/brace-expansion/errors/README.md
@@ -0,0 +1,8 @@
# errors

*[spec > 42sh > globbing > brace-expansion](..) > errors*

* [001-invalid-pattern-1](./001-invalid-pattern-1)
* [002-invalid-pattern-2](./002-invalid-pattern-2)
* [003-invalid-pattern-3](./003-invalid-pattern-3)
* [004-invalid-pattern-4](./004-invalid-pattern-4)
3 changes: 2 additions & 1 deletion support/display-env/README.md
Expand Up @@ -9,8 +9,9 @@ A binary that iterates on `**envp` and write each element on standard output.

int main(int argc, char **argv, char **envp)
{
int i = 0;
int i;

i = 0;
(void)argc;
(void)argv;
write(1, "------------------------------\n", 31);
Expand Down
2 changes: 1 addition & 1 deletion support/display-program-name/README.md
Expand Up @@ -6,7 +6,7 @@ A binary that writes its name on standard ouput.
#include <unistd.h>
#include <string.h>

int main(int ac,char **av)
int main(int ac, char **av)
{
(void)ac;
write(1, av[0], strlen(av[0]));
Expand Down
3 changes: 2 additions & 1 deletion support/display-pwd/README.md
Expand Up @@ -8,7 +8,8 @@ A binary that writes on standard output the absolute path of the current directo

int main(void)
{
char *pwd;
char *pwd;

pwd = getcwd(NULL, 0);
write(1, "PWD:", 4);
write(1, pwd, strlen(pwd));
Expand Down
2 changes: 1 addition & 1 deletion support/sleep-and-write-on-stderr/README.md
Expand Up @@ -9,7 +9,7 @@ A binary that sleeps for a duration in seconds given as first argument and then

int main(int argc, char **argv)
{
int seconds
int seconds;

seconds = 1;
if (argc > 1)
Expand Down
2 changes: 1 addition & 1 deletion support/write-all-arguments-on-stdout/README.md
Expand Up @@ -11,7 +11,7 @@ int main(int argc, char **argv)
if (argc >= 2)
{
argv++;
while(*argv)
while (*argv)
{
write(1, *argv, strlen(*argv));
write(1, "@", 1);
Expand Down

0 comments on commit 7dac9d3

Please sign in to comment.