Run a script or command

Use the Script block to set up your test environment, compile your students code, or check that it runs without errors

Often it may just be necessary to set up a simple test that checks the exit code of a command or script. The Script block is perfect for this purpose: it executes any commands entered in the provided editor and returns the exit code of the last command. If connected to a rubric, an exit code of 0 (or success) results in passing the test and any non-zero exit code (or failure) results in failing the test. However, it can also be used without a rubric for performing any steps that don't need to be tested.

You can use Script blocks for a number of purposes. For example:

  • Set up your test environment For instance, moving files into the test directory

  • Check that a program runs without errors Find out if your students' programs execute without error when specific output is not important.

  • Check that a program compiles Find out if your students' programs compile without error.

How to to add a Script block to your AutoTest configuration:

  1. In either the Setup or the Tests tab of the AutoTest settings, either click the script block to add it to the bottom of your test setup or drag-and-drop the block to the desired location.

  2. Optionally, adjust the Script block's name by clicking on it and editing it.

  3. In the editor, provide the code that you want to execute.

  4. If you nest this block within a Connect Rubric block, the binary exit status (success or fail) of this command will determine the score of the test.

You can use uploaded files in the Setup as programs to run too, access them from the $UPLOADED_FILESdirectory.

Last updated