Skip to content

Commit

Permalink
Merge pull request #79 from ErwannLesech/tests_step2
Browse files Browse the repository at this point in the history
test<test_step2>: new tests on double quote and variable
  • Loading branch information
ErwannLesech authored Jan 20, 2024
2 parents 20bca62 + 0534b88 commit 3205265
Show file tree
Hide file tree
Showing 38 changed files with 85 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main(int argc, char **argv)
{
errx(1, "Error while creating lexer");
}

int val = parser_loop(lexer, pretty_print_enabled);
if (val == 2)
{
Expand Down
1 change: 1 addition & 0 deletions tests/quote/double_quote/double_quote10.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=1;echo "$a\"$a"
1 change: 1 addition & 0 deletions tests/quote/double_quote/double_quote11.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "Special characters: !@#%$^&*()"
1 change: 1 addition & 0 deletions tests/quote/double_quote/double_quote12.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bb=1; echo "$ddd\""
1 change: 1 addition & 0 deletions tests/quote/double_quote/double_quote5.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=1;echo "$a\""
1 change: 1 addition & 0 deletions tests/quote/double_quote/double_quote6.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=1;echo "idiej$a:jodejoj" "$a" "dikefok"'
1 change: 1 addition & 0 deletions tests/quote/double_quote/double_quote7.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=1;echo "lpikopo"pojo^é$
4 changes: 4 additions & 0 deletions tests/quote/double_quote/double_quote8.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a=1;echo "lpikopo\


"
1 change: 1 addition & 0 deletions tests/quote/double_quote/double_quote9.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=1;echo "lpikopo\$$\$$\\$\$\*\\*\\\*\*\\***\ "
10 changes: 9 additions & 1 deletion tests/quote/double_quote/testsuite.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
run_test double_quote1.test
run_test double_quote2.test
run_test double_quote3.test
run_test double_quote4.test
run_test double_quote4.test
run_test double_quote5.test
run_test double_quote6.test
run_test double_quote7.test
run_test double_quote8.test
run_test double_quote9.test
run_test double_quote10.test
run_test double_quote11.test
run_test double_quote12.test
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error1.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bb=1; echo "$bb
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error2.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bb=1; echo "$ddd\"
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error3.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tata=1; echo "${tata}
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error4.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tata=1; echo "${tata}\"
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error5.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tata=1; echo "${tata"
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error6.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tata=1; echo "$
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error7.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tata=1; echo "$lff
1 change: 1 addition & 0 deletions tests/quote/double_quote_error/double_quote_error8.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tata=1; echo \"${tata}"
8 changes: 8 additions & 0 deletions tests/quote/double_quote_error/testsuite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
run_test double_quote_error1.test
run_test double_quote_error2.test
run_test double_quote_error3.test
run_test double_quote_error4.test
run_test double_quote_error5.test
run_test double_quote_error6.test
run_test double_quote_error7.test
run_test double_quote_error8.test
4 changes: 2 additions & 2 deletions tests/quote/single_quote_error/testsuite.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run_test single_quote_error1.test
run_test single_quote_error2.test
run_test single_quote_error3.test
run_test single_quote_errorMouli1.test
run_test single_quote_errorMouli2.test
run_test single_quoteMouli1.test
run_test single_quoteMouli2.test
5 changes: 5 additions & 0 deletions tests/redirections/redir_&input/complex1.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
echo 'hello' > input.txt
ls > output.txt 2<&1 < input.txt
cat output.txt
cat input.txt
rm input.txt output.txt
3 changes: 2 additions & 1 deletion tests/redirections/redir_&input/testsuite.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
run_test simple1.test
run_test simple1.test
run_test complex1.test
3 changes: 3 additions & 0 deletions tests/redirections/redir_&output/error1.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
t 2>& file;
cat file
rm file
5 changes: 5 additions & 0 deletions tests/redirections/redir_&output/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1
3
2
7
0
6 changes: 3 additions & 3 deletions tests/redirections/redir_&output/simple2.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
t 2>& file;
cat file
rm file
ls -l non_existent_directory >& output_and_error.txt
if [ -s output_and_error.txt ]; then echo tata; fi
rm -f output_and_error.txt
8 changes: 8 additions & 0 deletions tests/redirections/redir_&output/simple4.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
echo '1
3
2
7
0' > input.txt
sort < input.txt >& sorted_output.txt
cat sorted_output.txt
rm input.txt sorted_output.txt
3 changes: 2 additions & 1 deletion tests/redirections/redir_&output/testsuite.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
run_test simple1.test
run_test simple2.test
run_test simple3.test
run_test simple3.test
run_test error1.test
1 change: 1 addition & 0 deletions tests/redirections/redir_input/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello
4 changes: 3 additions & 1 deletion tests/redirections/redir_input/simple1.test
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ls < file.txt
echo 'hello' > file.txt
ls < file.txt
rm file.txt
4 changes: 4 additions & 0 deletions tests/redirections/redir_output/double_redir.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ls -l non_existent_directory 1> success.txt 2> error.txt; echo tata
cat success.txt
if [ -s error.txt ]; then echo tata;fi
rm success.txt error.txt
1 change: 1 addition & 0 deletions tests/redirections/redir_output/simple2.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
wrong_command 2>file
if [ -s error.txt ]; then echo tata;fi
# cat file --> working but not the same stderr message
rm file
3 changes: 2 additions & 1 deletion tests/redirections/redir_output/testsuite.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
run_test simple1.test
run_test simple2.test
run_test simple2.test
run_test double_redir.test
1 change: 1 addition & 0 deletions tests/variable/variable/condition_variable2.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=true; if $a; then echo atat;fi
1 change: 1 addition & 0 deletions tests/variable/variable/testsuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ run_test simple_variable6.test
run_test simple_variable7.test
run_test simple_variable8.test
run_test condition_variable1.test
run_test condition_variable2.test
run_test environment_variable.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a=1; if $a; then echo atat;fi
1 change: 1 addition & 0 deletions tests/variable/variable_error/simple_error_variable3.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$1 ${a} ${b} b=2; b=1; echo ${b}
4 changes: 3 additions & 1 deletion tests/variable/variable_error/testsuite.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
run_test while_variable_error1.test
run_test simple_error_variable1.test
run_test simple_error_variable2.test
run_test simple_error_variable2.test
run_test simple_error_variable3.test
run_test conditional_variable_error1.test

0 comments on commit 3205265

Please sign in to comment.