-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_env.sh
More file actions
executable file
·105 lines (93 loc) · 2.75 KB
/
make_env.sh
File metadata and controls
executable file
·105 lines (93 loc) · 2.75 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
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
100
101
102
103
104
105
#!/bin/bash
if [ $0 == $BASH_SOURCE ]; then
echo "Usage: source $BASH_SOURCE"
exit 1
fi
# Export STDLIB
export STDLIB="$(find tests/stdlib/java/ -name '*.java')"
# Get all tests for autocompletion
function _test_completions {
local FILES=$(ls tests/programs/*/marmoset/*/* -d | cut -d'/' -f 6 | sort --unique)
local cur=$"${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=($(compgen -W "${FILES}" -- "$cur"))
}
# Find input files from test name
# Not for use
function getinput {
FILE=$(find ./tests/programs/ -name $1 | tail -1)
if [[ -n $FILE ]]; then
if [ -f $FILE ]; then
INPUT=$FILE
else
INPUT=$(find $FILE -type f -name "*.java")
fi
echo ${INPUT}
fi
}
complete -F _test_completions getinput
# Find test and run with gdb
# (supports folders & files)
# Example: rundebug Je_6_StaticThis_AfterStaticInvoke.java
function rundebug {
INPUT=$(getinput $1); shift
if [[ -n $INPUT ]]; then
gdb --args ./joosc $@ $INPUT ${STDLIB}
fi
}
complete -F _test_completions rundebug
# Find test and run
# (supports folders & files)
# Example: runtest Je_6_StaticThis_AfterStaticInvoke.java
function runtest {
INPUT=$(getinput $1); shift
if [[ -n $INPUT ]]; then
./joosc $@ ${INPUT} ${STDLIB}
fi
}
complete -F _test_completions runtest
function runvalgrind {
INPUT=$(getinput $1); shift
if [[ -n $INPUT ]]; then
valgrind $@ ./joosc ${INPUT} ${STDLIB}
fi
}
complete -F _test_completions runvalgrind
# Run gdb on stdlib
# (useful for debugging critical errors on minimal input)
function runstdlib {
gdb --args ./joosc ${STDLIB}
}
# Open test files in editor
function viewtest {
# FILE=$(find ./tests/ -name $1 | tail -1)
INPUT=$(getinput $1)
${EDITOR} ${INPUT}
}
complete -F _test_completions viewtest
# Get failing tests
# -> Do a grep on each test
# -> Output tests with matching grep
# Example: search_failing "DISAMBIGUATION"
function search_failing {
INPUT_CMD='$(getinput {})'
GREP_STR=$1
make integration-test 2>/dev/null | grep "FAIL:" | cut -d' ' -f5 | # get failing tests
xargs -i bash -c "source make_env.sh && grep \"$GREP_STR\" $INPUT_CMD -l" | # grep each failing test for str
cut -d'/' -f7 | sort | uniq # get test names only
}
# Make and run the graph generator
function rungraph {
INPUT=$(getinput $1)
if [[ -n $INPUT ]]; then
make graph && (
make clean -C graphs/
./joosc ${INPUT} ${STDLIB}
make -C graphs/
)
fi
}
complete -F _test_completions rungraph
function run_java_ir {
javac -d java-ir-bin $(find java-ir -name "*.java")
java -cp java-ir-bin joosc.ir.interpret.Main
}