-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-sootTestOutput-auto-first.sh
58 lines (48 loc) · 2.87 KB
/
generate-sootTestOutput-auto-first.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
source ~/.bashrc
set -e
# 1. In the old-subj, get the list of public classes in your subject. Make sure that the jar file used as input to the command contains only your source files and contains no test files.
cd $DT_SUBJ
if [[ ! -e "$SUBJ_NAME-classes" ]]; then
echo "[DEBUG] Getting list of public classes."
jar -cf ./$SUBJ_NAME.jar -C classes/ .
java -cp $DT_LIBS:$DT_TOOLS: edu.washington.cs.dt.util.PublicClassFinder $SUBJ_NAME.jar > $SUBJ_NAME-classes
fi
# 2. In the old-subj, generate the randoop tests. For some of our subjects we noticed that randoop either exited unexpectedly or threw some exceptions and was unable to generate tests. In those cases, we simply removed the class that is causing the problem from old-subj-classes. See our Experiments caveats page for more details on what we omitted.
echo "[DEBUG] Generating auto tests."
jar -cf ./$SUBJ_NAME.jar -C classes/ .
java -ea -cp $DT_LIBS:$DT_CLASS:$DT_TOOLS_DIR/randoop.jar: randoop.main.Main gentests --classlist=$SUBJ_NAME-classes --outputlimit=5000 --ignore-flaky-tests=true
# 3. Compile the randoop tests that were generated
mkdir -p randoop/
mv *.java randoop/
cd randoop/
#see if ErrorTest exists, then execute the appropriate compile line
echo "[DEBUG] Compiling auto tests."
count=`ls -1 ErrorTest*.java 2>/dev/null | wc -l`
if [ $count != 0 ];
then
javac -cp $DT_LIBS:$DT_CLASS:$DT_TOOLS: ErrorTest*.java RegressionTest*.java
else
javac -cp $DT_LIBS:$DT_CLASS:$DT_TOOLS: RegressionTest*.java
fi
mkdir -p bin
mv *.class ./bin
#get sootTestOutput-auto
cd $DT_SUBJ
# 4. Find the automatically-generated tests in the subject.
echo "[DEBUG] Finding auto tests in the old subject."
bash "$DT_SCRIPTS/find-test-list.sh" old auto
# 5. Instrument the source and test files.
echo "[DEBUG] Instrumenting auto tests."
# java -cp $DT_TOOLS:$DT_LIBS:$DT_CLASS:$DT_RANDOOP:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain --soot-cp -inputDir $DT_RANDOOP
java -cp $DT_TOOLS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain --soot-cp $DT_LIBS:$DT_CLASS:$DT_RANDOOP:$JAVA_HOME/jre/lib/*: -inputDir $DT_RANDOOP
# java -cp $DT_TOOLS:$DT_LIBS:$DT_CLASS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain -inputDir $DT_CLASS
java -cp $DT_TOOLS:$DT_LIBS:$DT_CLASS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain -inputDir $DT_CLASS --soot-cp $DT_LIBS:$DT_CLASS:$JAVA_HOME/jre/lib/*:
# 6. Run the instrumented tests.
echo "[DEBUG] Running instrumented auto tests."
# Make sure to change directories to the src directory.
# Sometimes tests require that the pwd is a particular directory, and this is usually it.
cd $DT_SUBJ_SRC
java -cp $DT_TOOLS: edu.washington.cs.dt.main.ImpactMain -classpath $DT_LIBS:$DT_SUBJ/sootOutput/: -inputTests $DT_SUBJ/$SUBJ_NAME-auto-order
mv sootTestOutput/ $DT_SUBJ/sootTestOutput-auto
cd $DT_SUBJ
rm -rf sootOutput/