From: Richard W.M. Jones Date: Fri, 10 Jan 2020 08:31:06 +0000 (+0000) Subject: tests: Add basic tests. X-Git-Tag: v'0.2'~46 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=2eb51edbee2ed214e23a765ad72e53348476b243;p=goals.git tests: Add basic tests. Use 'make check' to run them. --- diff --git a/Goalfile.in b/Goalfile.in index 5aa349d..3c6bf9d 100644 --- a/Goalfile.in +++ b/Goalfile.in @@ -126,4 +126,17 @@ goal pod2man (page, section) = --release "@PACKAGE_NAME@-@PACKAGE_VERSION@" \ --section %section %< > %@-t mv %@-t %@ -} \ No newline at end of file +} + +#---------------------------------------------------------------------- +# Tests. + +let tests = wrap ("test", wildcard ("tests/*.sh")) + +goal check () = : tests + +goal test (name) = : { + t=`basename %name` + cd tests + ../run ./$t +} diff --git a/Makefile.in b/Makefile.in index 8529ad2..29825e7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -19,7 +19,7 @@ # Pass through normal targets to Goalfile.in # XXX Why can't this parse "all" instead of "all ()"? -all clean depend install maintainer-clean: src/goals +all clean depend install check maintainer-clean: src/goals ./run src/goals "$@ ()" # If src/goals doesn't exist then brute-force build it. Once we have diff --git a/tests/00-empty-goalfile.gl b/tests/00-empty-goalfile.gl new file mode 100644 index 0000000..1fc889e --- /dev/null +++ b/tests/00-empty-goalfile.gl @@ -0,0 +1,19 @@ +# Goals test. +# Copyright (C) 2020 Richard W.M. Jones +# Copyright (C) 2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +goal all diff --git a/tests/00-empty-goalfile.sh b/tests/00-empty-goalfile.sh new file mode 100755 index 0000000..71b560d --- /dev/null +++ b/tests/00-empty-goalfile.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Goals test. +# Copyright (C) 2020 Richard W.M. Jones +# Copyright (C) 2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test that goals works with an empty Goalfile (except for the +# mandatory "all" goal). + +goals -f 00-empty-goalfile.gl diff --git a/tests/00-order-linear.gl b/tests/00-order-linear.gl new file mode 100644 index 0000000..fc72ab1 --- /dev/null +++ b/tests/00-order-linear.gl @@ -0,0 +1,24 @@ +# Goals test. +# Copyright (C) 2020 Richard W.M. Jones +# Copyright (C) 2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +goal all = : g1 +goal g1 = : g2 { echo "G1" } +goal g2 = : g3 { echo "G2" } +goal g3 = : g4 { echo "G3" } +goal g4 = : g5 { echo "G4" } +goal g5 = : { echo "G5" } diff --git a/tests/00-order-linear.sh b/tests/00-order-linear.sh new file mode 100755 index 0000000..f2f7ec6 --- /dev/null +++ b/tests/00-order-linear.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Goals test. +# Copyright (C) 2020 Richard W.M. Jones +# Copyright (C) 2020 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test a linear dependency graph is built in the right order. + +goals -f 00-order-linear.gl > 00-order-linear.out +test "$(grep '^G' 00-order-linear.out)" = "G5 +G4 +G3 +G2 +G1" + +rm 00-order-linear.out diff --git a/tests/file1.c b/tests/file1.c deleted file mode 100644 index e69de29..0000000 diff --git a/tests/file2.c b/tests/file2.c deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test1.gl b/tests/test1.gl deleted file mode 100644 index 44c15a2..0000000 --- a/tests/test1.gl +++ /dev/null @@ -1,15 +0,0 @@ -# Test. - -include "url.gl" - -let foo = "bar" - -goal all = : "file1.o", *file("file2.o") - -goal clean = { } - -goal compile (name) = -"%name.o" : "%name.c" { - echo %< "->" %@ - touch %@ -}