From fac6565b2527f3fc5f966a76ecf3e6eedc7dbd51 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Sat, 28 Mar 2020 09:21:42 +0100 Subject: [PATCH] Do not ignore `#@` comments after empty line at start of test file --- lib/test.gi | 3 ++- tst/testspecial/broken-test.g.out | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/test.gi b/lib/test.gi index f16b3922fa4..2f4317933d9 100644 --- a/lib/test.gi +++ b/lib/test.gi @@ -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")); diff --git a/tst/testspecial/broken-test.g.out b/tst/testspecial/broken-test.g.out index 6ac311a482c..60fcd3d4939 100644 --- a/tst/testspecial/broken-test.g.out +++ b/tst/testspecial/broken-test.g.out @@ -1,15 +1,15 @@ 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 ( ) 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 ( ) called from read-eval loop at *stdin*:2 type 'quit;' to quit to outer loop @@ -17,7 +17,7 @@ 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 ( ) called from read-eval loop at *stdin*:2 type 'quit;' to quit to outer loop @@ -25,23 +25,23 @@ 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 ( ) 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 ( ) 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 ( ) called from read-eval loop at *stdin*:2 type 'quit;' to quit to outer loop