test suite: Add expected output for every test.
Rather than using the (munged) output of "gcc -E" we now capture precisely the output we expect from every test case. This allows us to stay immune from strange output from gcc (unpredictable whitespace output---aprticularly with different gcc versions). This will also allow us to write tests that capture expected error messages from the preprocessor as well.
This commit is contained in:
@@ -4,7 +4,4 @@ glcpp-parse.c
|
||||
glcpp-parse.h
|
||||
*.o
|
||||
*~
|
||||
tests/*.expected
|
||||
tests/*.gcc
|
||||
tests/*.glcpp
|
||||
tests/*.out
|
||||
|
||||
@@ -22,4 +22,4 @@ test: glcpp
|
||||
|
||||
clean:
|
||||
rm -f glcpp glcpp-lex.c glcpp-parse.c *.o *~
|
||||
rm -f tests/*.out tests/*.gcc tests/*.expected tests/*~
|
||||
rm -f tests/*.out tests/*~
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
this is four tokens
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
1
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
a 1
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
a 1
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
|
||||
a b c foo
|
||||
b c a bar
|
||||
c a b baz
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
1
|
||||
|
||||
foo
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
1
|
||||
|
||||
foo
|
||||
|
||||
2
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
bar
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
1
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
1
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
()1()
|
||||
|
||||
()2()
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
((bar)+1)
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
((bar)*(baz))
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
1
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
(this is more than one word)
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
one fish,two fish,red fish,blue fish
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
(2*((1+(3))))
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
(argument(including parens)for the win)
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
1
|
||||
2
|
||||
3 4
|
||||
5 6 7
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
foo
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
foo bar
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
bar
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
foo(2*(3))
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
foo(2*(foo(2*(3))))
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
foo
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
1+foo
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
more success
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
expand(just once)
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
success
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
(two,words)
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
onetoken
|
||||
@@ -0,0 +1,5 @@
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
@@ -0,0 +1,5 @@
|
||||
success_1
|
||||
|
||||
success_2
|
||||
|
||||
success_3
|
||||
@@ -0,0 +1,7 @@
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
success_3
|
||||
@@ -0,0 +1,7 @@
|
||||
success_1
|
||||
|
||||
success_2
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
@@ -0,0 +1,11 @@
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
|
||||
|
||||
|
||||
success_4
|
||||
@@ -0,0 +1,11 @@
|
||||
success_1
|
||||
|
||||
success_2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
@@ -0,0 +1,11 @@
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
success_3
|
||||
@@ -0,0 +1,11 @@
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
|
||||
success
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
|
||||
|
||||
success_1
|
||||
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_4
|
||||
|
||||
|
||||
|
||||
success_5
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
|
||||
success_1
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
|
||||
|
||||
success_4
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
|
||||
success_1
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_1
|
||||
|
||||
|
||||
success_2
|
||||
|
||||
|
||||
|
||||
|
||||
success_3
|
||||
|
||||
|
||||
|
||||
|
||||
success_4
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
success_5
|
||||
|
||||
|
||||
success_6
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
success
|
||||
|
||||
success
|
||||
|
||||
success
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
ab
|
||||
a
|
||||
b
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
12
|
||||
1000
|
||||
identifier2
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
5*2
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
success
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
|
||||
f = g /h;
|
||||
l();
|
||||
m = n
|
||||
+ p;
|
||||
|
||||
more code here
|
||||
|
||||
are not treated like comments.
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
a = b
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
success_1 success_2 success_3
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
|
||||
f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
|
||||
int i[] = { 1, 23, 4, 5, };
|
||||
+1
-4
@@ -2,9 +2,6 @@
|
||||
|
||||
for test in *.c; do
|
||||
echo "Testing $test"
|
||||
../glcpp < $test > $test.glcpp
|
||||
grep -v '^ *$' < $test.glcpp > $test.out || true
|
||||
gcc -E $test -o $test.gcc
|
||||
grep -v '^#' < $test.gcc | grep -v '^$' | sed -r -e 's/^ +/ /' > $test.expected || true
|
||||
../glcpp < $test > $test.out
|
||||
diff -u $test.expected $test.out
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user