forked from elviscgn/wtc-java-prep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·58 lines (47 loc) · 1.66 KB
/
Copy pathrun_tests.sh
File metadata and controls
executable file
·58 lines (47 loc) · 1.66 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
JAR="tests/lib/junit-standalone.jar"
BUILD_DIR="build"
SOLUTIONS_DIR="solutions"
TESTS_DIR="tests"
# havent tested on windows
if [ ! -f "$JAR" ]; then
echo "JUnit JAR not found. Run ./setup.sh first."
exit 1
fi
if [ ! -d "$SOLUTIONS_DIR" ]; then
echo "No solutions/ folder found."
exit 1
fi
SOLUTION_FILES=$(find "$SOLUTIONS_DIR" -name "*.java" 2>/dev/null)
if [ -z "$SOLUTION_FILES" ]; then
echo "No .java files in solutions/ yet."
exit 1
fi
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
echo "Compiling solutions..."
javac -cp "$JAR" -d "$BUILD_DIR" $SOLUTION_FILES
if [ $? -ne 0 ]; then exit 1; fi
FILTER="${1:-}"
if [ -n "$FILTER" ]; then
TEST_FILES=$(find "$TESTS_DIR" -name "*${FILTER}*.java" ! -path "*/lib/*" 2>/dev/null)
else
TEST_FILES=$(find "$TESTS_DIR" -name "*.java" ! -path "*/lib/*" 2>/dev/null)
fi
if [ -z "$TEST_FILES" ]; then
echo "No test files found matching '${FILTER}'."
exit 1
fi
echo "Compiling tests..."
javac -cp "$JAR:$BUILD_DIR" -d "$BUILD_DIR" $TEST_FILES
if [ $? -ne 0 ]; then exit 1; fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [ -n "$FILTER" ]; then
echo " Running tests matching: $FILTER"
java -jar "$JAR" --classpath "$BUILD_DIR" --scan-classpath --include-classname ".*${FILTER}.*"
else
echo " Running all tests"
java -jar "$JAR" --classpath "$BUILD_DIR" --scan-classpath
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"