Skip to content

Commit

Permalink
Give more helpful warning when using tabs in continuations
Browse files Browse the repository at this point in the history
This rejects continuations using 'tab' inside tests. They can
be confusing for users because GAP does not treat them as
continuations, but instead a line of output.

They are rejected, rather than treated as continuations, because
we do not want different parts of GAP to handle continuations
differently, or really start changing the definition of something
so fundamental.

This does break any tests which start an output line with '>\t',
but no such tests seem to exist and would be easily confused with
a continuation.
  • Loading branch information
ChrisJefferson committed Mar 23, 2019
1 parent 9e7e38d commit bba65fc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ InstallGlobalFunction(ParseTestInput, function(str, ignorecomments, fnam)
Append(inp[Length(inp)], lines[i]{[3..Length(lines[i])]});
Add(inp[Length(inp)], '\n');
i := i+1;
elif Length(lines[i]) > 1 and lines[i]{[1..2]} = ">\t" then
testError("Invalid test file: Continuation '> ' uses a tab instead of a space");
elif Length(outp) > 0 then
if foundcmd then
testError("Invalid test file: #@ command found in the middle of a single test");
Expand Down
6 changes: 6 additions & 0 deletions tst/testspecial/broken-test-6.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gap> f := function()
> local a;
> if a = 0 then
> Error("a is zero");
> fi;
> end;;
2 changes: 2 additions & 0 deletions tst/testspecial/broken-test.g
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Test("broken-test-4.tst", rec(width := 800));
quit;
Test("broken-test-5.tst", rec(width := 800));
quit;
Test("broken-test-6.tst", rec(width := 800));
quit;
Test("invalidtestfile.tst", rec(width := 800));
quit;
Test("empty.tst", rec(width := 800));
Expand Down
24 changes: 16 additions & 8 deletions tst/testspecial/broken-test.g.out
Original file line number Diff line number Diff line change
@@ -1,39 +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:129 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:569 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
<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:135 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:569 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
<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:569 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 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:569 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 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 '> ' uses a tab instead of a space at broken-test-6.tst:2 at GAPROOT/lib/test.gi:31 called from
testError( "Invalid test file: Continuation '> ' uses a tab instead of a space" ); at GAPROOT/lib/test.gi:128 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:571 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:135 called from
ParseTestInput( full, opts.ignoreComments, fnam ) at GAPROOT/lib/test.gi:569 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
<function "Test">( <arguments> )
called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
Expand Down

0 comments on commit bba65fc

Please sign in to comment.