So let's say you messed up on a test case. That doesn't really say much.
There are two things you can do:
Method 1: Compare your output with the solution output
When you run
gradescript
, it generates files in the following format:
Files
tmp-???-test-stdout.txt
tmp-???-test-stderr.txt
tmp-???-correct-stdout.txt
tmp-???-correct-stderr.txt
The
??? is replaced with the number of the test case you just ran.
You can compare your output to the solution's output in 2 ways (there are more but let's keep it simple).
Diff
UNIX Command
diff -y file1 file2
NOTE: I'd recommend pairing this with
less
since your program's output may be larger than your terminal.
Preview (Note the third line is different):
Vimdiff
UNIX Command
vimdiff file1 file2
Vimdiff highlights the lines and characters that are different, so you'll instantly know what is different between your output and the solution executable's output.
Preview (Again, third line is different):
You can tell if X lines are the same via vimdiff if it says something like "190 lines: 255" and is gray like in the picture above.
Vimdiff is basically telling you "These lines are the same and it is pointless for me to print them".
To Quit Vimdiff, use :qa
(Quit All)
Method 2: See how the gradescript runs your program
This method varies per lab. The test cases can vary:
- The file is read in to the program via
stdin
- The file is read as command line arguments for the application
- The file is used in command line arguments for the program to read in via
ifstream
, FILE*
, etc.
Go in to the
Gradescript-Examples
directory (found via the path above) and then use
cat
or
vi
to view the test case files directly.
It should be obvious, when you get there, what files are used in test cases.
If your program uses command line arguments, the contents of the file may be command line arguments.
For instance, CS140's
Bigwhite executable for Lab 2 accepts input like this:
UNIX Command
./bigwhite width height
The lab has a
Gradescript-Examples
directory that looks like this:
Opening 021.txt via
vim
gives us this:
Text
14 14
It's obvious, based on the input method above (The lab accepts 2 command line arguments) that this file specifies command line arguments.
Therefore, we can run the test ourselves without the gradescript:
UNIX Command
./bigwhite 14 14
"Clara, what about those pgm files prior to 021.txt?"
Yes, the lab I used as an example has 5 executable files.
Bigwhite accepts command line arguments.
But the one before it (called
pgminfo) reads a PGM file in from
stdin
.
You know what this means? Those first 20 files are PGM files read directly in to your executable via
stdin
.
You can look at the files manually and see how it's structured.
Some files purposefully contain errors that you can probably catch via looking at it manually.