A script was created in Summer 2010 to assist tutors in the creation of autotesting folders for the assignments. An additional script was created in Fall 2010 to assist with the creation of test files within those folders. These scripts were created for CS116, but should be usable in any course which uses Bittersuite for testing. Currently, it is set up for use with Scheme and Python, but it should be possible to add other languages, if desired.
The script for creating testing folders is called make-all.py, the script for creating the test files is called make-tests.py, and the script for creating the mark-scheme is called make-mark-scheme.py.
The following are step by step instructions of how to make public tests and autotests. More information is provided lower down on this page, or on the python specific page.
This requires the use of the make-all.py script, which should be in the bin folder.
The public test folder will have an "in" folder, which will have the number of folders specified inside (one for each question). Do the following inside each of the folders:
desc = test description
(result (fn-call par1 par2...))
(expected exp-val)
Python:
desc = test description
result = fn-call(par1 par2...)
expected = exp-val
Ensure that these tests work by testing them on sample code:
This will make use of the make-tests.py script, which should be in the bin folder.
If check-within is needed/used, ensure fpequal.rkt module is in the provided folder in the test.pt and test.1 folders. If not, it can be found in the "Useful Modules" folder in the marking folder:
(modules fpequal.rkt)
(equal check-close)
(result (fn-call par1 par2...))
(expected exp-val)
If input is needed/used, ensure suppress_prompt.py module is in the provided folder in the test.pt and test.1 folders. If not, it can be found in the "Useful Modules" folder in the marking folder:
desc = description
input = {inp1
inp2
inp3...}
result = fn-call(par1 par2...)
expected = exp-val
If printing is needed/used, ensure redirect_output.py module is in the provided folder in the test.pt and test.1 folders. If not, it can be found in the "Useful Modules" folder in the marking folder:
Note that the redirect_output.py module creates a list of strings of the printed output, where each string is a separate line of the output, so the exp-val should be a list of strings.
desc = description
from redirect_output import *
result = redirect_output( fn_name, [par1, par2...])
expected = exp-val
These steps are based off of the instructions in MarkUsPrepareForMarking#If_ISA_needs_to_upload_plain_tex. Do these steps any time after the due date. Replace a01
with the current assignment number.
/u/isg/bin/markus.py download a01 /u/cs116/handin/a01_autotest
ln -s a01 a01_autotest
.
distrst -t t -s '*' a01_autotest 1 AUTOTESTRESULTS
python MakeGradedAssignment.py
in terminal. This puts all of the results into one neat file which will be used to grade on Markus.
/u/isg/bin/markus.py upload_marking --filter 'GRADED_ASSIGNMENT.py' a01 /u/cs116/handin/a01_autotest/
make-all.py {asst name} {number of questions}
~/make-all.py a4 4
will lead to the creation of a testing suite for an assignment called a4
, that has 4 questions (or 4 files to be submitted)
.subfiles
is created, with the required files to submit taking the form {ass't name}q{x}.{ss,py}
. For example, if in the above example of ~/make-all.py a4 4
, if we assume the language had been set to Scheme, .subfiles
will include: mark-scheme
(a template), runTests
and computeMarks
are created, as well as the folders in
, provided
and answers
(if necessary). In the in
folder, the main options.ss
file is created, with the language specification. Also, a folder is created for each of the questions, each with its own options file, specifying the loadcode, as well as any alternate equality function.
This script will create all of the files and directories required to run tests on a question by reading a text file. To call make-tests
from anywhere in the linux terminal, first save make-tests.py
into csXXX/bin/
and restart the terminal. You only need to do this once at the start of term. Each time you want to use the script, call the command make-tests.py {asst name} {question number} {text file name}
. The text file must be saved in marking/???/test.1/
, where ???
is the assignment name (such as a1 or a01), and should look something like this:
desc = y-intercept is a given point (result (find-y-intercept (make-posn 0 1) (make-posn 1 0))) (expected 1) desc = y-intercept is origin (result (find-y-intercept (make-posn 2 2) (make-posn -2 -2))) (expected 0) desc = general case (result (find-y-intercept (make-posn 1 3) (make-posn 2 -5))) (expected 11)
The script interprets blank lines in the text file as the end of a test; after the question tags, each test should be included in a block of text without blank lines, preceded by and followed by at least one blank line. The script will create test directories numbered sequentially beginning at t01.
The script checks each line of the text file for a specific set of tags (which are described in detail in the next section). The one tag you should use on every test is desc - this sets a description of the test, and gives students useful information on which tests they passed and which tests they failed. All tags have a default value, and so you can include as many or as few as needed for a given test; however, you should always include the desc tag, since its default value is just a number.
If a line does not begin with one of those tags, it will be written to the appropriate test.py or test.rkt file. Be sure to read the appropriate twiki pages to know what each test.py or test.rkt file should contain.
Question tags are used to set values that will be the same for all tests of a given question, such as the language that will be used, or modules that need to be loaded. Test tags only apply to an individual test, and can do things like set keyboard input or change the mark value of an individual question. If a test and question tag disagree (such as over the mark value for a question), the test tag takes precedence.
Question and test tags can be further subdivided into two types: those which accept a single line of input, and those which can accept multiple lines of input.
The first lines of the text file can determine what is written in the options.rkt file for the question. While question tags usually don't need to be included (as in the example), there are situations where they are quite useful. If any of the following tags are included, they must be included in a single block (ie no blank lines between them) at the beginning of the file, and must be followed by at least one blank line before the first test-specific block. If none of these tags are included, an options.rkt file will still be written, and will contain the default loadcode and nothing else.
q_value
(single-line input) sets the default value for each test. If this tag is not included, each question will be worth one mark.
q_language
(single-line input) sets the language; valid options are the same as those for BitterSuite. If this tag is not included, any references to the language will be based on the language specified in the assignment's option file, which is created by make-all.py
.
q_loadcode
(single-line input) sets the loadcode. If this tag is not included, the loadcode is set to AQ.E
, where A
is the assignment name, Q
is the question number, and E
is the extension associated with the language in use (ie rkt for Scheme and py for Python).
q_desc
(single-line input) sets the question description. This description will be overwritten by any test-specific descriptions.
q_options
(multi-line input) adds its argument to the end of options.rkt. This can be useful for adding modules and equality functions.
Other than the specific tags listed below, any line included in a particular test block will be written to the test.py or test.rkt file (depending on the language chosen). It is usually best to include any tags at the beginning of the test, but they can be included anywhere within the test block.
value
(single-line input) sets the value for an individual test.
desc
(single-line input) sets the description for an individual test.
options
(multi-line input) adds its argument to the end of the test-specific options.rkt.
input
(multi-line input) creates a file containing its argument. This file is used as keyboard input, as described at BitterSuitePythonTesting.
output
(multi-line input) creates a file containing its argument. This file is used as screen output, as described at BitterSuitePythonTesting.
file
works slightly differently than other tags. It takes a single-line input which it uses as the name for the file it creates (the file is created in test.1/provided
). The following line is treated as the beginning of a multi-line input, which is used as the contents of the file (this line should begin with an open brace or double brace).
Since often you will want to create the testing suite folder before the marks breakdown has been given, this script will create the proper mark-scheme
file. The only drawback is that the script assumes that there must be 10 marks assigned to autotesting for each question, and 10 marks to design recipe and style.
-- JonathanTemplin - 26 Aug 2010 *Note that the attachments are saved as .py.txt
files,not just .py
. Just copy them to your home directory and correct the file extension.
mark-scheme
I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
a02q3b.txt | r1 | manage | 1.4 K | 2010-12-15 - 17:33 | PeterSinclair | Sample text file to show the syntax expected by ctest6.py |
![]() |
make-all.py.txt | r4 r3 r2 r1 | manage | 10.3 K | 2011-01-06 - 12:09 | PeterSinclair | Updated to create and look for .rkt files |
![]() |
make-marks.py.txt | r1 | manage | 3.0 K | 2010-08-26 - 15:27 | JonathanTemplin | |
![]() |
make-tests.py.txt | r2 r1 | manage | 11.0 K | 2011-12-20 - 15:21 | PeterSinclair | Version 2.1 - Added automatic course detection and permission changing for answers folder |