-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-test-order.sh
84 lines (66 loc) · 2.86 KB
/
get-test-order.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
#!/usr/bin/env bash
# Usage: bash get-test-order.sh <old|new>
# EITHER:
# - Run the setup script before running this script
# OR:
# - Be in the same directory as the pom.xml before running this script.
# Only run for human-written tests
version=$1
if [[ "$version" == "new" ]]; then
TESTS=$NEW_DT_TESTS
CLASS=$NEW_DT_CLASS
LIBS=$NEW_DT_LIBS
SUBJ=$NEW_DT_SUBJ
SUBJ_SRC=$NEW_DT_SUBJ_SRC
ROOT_DIR=$NEW_DT_SUBJ_ROOT
else
TESTS=$DT_TESTS
CLASS=$DT_CLASS
LIBS=$DT_LIBS
SUBJ=$DT_SUBJ
SUBJ_SRC=$DT_SUBJ_SRC
ROOT_DIR=$DT_SUBJ_ROOT
fi
if [[ ! -z "$SUBJ_SRC" ]]; then
cd "$SUBJ_SRC"
fi
output_file_name="test-order"
if [[ ! -z "$SUBJ_NAME" ]]; then
output_file_name="$SUBJ/$SUBJ_NAME-orig-order"
fi
# Run the tests, but force to re-compile from top level just in case of needing local dependencies upgraded
(
cd $ROOT_DIR
/home/awshi2/apache-maven/bin/mvn install -Dmavanagaiata.skip=true -Drat.skip=true -Ddependency-check.skip=true -Dcheckstyle.skip=true -Dmaven.javadoc.skip=true -Dmaven-source.skip=true -Dcobertura.skip -DskipTests -pl $(echo $SUBJ_SRC | sed "s;$ROOT_DIR;;") -am
)
/home/awshi2/apache-maven/bin/mvn test -Dmavanagaiata.skip=true -Drat.skip=true -Ddependency-check.skip=true -Dcheckstyle.skip=true -Dmaven.javadoc.skip=true -Dmaven-source.skip=true -Dcobertura.skip |& tee "test-log.txt"
java -cp $DT_TOOLS: edu.washington.cs.dt.impact.tools.GetOriginalOrder $output_file_name "target/" "test-log.txt"
# tests=($(grep -h "Running .*" "test-log.txt" | sed -E "s/.*Running (.*)/\1/g"))
# (
# for test_name in "${tests[@]}"; do
# test_case_names=($(xmllint --xpath "//testsuite/testcase/@name" "target/surefire-reports/TEST-$test_name.xml" | sed -E "s/name=\"([^\"]*)\"/\1/g"))
# test_class_names=($(xmllint --xpath "//testsuite/testcase/@classname" "target/surefire-reports/TEST-$test_name.xml" | sed -E "s/classname=\"([^\"]*)\"/\1/g"))
# n="${#test_class_names[@]}"
# for (( i=0; i<"$n"; i++ )); do
# test_case_name="${test_case_names[$i]}"
# test_class_name="${test_class_names[$i]}"
# fqn="$test_class_name.$test_case_name"
# echo "$fqn"
# done
# done
# ) > "$output_file_name"
if [[ ! -z "$SUBJ_NAME" ]]; then
TEST_ORDER="$output_file_name"
IGNORE_TESTS_LIST="$DT_SCRIPTS/${SUBJ_NAME}-results/${SUBJ_NAME}-ignore-order"
if [[ -e "$IGNORE_TESTS_LIST" ]]; then
temp=$(mktemp)
grep -Fvf "$IGNORE_TESTS_LIST" $TEST_ORDER > $temp
mv $temp $TEST_ORDER
fi
java -cp $DT_TOOLS: edu.washington.cs.dt.impact.tools.detectors.FailingTestDetector --classpath "$CLASS:$TESTS:$LIBS:$DT_TOOLS:" --tests "$TEST_ORDER" --output "$IGNORE_TESTS_LIST"
if [[ -e "$IGNORE_TESTS_LIST" ]]; then
temp=$(mktemp)
grep -Fvf "$IGNORE_TESTS_LIST" $TEST_ORDER > $temp
mv $temp $TEST_ORDER
fi
fi