From 2e7fac41205a4cd275f7f7f03d5a648a31098f85 Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Thu, 7 Jun 2018 09:19:59 +0100 Subject: [PATCH] Add warning a file given to Test contains no tests --- lib/test.gi | 5 +++++ tst/testinstall/files/invalidtestfile.txt | 8 ++++++++ tst/testinstall/files/test.tst | 11 +++++++++++ tst/testinstall/files/tinytest.txt | 1 + 4 files changed, 25 insertions(+) create mode 100644 tst/testinstall/files/invalidtestfile.txt create mode 100644 tst/testinstall/files/test.tst create mode 100644 tst/testinstall/files/tinytest.txt diff --git a/lib/test.gi b/lib/test.gi index c59b7c864ed..0e49b4889f6 100644 --- a/lib/test.gi +++ b/lib/test.gi @@ -419,6 +419,11 @@ InstallGlobalFunction("Test", function(arg) # split input into GAP input, GAP output and comments pf := ParseTestInput(full, opts.ignoreComments); + + # Warn if we have not found any tests in the file + if IsEmpty(pf[1]) then + Info(InfoWarning, 1, "Test: File does not contain any tests!"); + fi; # run the GAP inputs and collect the outputs and the timings RunTests(pf, rec(breakOnError := opts.breakOnError, diff --git a/tst/testinstall/files/invalidtestfile.txt b/tst/testinstall/files/invalidtestfile.txt new file mode 100644 index 00000000000..77aa7997a1b --- /dev/null +++ b/tst/testinstall/files/invalidtestfile.txt @@ -0,0 +1,8 @@ +# This file contains some valid GAP code which is not +# a valid tst file, to check error reporting. +# +# It has a ".txt" extension to avoid it being found by +# Any code which looks through testinstall for .g or .tst files + +x := 3; +g := SymmetricGroup(5); \ No newline at end of file diff --git a/tst/testinstall/files/test.tst b/tst/testinstall/files/test.tst new file mode 100644 index 00000000000..dcd24e3c6e4 --- /dev/null +++ b/tst/testinstall/files/test.tst @@ -0,0 +1,11 @@ +gap> START_TEST("test.tst"); +gap> dir := DirectoriesLibrary("tst/testinstall/files");; +gap> Test(Filename(dir,"empty.txt")); +#I Test: File does not contain any tests! +true +gap> Test(Filename(dir,"invalidtestfile.txt")); +#I Test: File does not contain any tests! +true +gap> Test(Filename(dir, "tinytest.txt")); +true +gap> STOP_TEST("test.tst"); diff --git a/tst/testinstall/files/tinytest.txt b/tst/testinstall/files/tinytest.txt new file mode 100644 index 00000000000..ba8083c5827 --- /dev/null +++ b/tst/testinstall/files/tinytest.txt @@ -0,0 +1 @@ +gap> 1;;