#!/bin/bash # pathtest -- run a series of path tests on RoadNetwork.txt # this source file must be made executable, eg chmod +x pathtest # author: Douglas W. Jones # version: Sept. 22, 2020 # the directory tests must exist # for test N, there must be a file tests/expN, holding the expected output # when running test N, the actual output will go in file tests/outN # if you change the program in a way that changes the output for test N, # a) if the failure found a bug, fix the program so the output is correct # b) if the new output is correct (because you improved the program) do # mv tests/outN tests/expN # in order to update things so the script expects the new output # as features are added to the program, add tests! ####### # test 1: path 1 in main, missing parameter java RoadNetwork 2> tests/out1 if diff tests/out1 tests/exp1 ; then echo "test 1 success" else read -p "Test failure -- path 1 in main, missing parameter" fi ####### # test 2: path 3 in main, nonexistant input file rm test java RoadNetwork test 2> tests/out2 if diff tests/out2 tests/exp2 ; then echo "test 2 success" else read -p "Test failure -- path 3 in main, nonexistant input file" fi ####### # test 3: path 2 in main, empty input file, path 1 in buildmodel echo "" > test java RoadNetwork test 2> tests/out3 if diff tests/out3 tests/exp3 ; then echo "test 3 success" else read -p "Test failure -- path 2 in main, empty input, path 1 in buildmodel" fi ####### # test 4: main path 2, path 1 in buildmodel, just an invalid command echo "gribble" > test java RoadNetwork test 2> tests/out4 if diff tests/out4 tests/exp4 ; then echo "test 4 success" else read -p "Test failure -- path 1 in buildmodel, just an invalid command" fi