-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.cmd
155 lines (126 loc) · 4.89 KB
/
check.cmd
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
:<<"::NONWINDOWSSCRIPT"
@ECHO OFF
GOTO :WINDOWSSCRIPT
::NONWINDOWSSCRIPT
minjavavsn=17
recjavavsn=21
# check Java version
javavsn=`java -fullversion 2>&1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1`
if [[ "$javavsn" -lt "$minjavavsn" ]]; then
echo "Exiting : Java ${minjavavsn}+ required, Java ${javavsn} found"
echo "Recommended: Remove Java ${javavsn}, install Java ${recjavavsn} from https://www.azul.com/downloads/"
exit 1
fi
# check required files
missing=0
[ ! -f "junit5all.jar" ] && echo "Missing file: junit5all.jar" && missing=1
[ ! -f "checkthat.jar" ] && echo "Missing file: checkthat.jar" && missing=1
[ ! -f "checkagent.jar" ] && echo "Missing file: checkagent.jar" && missing=1
[[ "$missing" -eq "1" ]] && exit 1
if [ $# -ge 2 ]; then
# check arg file exists
[ ! -f "$1" ] && echo Missing argument file: "$name" && exit 1
TARGET1=$1
TARGET2=$2
PROPS=${3-}
OPTS=${4-}
if [[ "$TARGET2" == *"StructureTest" ]]; then
echo "Structural tester: compiling and running $TARGET2"
elif [[ "$TARGET2" == *"Suite" ]]; then
echo "Test suite: compiling and running $TARGET2"
else
echo "Functional tester: compiling and running $TARGET2"
fi
echo javac -cp ".:junit5all.jar:checkthat.jar" "${TARGET1}"
javac -cp ".:junit5all.jar:checkthat.jar" "${TARGET1}"
retVal=$?
[[ $retVal -ne 0 ]] && echo "Exiting: Java compilation failed with error code $retVal" && exit $retVal
echo java ${PROPS} -javaagent:checkagent.jar -jar junit5all.jar execute ${OPTS} -E junit-vintage --disable-banner -cp . -cp checkthat.jar -c "${TARGET2}"
java ${PROPS} -javaagent:checkagent.jar -jar junit5all.jar execute ${OPTS} -E junit-vintage --disable-banner -cp . -cp checkthat.jar -c "${TARGET2}"
exit 0
fi
# usage
echo "Usage: check.bat <path of tester file> <tester class> [CheckThat options] [JUnit properties]"
echo "Useful CheckThat options:"
echo " -Dlang=HU or -Dlang=EN For structural tester error messages."
echo " -Dsummary=time/full Use either time or full to see more JUnit summary details."
echo " -Derrors=verbose If you really, REALLY want to see the full stack trace."
echo "Useful JUnit properties:"
echo " --disable-ansi-colors For monochrome terminals."
echo
echo "Note: in PowerShell terminals, options have to be surrounded using this very silly syntax:"
echo " '\"-Dlang=EN\"'"
echo
echo "Note: passing more than one option can be tricky."
echo "Suggested: see the executed java and javac commands and manually modify them."
exit 1
:WINDOWSSCRIPT
set minjavavsn=17
set recjavavsn=21
if "%~1"=="" goto USAGE
REM check Java version
for /f tokens^=2^ delims^=.-_+^" %%j in ('java -fullversion 2^>^&1') do set "javavsn=%%j"
if %javavsn% LSS %minjavavsn% (
echo Exiting : Java %minjavavsn%+ required, Java %javavsn% found
echo Recommended: Remove Java %javavsn% (and possible other old versions^), install Java %recjavavsn% from https://www.azul.com/downloads/
goto END
)
REM check required files
set missing=0
for %%i in ("checkthat.jar" "checkagent.jar" "junit5all.jar" "%~1") do (
if not exist "%%i" (
echo Missing required file: %%i
set missing=1
)
)
if "%missing%"=="1" goto END
if "%~2"=="" goto USAGE
REM check arg file exists
if not exist "%~1" (
echo Missing argument file: %~1
goto END
)
set TARGET1="%~1"
set TARGET2="%~2"
set PROPS=
set OPTS=
if not "%~3"=="" (
set PROPS="%~3"
)
if not "%~4"=="" (
set OPTS="%~4"
)
if not "x%TARGET2:StructureTest=%"=="x%TARGET2%" (
echo Structural tester: compiling and running %TARGET2%
) else (
if not "x%TARGET2:Suite=%"=="x%TARGET2%" (
echo Test suite: compiling and running %TARGET2%
) else (
echo Functional tester: compiling and running %TARGET2%
)
)
@ECHO ON
javac -cp ".;junit5all.jar;checkthat.jar" %TARGET1%
: Stops the batch file if there was a compilation error
@if %ERRORLEVEL% NEQ 0 (
echo Exiting: Java compilation failed with error code %ERRORLEVEL%
exit /b %ERRORLEVEL%
)
java %PROPS% -javaagent:checkagent.jar -jar junit5all.jar execute %OPTS% -E junit-vintage --disable-banner -cp . -cp checkthat.jar -c %TARGET2%
@ECHO OFF
goto END
:USAGE
echo Usage: check.bat ^<path of tester file^> ^<tester class^> [CheckThat options] [JUnit properties]
echo Useful CheckThat options:
echo -Dlang=HU or -Dlang=EN For structural tester error messages.
echo -Dsummary=time/full Use either time or full to see more JUnit summary details.
echo -Derrors=verbose If you really, REALLY want to see the full stack trace.
echo Useful JUnit properties:
echo --disable-ansi-colors For monochrome terminals.
echo[
echo Note: in PowerShell terminals, options have to be surrounded using this very silly syntax:
echo '"-Dlang=EN"'
echo[
echo Note: passing more than one option can be tricky.
echo Suggested: see the executed java and javac commands and manually modify them.
:END