Skip to content

Instantly share code, notes, and snippets.

@liaujianjie
Last active January 31, 2018 12:40
Show Gist options
  • Save liaujianjie/2472f9ed6d513ffa266b90fbf495706c to your computer and use it in GitHub Desktop.
Save liaujianjie/2472f9ed6d513ffa266b90fbf495706c to your computer and use it in GitHub Desktop.
Runs the tests for your CS1010 test cases
echo "Running $2 test cases for $1...\n\n"
for i in $(seq $2);
do echo "========== TEST CASE $i"
./a.out < $1$i.in > $1$i.out.actual
diff $1$i.out $1$i.out.actual
rm $1$i.out.actual;
done
@liaujianjie
Copy link
Author

liaujianjie commented Nov 3, 2017

What is this

Lets you run all your test cases iteratively in a single command like this: ./test.sh wowdoge 6

If pass all test cases:

$ ./test.sh modules 4
Running 4 test cases for modules...


========== TEST CASE 1
========== TEST CASE 2
========== TEST CASE 3
========== TEST CASE 4

If fail some test cases:

$ ./test.sh modules 4
Running 4 test cases for modules...


========== TEST CASE 1
2c2
< Choose a module: Prerequisites for CX3110: CX2010 CX1010
---
> Choose a module: No prerequisites for CX3110
========== TEST CASE 2
========== TEST CASE 3
2c2
< Choose a module: Prerequisites for CX3311: CX2101
---
> Choose a module: No prerequisites for CX3311
========== TEST CASE 4

✨✨✨✨✨ tested on sunfire ✨✨✨✨✨

Feel free to share with anyone.

How to install

  1. Copy and paste into your working directory as test.sh (yes, write/print this and bring it in and type it out in your PE)
  2. Run chmod u+x test.sh (this gives the script permission to manipulate files)

How to use

  1. Build your program with the default output file name a.out ⚠️ IMPORTANT: do not forget to build your app
  2. Ensure you are in your working directory
  3. Run ./test.sh <test_case_name> <test_case_count>

For example, if your test case file is sudoku1.in/sudoku1.out and you have 4 test cases, then you should use this:
./test.sh sudoku 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment