Skip to content

Commit

Permalink
add test for incremental compilation working
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-taylor committed Apr 20, 2019
1 parent f318cbe commit cc657a4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
26 changes: 17 additions & 9 deletions tests/do_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ unset CDPATH
tests_dir=$(dirname $(readlink -f $0))
cd "$tests_dir"

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

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

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

Expand All @@ -44,13 +44,21 @@ do

for compile_options in $compile_options_list
do
dcc_flags=
suffix=`echo $compile_options|sed 's/^dcc_flags=//;s/["$]//g;s/src_file//'`
eval $compile_options
expected_stderr_file="$expected_output_dir/`basename $src_file .c`$suffix.txt"
#echo "$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file"
"$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file" 2>tmp.actual_stderr >/dev/null
test ! -s tmp.actual_stderr && ./a.out </dev/null 2>>tmp.actual_stderr >/dev/null
case "$src_file" in
*.c)
dcc_flags=
suffix=`echo $compile_options|sed 's/^dcc_flags=//;s/["$]//g;s/src_file//'`
eval $compile_options
expected_stderr_file="$expected_output_dir/`basename $src_file .c`$suffix.txt"
#echo "$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file"
"$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file" 2>tmp.actual_stderr >/dev/null
test ! -s tmp.actual_stderr && ./a.out </dev/null 2>>tmp.actual_stderr >/dev/null
;;

*.sh)
expected_stderr_file="$expected_output_dir/`basename $src_file .sh`.txt"
$src_file </dev/null 2>tmp.actual_stderr >/dev/null
esac

if test ! -s tmp.actual_stderr
then
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
incremental compilation works
incremental compilation works
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-i

Values when execution stopped:

a = <deleted-value>
argc = <deleted-value>
a[42] = <deleted-value>
a[43] = <deleted-value>
Expand Down
18 changes: 18 additions & 0 deletions tests/run_time/incremental_compilation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

cat >tmp1.c <<eof
#include <stdio.h>
void f(void) {fprintf(stderr, "incremental compilation works\n"); }
eof

cat >tmp2.c <<eof
extern void f(void);
int main(void) {f(); }
eof

dcc -c tmp1.c
dcc -c tmp2.c
dcc tmp1.o tmp2.o
./a.out
dcc tmp1.o tmp2.c
./a.out

0 comments on commit cc657a4

Please sign in to comment.