Skip to content

Commit

Permalink
Do not ignore #@ comments after empty line at start of test file
Browse files Browse the repository at this point in the history
  • Loading branch information
zickgraf committed Mar 30, 2020
1 parent 5be75b9 commit 81e3fd4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ InstallGlobalFunction(ParseTestInput, function(str, ignorecomments, fnam)
i := i+1;
else
Add(inp, "\n");
Add(pos, i);
i := i+1;
while i <= Length(lines) and (Length(lines[i]) = 0 or lines[i][1] = '#') do
while i <= Length(lines) and (Length(lines[i]) = 0 or (StartsWith(lines[i], "#") and not StartsWith(lines[i], "#@"))) do
i := i+1;
od;
Add(outp, JoinStringsWithSeparator(lines{[1..i-1]}, "\n"));
Expand Down
20 changes: 10 additions & 10 deletions tst/testspecial/broken-test.g.out
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
gap> Test("broken-test-2.tst", rec(width := 800));
Error, Invalid test file: #@ command found in the middle of a single test at broken-test-2.tst:5 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: #@ command found in the middle of a single test" ); at GAPROOT/lib/test.gi:131 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 called from
testError( "Invalid test file: #@ command found in the middle of a single test" ); at GAPROOT/lib/test.gi:132 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:572 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-3.tst", rec(width := 800));
Error, Invalid test file at broken-test-3.tst:5 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:137 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:138 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:572 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-4.tst", rec(width := 800));
Error, Invalid test file: Nested #@if at broken-test-4.tst:2 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: Nested #@if" ); at GAPROOT/lib/test.gi:52 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:572 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-5.tst", rec(width := 800));
Error, Invalid test file: two #@else at broken-test-5.tst:7 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: two #@else" ); at GAPROOT/lib/test.gi:63 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:572 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("broken-test-6.tst", rec(width := 800));
Error, Invalid test file: Continuation prompt '> ' followed by a tab, expected a regular space at broken-test-6.tst:3 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: Continuation prompt '> ' followed by a tab, expected a regular space" ); at GAPROOT/lib/test.gi:128 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 called from
testError( "Invalid test file: Continuation prompt '> ' followed by a tab, expected a regular space" ); at GAPROOT/lib/test.gi:129 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:572 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk> quit;
gap> Test("invalidtestfile.tst", rec(width := 800));
Error, Invalid test file at invalidtestfile.tst:7 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:137 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 called from
testError( "Invalid test file" ); at GAPROOT/lib/test.gi:138 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:572 called from
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
Expand Down
1 change: 1 addition & 0 deletions tst/testspecial/leading-empty-line.g
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test("leading-empty-line.tst", rec(width := 800));
3 changes: 3 additions & 0 deletions tst/testspecial/leading-empty-line.g.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gap> Test("leading-empty-line.tst", rec(width := 800));
true
gap> QUIT;
5 changes: 5 additions & 0 deletions tst/testspecial/leading-empty-line.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#@if true
gap> 1 + 1;
2
#@fi

0 comments on commit 81e3fd4

Please sign in to comment.