1.0.0 • Published 4 years ago
cs241-regtest v1.0.0
CS 241 Register Test Script
Installation and Usage
npm i cs241-regtest
npx cs241-regtest [source] [testFile]sourceis the path to the source filetestFileis the path to the test suite in JSON format
testFile format
The file specified by testFile is in JSON format with the following parameters:
preprocessoris a string specifying how a source file will be compiled into a machine-readable format. For CS 241, a MIPS assembly file may be translated with programs likecs241.wordasmorcs241.binasm. Any preprocessor must accept the file as redirected into the its stdin and out of its stdout, likecs241.wordasm < inputrather thancs241.wordasm input.destinationis a string that specifies where the output ofpreprocessorwill be redirected. A relative path wil be resolved from the current working directory, not the location of the test file. Avoid shell-specific expansions like~for the home directory. Ifpreprocessoris specified butdestinationis not, the output of the preprocessor will be written to a file in the same directory as the source file with the same name as the file but without an extension. Be careful that the output program does not overwrite the source file in the case that the source file does not have an extension.runtimeis a string specifying the runtime environment of the executable. For CS 241, runtime environments that specify registers includemips.twoints,mips.array, etc. Runtime environments must accept executable file paths as command-line arguments, likemips.twoints executablerather thanmips.twoints < executable.testsis an object keyed with the names of all of the tests to be run on the program. A test has the following keys:inputis an array of what will be inputted to the program. Formips.twoints, it will be an array of two numbers. Formips.array, it will be the length of the array followed by its elements. No newline characters are necessary.expectedis an object keyed with numbers representing the registers to be verified. A test will fail if any of the specified registers' outputs do not match what is in the test case. If a register is not specified inexpected, its result will not be checked.erroris a boolean that checks if an error is produced by the MIPS emulator. If it is set to true, an internal error like division by zero will be ignored by the tester.
Example programs and tests are given in the cs241-regtest repository.
1.0.0
4 years ago