Skip to content

Commit cc657a4

Browse files
committed
add test for incremental compilation working
1 parent f318cbe commit cc657a4

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

tests/do_tests.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ unset CDPATH
44
tests_dir=$(dirname $(readlink -f $0))
55
cd "$tests_dir"
66

7-
trap 'rm -fr tmp.* a.out' EXIT INT TERM
7+
trap 'rm -fr tmp* a.out' EXIT INT TERM
88

99
# some values reported in errors are not determinate (e.g. variable addresses)
1010
# and will vary between execution and definitely between platforms
@@ -35,7 +35,7 @@ mkdir -p $expected_output_dir
3535
test_failed=0
3636

3737
# don't change the variable src_file some tests rely on it
38-
for src_file in tests/extracted_compile_time_tests/*.c tests/compile_time/*.c tests/run_time/*.c
38+
for src_file in tests/extracted_compile_time_tests/*.c tests/compile_time/*.c tests/run_time/*.*
3939
do
4040
rm -f a.out
4141

@@ -44,13 +44,21 @@ do
4444

4545
for compile_options in $compile_options_list
4646
do
47-
dcc_flags=
48-
suffix=`echo $compile_options|sed 's/^dcc_flags=//;s/["$]//g;s/src_file//'`
49-
eval $compile_options
50-
expected_stderr_file="$expected_output_dir/`basename $src_file .c`$suffix.txt"
51-
#echo "$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file"
52-
"$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file" 2>tmp.actual_stderr >/dev/null
53-
test ! -s tmp.actual_stderr && ./a.out </dev/null 2>>tmp.actual_stderr >/dev/null
47+
case "$src_file" in
48+
*.c)
49+
dcc_flags=
50+
suffix=`echo $compile_options|sed 's/^dcc_flags=//;s/["$]//g;s/src_file//'`
51+
eval $compile_options
52+
expected_stderr_file="$expected_output_dir/`basename $src_file .c`$suffix.txt"
53+
#echo "$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file"
54+
"$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file" 2>tmp.actual_stderr >/dev/null
55+
test ! -s tmp.actual_stderr && ./a.out </dev/null 2>>tmp.actual_stderr >/dev/null
56+
;;
57+
58+
*.sh)
59+
expected_stderr_file="$expected_output_dir/`basename $src_file .sh`.txt"
60+
$src_file </dev/null 2>tmp.actual_stderr >/dev/null
61+
esac
5462

5563
if test ! -s tmp.actual_stderr
5664
then
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
incremental compilation works
2+
incremental compilation works

tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-i
1111

1212
Values when execution stopped:
1313

14+
a = <deleted-value>
1415
argc = <deleted-value>
1516
a[42] = <deleted-value>
1617
a[43] = <deleted-value>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
cat >tmp1.c <<eof
4+
#include <stdio.h>
5+
void f(void) {fprintf(stderr, "incremental compilation works\n"); }
6+
eof
7+
8+
cat >tmp2.c <<eof
9+
extern void f(void);
10+
int main(void) {f(); }
11+
eof
12+
13+
dcc -c tmp1.c
14+
dcc -c tmp2.c
15+
dcc tmp1.o tmp2.o
16+
./a.out
17+
dcc tmp1.o tmp2.c
18+
./a.out

0 commit comments

Comments
 (0)