package com.holyer.mark;import java.io.*;import java.util.*;class Mark{ boolean verbose; String[] tests; File currentDir; PrintStream feedback; boolean all, any; int total, max; int batchTotal, batchMax; public static void main (String[] args) { boolean vflag = true; String testfile; String[] dirs; int n = 0; if (args.length - n == 0 || args[n].startsWith("-")) { System.err.println ( "Usage: java -jar mark.jar testfile.mrk [dir] [dir] ...\n" + "If no directories are given, the current one is used.\n" + "The testfile contains lines of the form:\n" + " SETUP cmd (run the command cmd)\n" + " DELETE files (delete files, wildcards allowed)\n" + " TEST [n] cmd (run a test worth n marks, default 1)\n" + " output (lines of output expected from the test)\n" + " ALL [n] (start batch of tests worth n, all must pass)\n" + " ANY [n] (start batch of tests worth n, any may pass)\n" + " IMPORT [n] f (include a hand-written mark file f)\n" + " TOTAL (generate a total mark)" ); return; } testfile = args[n++]; dirs = new String[args.length - n]; for (int i = 0; i < dirs.length; i++) dirs[i] = args[n+i]; if (dirs.length == 0) dirs = new String[] {"."}; Mark program = new Mark(); program.mark(vflag, testfile, dirs); } // Run the tests on all the directories. void mark(boolean vflag, String testfile, String[] dirs) { verbose = vflag; tests = readFile(testfile); currentDir = null; for (int i = 0; i <= dirs.length; i++) { if (i == dirs.length && i > 0) break; if (dirs.length > 0) currentDir = new File(dirs[i]); try { if (verbose && (currentDir == null || dirs[i].equals("."))) { feedback = new PrintStream(new FileOutputStream("feedback.txt")); } else if (verbose) { File dir = new File("feedback"); dir.mkdir(); File out = new File(dir, currentDir.getName() + ".txt"); feedback = new PrintStream(new FileOutputStream(out)); } runTests(testfile);[...]