-
Notifications
You must be signed in to change notification settings - Fork 1
/
runFullWorkflowOnAllUnitTests.bash
executable file
·85 lines (81 loc) · 2.89 KB
/
runFullWorkflowOnAllUnitTests.bash
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
#!/bin/bash
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-a|--advocate)
pathToAdvocate="$2"
shift
shift
;;
-f|--folder)
dir="$2"
shift
shift
;;
-m|--modulemode)
modulemode="$2"
shift
shift
;;
*)
shift
;;
esac
done
if [ -z "$pathToAdvocate" ]; then
echo "Path to advocate is empty"
exit 1
fi
if [ -z "$dir" ]; then
echo "Directory is empty"
exit 1
fi
pathToPatchedGoRuntime="$pathToAdvocate/go-patch/bin/go"
pathToGoRoot="$pathToAdvocate/go-patch"
pathToOverheadInserter="$pathToAdvocate/toolchain/unitTestOverheadInserter/unitTestOverheadInserter"
pathToOverheadRemover="$pathToAdvocate/toolchain/unitTestOverheadRemover/unitTestOverheadRemover"
pathToAnalyzer="$pathToAdvocate/analyzer/analyzer"
pathToFullWorkflowExecutor="$pathToAdvocate/toolchain/unitTestFullWorkflow/unitTestFullWorkflow.bash"
cd "$dir"
echo "In directory: $dir"
mkdir -p advocateResult
test_files=$(find "$dir" -name "*_test.go")
total_files=$(echo "$test_files" | wc -l)
current_file=1
skipped_tests=0
attempted_tests=0
for file in $test_files; do
echo "Progress: $current_file/$total_files"
echo "Processing file: $file"
package_path=$(dirname "$file")
test_functions=$(grep -oE ".*Test.*\(.*testing\.T\)" $file | sed 's/(.*\*testing\.T.*)//' | sed 's/func //')
for test_func in $test_functions; do
attempted_tests=$((attempted_tests+1))
packageName=$(basename "$package_path")
fileName=$(basename "$file")
echo "Running full workflow for test: $test_func in package: $package_path in file: $file"
adjustedPackagePath=$(echo "$package_path" | sed "s|$dir||g")
directoryName="advocateResult/file($current_file)-test($attempted_tests)-$fileName-$test_func"
mkdir -p $directoryName
if [ "$modulemode" == "true" ]; then
$pathToFullWorkflowExecutor -a $pathToAdvocate -p $adjustedPackagePath -m true -f $dir -tf $file -t $test_func &> $directoryName/output.txt
else
$pathToFullWorkflowExecutor -a $pathToAdvocate -p $adjustedPackagePath -f $dir -tf $file -t $test_func &> $directoryName/output.txt
fi
if [ $? -ne 0 ]; then
echo "File $current_file with Test $attempted_tests failed, check output.txt for more information. Skipping..."
skipped_tests=$((skipped_tests+1))
continue
fi
mv $package_path/advocateTrace $directoryName
mv $package_path/results_machine.log $directoryName
mv $package_path/results_readable.log $directoryName
mv $package_path/times.log $directoryName
mv $package_path/rewritten_trace* $directoryName 2>/dev/null
mv ./advocateCommand.log $directoryName
done
current_file=$((current_file+1))
done
echo "Finished fullworkflow for all tests"
echo "Attempted tests: $attempted_tests"
echo "Skipped tests: $skipped_tests"