forked from RMLio/rmlmapper-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·99 lines (84 loc) · 2.36 KB
/
test.sh
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
#!/usr/bin/env bash
## Prints message when verbose is enabled.
log () {
local MESSAGE=$1
if [[ "$VERBOSE" == "true" ]]; then
>&2 echo $MESSAGE
fi
}
SKIP_ORACLE_TESTS=false
ONLY_ORACLE_TESTS=false
# Process command line arguments
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-n|--no-oracle)
SKIP_ORACLE_TESTS=true
shift # past argument
;;
-o|--only-oracle)
ONLY_ORACLE_TESTS=true
shift # past argument
;;
-v|--verbose)
VERBOSE=true
shift # past argument
;;
-m|--hide-maven-output)
HIDE_MAVEN_OUTPUT=true
shift # past argument
;;
-h|--help)
echo "Usage information: "
echo
echo " -n|--no-oracle Skip Oracle tests."
echo " -o|--only-oracle Only run Oracle tests."
echo " -v|--verbose Output more information."
echo " -m|--hide-maven-output Hide maven output."
echo " -h|--help The usage of information."
exit 0;
;;
esac
done
if [[ "$SKIP_ORACLE_TESTS" == "true" && "$ONLY_ORACLE_TESTS" == "true" ]]; then
>&2 echo "Error: Either use -n|--no-oracle or -o|--only-oracle, but not both."
exit 1
fi
log "Skip Oracle tests: $SKIP_ORACLE_TESTS"
log "Only Oracle tests: $ONLY_ORACLE_TESTS"
log ""
if [[ "$ONLY_ORACLE_TESTS" != "true" ]]; then
log "Running all tests except Oracle tests."
if [[ "$HIDE_MAVEN_OUTPUT" == "true" ]]; then
mvn test -Dtest=!Mapper_OracleDB_Test &> /dev/null
else
mvn test -Dtest=!Mapper_OracleDB_Test
fi
fi
if [ $? -eq 0 ]; then
if [[ "$SKIP_ORACLE_TESTS" != "true" ]]; then
log "Running all Oracle tests."
cp pom.xml pom-oracle.xml
dep="\t\t<dependency>\n\t\t\t<groupId>com.oracle</groupId>\n\t\t\t<artifactId>ojdbc8</artifactId>\n\t\t\t<version>12.2.0.1</version>\n\t\t</dependency>"
temp=$(echo $dep | sed 's/\//\\\//g')
sed -i "/<\/dependencies>/ s/.*/${temp}\n&/" pom-oracle.xml
if [[ "$HIDE_MAVEN_OUTPUT" == "true" ]]; then
mvn test -f pom-oracle.xml -Dtest=Mapper_OracleDB_Test &> /dev/null
else
mvn test -f pom-oracle.xml -Dtest=Mapper_OracleDB_Test
fi
rm pom-oracle.xml
if [ $? -eq 0 ]; then
log "All tests are done."
else
>&2 echo "Some of the tests failed."
exit 1
fi
else
log "All tests succeeded."
fi
else
>&2 echo "Some of the tests failed."
exit 1
fi