From 1b7857bc253640422965619cd83242bafb2dcd1a Mon Sep 17 00:00:00 2001 From: Akshar Patel Date: Wed, 27 Mar 2024 17:43:21 +0000 Subject: [PATCH] fix: run tests anywhere, and fix ABC test Tests can now be ran no matter where you are located. ABC now checks against two different expected outputs. --- * Closes #10 --- --- ABC/tests/bear-fuzzy-wuzzy/ABC.expected2 | 6 ++++++ ABC/tests/bear-fuzzy-wuzzy/ABCtest.bats | 4 +++- ARRAY/tests/recursive/ARRAYtest.bats | 1 + BF/tests/random/BFtest.bats | 1 + CHAR/tests/random/CHARtest.bats | 1 + GINGER/tests/ginger/GINGERtest.bats | 1 + HANDLER/tests/list/HANDLERtest.bats | 1 + INFIX/tests/add_and_multiply/INFIXtest.bats | 3 ++- LAMBDA/tests/random/LAMBDAtest.bats | 1 + LAMBDAQ/tests/free/LAMBDAQtest.bats | 1 + LIST/tests/chooser/LISTtest.bats | 1 + LON/tests/parse/LONtest.bats | 1 + LON2/tests/print/LON2test.bats | 1 + LONN/tests/min/LONNtest.bats | 3 ++- NAME/tests/let-proc/NAMEtest.bats | 1 + NEED/tests/let/NEEDtest.bats | 1 + OBJ/tests/class/OBJtest.bats | 1 + PROP/tests/class-property/PROPtest.bats | 1 + RANDSCONT/tests/letrec/RANDSCONTtest.bats | 1 + REF/tests/let/REFtest.bats | 1 + REFCONT/tests/odd_even/REFCONTtest.bats | 1 + SET/tests/let/SETtest.bats | 1 + THREADCONT/tests/concurrent/THREADCONTtest.bats | 1 + TYPE0/tests/boolean/TYPE0test.bats | 1 + TYPE1/tests/proc-types/TYPE1test.bats | 1 + V0/tests/nested-prims/V0test.bats | 1 + V1/tests/nested-prims/V1test.bats | 1 + V2/tests/nested-ifs/V2test.bats | 1 + V3/tests/let/V3test.bats | 1 + V4/tests/proc/V4test.bats | 1 + V5/tests/letrec/V5test.bats | 1 + V6/tests/define/V6test.bats | 1 + bin/test.bash | 4 ++++ 33 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 ABC/tests/bear-fuzzy-wuzzy/ABC.expected2 diff --git a/ABC/tests/bear-fuzzy-wuzzy/ABC.expected2 b/ABC/tests/bear-fuzzy-wuzzy/ABC.expected2 new file mode 100644 index 0000000..2504d3b --- /dev/null +++ b/ABC/tests/bear-fuzzy-wuzzy/ABC.expected2 @@ -0,0 +1,6 @@ + + +2 matches: +bear(fuzzy) +bear(wuzzy) + diff --git a/ABC/tests/bear-fuzzy-wuzzy/ABCtest.bats b/ABC/tests/bear-fuzzy-wuzzy/ABCtest.bats index 40e00ee..90832ef 100644 --- a/ABC/tests/bear-fuzzy-wuzzy/ABCtest.bats +++ b/ABC/tests/bear-fuzzy-wuzzy/ABCtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd ABC plcc grammar javac -cp abcdatalog.jar Java/*.java @@ -14,5 +15,6 @@ teardown() { @test "ABC bear-fuzzy-wuzzy" { RESULT="$(java -cp abcdatalog.jar:Java Rep -n < ./tests/bear-fuzzy-wuzzy/ABC.input)" expected_output=$(< "./tests/bear-fuzzy-wuzzy/ABC.expected") - [[ "$RESULT" == "$expected_output" ]] + expected_output2=$(< "./tests/bear-fuzzy-wuzzy/ABC.expected2") + [[ "$RESULT" == "$expected_output" || "$RESULT" == "$expected_output2" ]] } diff --git a/ARRAY/tests/recursive/ARRAYtest.bats b/ARRAY/tests/recursive/ARRAYtest.bats index ddd9773..b256a70 100644 --- a/ARRAY/tests/recursive/ARRAYtest.bats +++ b/ARRAY/tests/recursive/ARRAYtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd ARRAY plccmk -c grammar > /dev/null } diff --git a/BF/tests/random/BFtest.bats b/BF/tests/random/BFtest.bats index 4e9d85e..57dee17 100644 --- a/BF/tests/random/BFtest.bats +++ b/BF/tests/random/BFtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd BF plccmk -c grammar > /dev/null } diff --git a/CHAR/tests/random/CHARtest.bats b/CHAR/tests/random/CHARtest.bats index f6e4086..833b74e 100644 --- a/CHAR/tests/random/CHARtest.bats +++ b/CHAR/tests/random/CHARtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd CHAR plccmk -c grammar > /dev/null } diff --git a/GINGER/tests/ginger/GINGERtest.bats b/GINGER/tests/ginger/GINGERtest.bats index 27cbdb4..faef427 100644 --- a/GINGER/tests/ginger/GINGERtest.bats +++ b/GINGER/tests/ginger/GINGERtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd GINGER plccmk -c grammar > /dev/null } diff --git a/HANDLER/tests/list/HANDLERtest.bats b/HANDLER/tests/list/HANDLERtest.bats index 34f9744..c3b2127 100644 --- a/HANDLER/tests/list/HANDLERtest.bats +++ b/HANDLER/tests/list/HANDLERtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd HANDLER plccmk -c grammar > /dev/null } diff --git a/INFIX/tests/add_and_multiply/INFIXtest.bats b/INFIX/tests/add_and_multiply/INFIXtest.bats index 216f7e8..fdaa059 100644 --- a/INFIX/tests/add_and_multiply/INFIXtest.bats +++ b/INFIX/tests/add_and_multiply/INFIXtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd INFIX plccmk -c grammar > /dev/null } @@ -11,7 +12,7 @@ teardown() { } @test "INFIX add_and_multiply" { - skip "Doesn't behave like we expect. Help please!" + skip "Intentionally not implemented" RESULT="$(rep -n < ./tests/add_and_multiply/INFIX.input)" expected_output=$(< "./tests/add_and_multiply/INFIX.expected") diff --git a/LAMBDA/tests/random/LAMBDAtest.bats b/LAMBDA/tests/random/LAMBDAtest.bats index 6ad7b1d..f8131d5 100644 --- a/LAMBDA/tests/random/LAMBDAtest.bats +++ b/LAMBDA/tests/random/LAMBDAtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd LAMBDA plccmk -c grammar > /dev/null } diff --git a/LAMBDAQ/tests/free/LAMBDAQtest.bats b/LAMBDAQ/tests/free/LAMBDAQtest.bats index 14cc637..626f30b 100644 --- a/LAMBDAQ/tests/free/LAMBDAQtest.bats +++ b/LAMBDAQ/tests/free/LAMBDAQtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd LAMBDAQ plccmk -c grammar > /dev/null } diff --git a/LIST/tests/chooser/LISTtest.bats b/LIST/tests/chooser/LISTtest.bats index d6957ef..95190ab 100644 --- a/LIST/tests/chooser/LISTtest.bats +++ b/LIST/tests/chooser/LISTtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd LIST plccmk -c grammar > /dev/null } diff --git a/LON/tests/parse/LONtest.bats b/LON/tests/parse/LONtest.bats index 82c6d07..59cc358 100644 --- a/LON/tests/parse/LONtest.bats +++ b/LON/tests/parse/LONtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd LON plccmk -c grammar > /dev/null } diff --git a/LON2/tests/print/LON2test.bats b/LON2/tests/print/LON2test.bats index 4b5315c..b17d262 100644 --- a/LON2/tests/print/LON2test.bats +++ b/LON2/tests/print/LON2test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd LON2 plccmk -c grammar > /dev/null } diff --git a/LONN/tests/min/LONNtest.bats b/LONN/tests/min/LONNtest.bats index 66ed2af..cbd5b63 100644 --- a/LONN/tests/min/LONNtest.bats +++ b/LONN/tests/min/LONNtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd LONN plccmk -c grammar > /dev/null } @@ -11,7 +12,7 @@ teardown() { } @test "LONN min" { - skip "Language not implemented minimun number is always 0" + skip "Intentionally not implemented" RESULT="$(rep -n < ./tests/min/LONN.input)" expected_output=$(< "./tests/min/LONN.expected") diff --git a/NAME/tests/let-proc/NAMEtest.bats b/NAME/tests/let-proc/NAMEtest.bats index 8b59c2a..26b2ed0 100644 --- a/NAME/tests/let-proc/NAMEtest.bats +++ b/NAME/tests/let-proc/NAMEtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd NAME plccmk -c grammar > /dev/null } diff --git a/NEED/tests/let/NEEDtest.bats b/NEED/tests/let/NEEDtest.bats index 673c69d..cb863ca 100644 --- a/NEED/tests/let/NEEDtest.bats +++ b/NEED/tests/let/NEEDtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd NEED plccmk -c grammar > /dev/null } diff --git a/OBJ/tests/class/OBJtest.bats b/OBJ/tests/class/OBJtest.bats index 799b8c4..b4daf5e 100644 --- a/OBJ/tests/class/OBJtest.bats +++ b/OBJ/tests/class/OBJtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd OBJ plccmk -c grammar > /dev/null } diff --git a/PROP/tests/class-property/PROPtest.bats b/PROP/tests/class-property/PROPtest.bats index 2a1c5fa..7ea0b95 100644 --- a/PROP/tests/class-property/PROPtest.bats +++ b/PROP/tests/class-property/PROPtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd PROP plccmk -c grammar > /dev/null } diff --git a/RANDSCONT/tests/letrec/RANDSCONTtest.bats b/RANDSCONT/tests/letrec/RANDSCONTtest.bats index 239d9c2..2c4dc11 100644 --- a/RANDSCONT/tests/letrec/RANDSCONTtest.bats +++ b/RANDSCONT/tests/letrec/RANDSCONTtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd RANDSCONT plccmk -c grammar > /dev/null } diff --git a/REF/tests/let/REFtest.bats b/REF/tests/let/REFtest.bats index f568d19..927cb6b 100644 --- a/REF/tests/let/REFtest.bats +++ b/REF/tests/let/REFtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd REF plccmk -c grammar > /dev/null } diff --git a/REFCONT/tests/odd_even/REFCONTtest.bats b/REFCONT/tests/odd_even/REFCONTtest.bats index f36b7b2..15f7e6e 100644 --- a/REFCONT/tests/odd_even/REFCONTtest.bats +++ b/REFCONT/tests/odd_even/REFCONTtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd REFCONT plccmk -c grammar > /dev/null } diff --git a/SET/tests/let/SETtest.bats b/SET/tests/let/SETtest.bats index 025791a..2261743 100644 --- a/SET/tests/let/SETtest.bats +++ b/SET/tests/let/SETtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd SET plccmk -c grammar > /dev/null } diff --git a/THREADCONT/tests/concurrent/THREADCONTtest.bats b/THREADCONT/tests/concurrent/THREADCONTtest.bats index 2ee8218..d4768eb 100644 --- a/THREADCONT/tests/concurrent/THREADCONTtest.bats +++ b/THREADCONT/tests/concurrent/THREADCONTtest.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd THREADCONT plccmk -c grammar > /dev/null } diff --git a/TYPE0/tests/boolean/TYPE0test.bats b/TYPE0/tests/boolean/TYPE0test.bats index 97e70ed..bebe866 100644 --- a/TYPE0/tests/boolean/TYPE0test.bats +++ b/TYPE0/tests/boolean/TYPE0test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd TYPE0 plccmk -c grammar > /dev/null } diff --git a/TYPE1/tests/proc-types/TYPE1test.bats b/TYPE1/tests/proc-types/TYPE1test.bats index 75db449..e8e1ea4 100644 --- a/TYPE1/tests/proc-types/TYPE1test.bats +++ b/TYPE1/tests/proc-types/TYPE1test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd TYPE1 plccmk -c grammar > /dev/null } diff --git a/V0/tests/nested-prims/V0test.bats b/V0/tests/nested-prims/V0test.bats index e99124b..d7e1ca8 100644 --- a/V0/tests/nested-prims/V0test.bats +++ b/V0/tests/nested-prims/V0test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd V0 plccmk -c grammar > /dev/null } diff --git a/V1/tests/nested-prims/V1test.bats b/V1/tests/nested-prims/V1test.bats index 9a748a4..4250fb9 100644 --- a/V1/tests/nested-prims/V1test.bats +++ b/V1/tests/nested-prims/V1test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd V1 plccmk -c grammar > /dev/null } diff --git a/V2/tests/nested-ifs/V2test.bats b/V2/tests/nested-ifs/V2test.bats index 6ff8dc1..7ce0855 100644 --- a/V2/tests/nested-ifs/V2test.bats +++ b/V2/tests/nested-ifs/V2test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd V2 plccmk -c grammar > /dev/null } diff --git a/V3/tests/let/V3test.bats b/V3/tests/let/V3test.bats index 2220949..00d5499 100644 --- a/V3/tests/let/V3test.bats +++ b/V3/tests/let/V3test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd V3 plccmk -c grammar > /dev/null } diff --git a/V4/tests/proc/V4test.bats b/V4/tests/proc/V4test.bats index 65dafed..955ec63 100644 --- a/V4/tests/proc/V4test.bats +++ b/V4/tests/proc/V4test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd V4 plccmk -c grammar > /dev/null } diff --git a/V5/tests/letrec/V5test.bats b/V5/tests/letrec/V5test.bats index dd248b6..2341bbc 100644 --- a/V5/tests/letrec/V5test.bats +++ b/V5/tests/letrec/V5test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd V5 plccmk -c grammar > /dev/null } diff --git a/V6/tests/define/V6test.bats b/V6/tests/define/V6test.bats index b3971eb..19aa520 100644 --- a/V6/tests/define/V6test.bats +++ b/V6/tests/define/V6test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + cd "$(git rev-parse --show-toplevel)" cd V6 plccmk -c grammar > /dev/null } diff --git a/bin/test.bash b/bin/test.bash index 2ec99cb..c90f0c8 100755 --- a/bin/test.bash +++ b/bin/test.bash @@ -1,3 +1,7 @@ #!/usr/bin/env bash +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +PROJECT_ROOT="$( cd "${SCRIPT_DIR}/.." &> /dev/null && pwd )" +cd "${PROJECT_ROOT}" + bats --recursive .