Use 'make check' to run them.
         --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
+}
 
 # 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
 
--- /dev/null
+# 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
 
--- /dev/null
+#!/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
 
--- /dev/null
+# 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" }
 
--- /dev/null
+#!/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
 
+++ /dev/null
-# 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 %@
-}