This repository was archived by the owner on Sep 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_java.sh
More file actions
42 lines (35 loc) · 1.33 KB
/
Copy pathscript_java.sh
File metadata and controls
42 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# store paths in variables
testDir="./test"
testInputDir="$testDir/in"
testOutputDir="$testDir/out"
sourceDir="./src"
tablePath="$sourceDir/table.npt"
outputDir="./out"
dotClassFilesOutputDir="$outputDir/classes"
reportDir="$outputDir/report"
resultDir="$outputDir/result"
# make necessary directories if not existed before
mkdir -p $outputDir
mkdir -p $dotClassFilesOutputDir
mkdir -p $reportDir
mkdir -p $resultDir
# compile Main.java
javac --release 8 -cp "$sourceDir" -d $dotClassFilesOutputDir $sourceDir/Main.java
# compare output result with expected result
inputFileNames=`ls $testInputDir`
for fileRelativePath in $inputFileNames; do
currentfileName=${fileRelativePath%.*}
testInputFile="$testInputDir/$currentfileName.cool"
testOutputFile="$testOutputDir/$currentfileName.out"
currentOutputFile="$resultDir/$currentfileName-result.out"
reportFile="$reportDir/$currentfileName-report.txt"
result=`java -cp "$dotClassFilesOutputDir" Main --input $testInputFile --output $currentOutputFile --table $tablePath`
if cmp -s "$testOutputFile" "$currentOutputFile"; then
printf "Ok" > $reportFile
printf "$currentfileName passed\n"
else
printf "%s" "$result" > $reportFile
printf '%s failed. expected "%s" but result is "%s"\n' "$currentfileName" "`cat $testOutputFile`" "`cat $currentOutputFile`"
fi
done