aboutsummaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-02-09 15:00:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-09 15:00:16 +0200
commitab0d6919707349436edd336bbfa8f433bd6e6749 (patch)
tree864fc885d71ab8205f9c47f0c813b0a48166de33 /tests/test
parentdab05fa5ebea3aaf7107c8acf18a7f17c556a45c (diff)
Fix broken test (and few other things)
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/config-test/testscript5
-rw-r--r--tests/test/script/generated/buildfile2
-rw-r--r--tests/test/script/generated/driver.cxx11
-rw-r--r--tests/test/script/generated/testscript7
-rw-r--r--tests/test/script/generated/testscript.in2
-rw-r--r--tests/test/simple/generated/buildfile4
-rw-r--r--tests/test/simple/generated/driver.cxx25
-rw-r--r--tests/test/simple/generated/input.in1
-rw-r--r--tests/test/simple/generated/testscript25
-rw-r--r--tests/test/simple/generated/utility.cxx28
10 files changed, 47 insertions, 63 deletions
diff --git a/tests/test/config-test/testscript b/tests/test/config-test/testscript
index 7423322..0561a59 100644
--- a/tests/test/config-test/testscript
+++ b/tests/test/config-test/testscript
@@ -75,8 +75,9 @@ EOI
# units/simple - simple (non-scripted) test
#
# This one is a bit tricky since we need an executable to run. We don't want
-# to be building anything as part of our test project so what we do is test
-# a dummy file target with an overridden test target.
+# to be building anything as part of our test project so what we do is test a
+# dummy file target with an overridden test target (note that $src_root here
+# refers to the root of the project being tested).
#
+mkdir proj/units/simple
+touch proj/units/simple/driver
diff --git a/tests/test/script/generated/buildfile b/tests/test/script/generated/buildfile
index c27b49d..524be44 100644
--- a/tests/test/script/generated/buildfile
+++ b/tests/test/script/generated/buildfile
@@ -5,4 +5,4 @@
# Test generated testscripts.
#
-./: test{testscript} $b file{*.cxx +*.in}
+./: test{testscript} $b file{*.in}
diff --git a/tests/test/script/generated/driver.cxx b/tests/test/script/generated/driver.cxx
deleted file mode 100644
index e155462..0000000
--- a/tests/test/script/generated/driver.cxx
+++ /dev/null
@@ -1,11 +0,0 @@
-// file : tests/test/script/generated/driver.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <iostream>
-
-int
-main ()
-{
- std::cout << "1.2.3" << std::endl;
-}
diff --git a/tests/test/script/generated/testscript b/tests/test/script/generated/testscript
index 572c73f..8b9d2ab 100644
--- a/tests/test/script/generated/testscript
+++ b/tests/test/script/generated/testscript
@@ -19,16 +19,11 @@ name: test
version: 1.2.3
EOI
-+cat <<EOI >=build/root.build
-using cxx
-EOI
-
: testscript
:
-ln -s $src_base/driver.cxx ./;
ln -s $src_base/testscript.in ./;
$* <<EOI
-exe{driver}: cxx{driver} test{testscript}
+./: test{testscript}
test{testscript}: in{testscript} $src_root/file{manifest} #@@ in module
test{testscript}: in.symbol = '@'
EOI
diff --git a/tests/test/script/generated/testscript.in b/tests/test/script/generated/testscript.in
index b030b39..297d79d 100644
--- a/tests/test/script/generated/testscript.in
+++ b/tests/test/script/generated/testscript.in
@@ -2,4 +2,4 @@
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-$* >'@version@'
+echo '@version@' >'1.2.3'
diff --git a/tests/test/simple/generated/buildfile b/tests/test/simple/generated/buildfile
index af97abd..2d795a8 100644
--- a/tests/test/simple/generated/buildfile
+++ b/tests/test/simple/generated/buildfile
@@ -5,4 +5,6 @@
# Test generated test inputs/outputs.
#
-./: test{testscript} $b file{*.cxx +*.in}
+./: test{testscript} exe{driver} $b file{*.in}
+
+exe{driver}: cxx{driver}
diff --git a/tests/test/simple/generated/driver.cxx b/tests/test/simple/generated/driver.cxx
index fb3ab8f..a8e5cab 100644
--- a/tests/test/simple/generated/driver.cxx
+++ b/tests/test/simple/generated/driver.cxx
@@ -2,10 +2,31 @@
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
+#include <string>
+#include <fstream>
#include <iostream>
+using namespace std;
+
int
-main ()
+main (int argc, char* argv[])
{
- std::cout << "1.2.3" << std::endl;
+ int r (0);
+
+ if (argc == 1)
+ {
+ cout << "1.2.3" << endl;
+ }
+ else
+ {
+ ifstream ifs (argv[1]);
+
+ if (!ifs.is_open ())
+ cerr << "unable to open " << argv[1] << endl;
+
+ string s;
+ r = getline (ifs, s) && s == "1.2.3" ? 0 : 1;
+ }
+
+ return r;
}
diff --git a/tests/test/simple/generated/input.in b/tests/test/simple/generated/input.in
new file mode 100644
index 0000000..36d79d4
--- /dev/null
+++ b/tests/test/simple/generated/input.in
@@ -0,0 +1 @@
+$version$
diff --git a/tests/test/simple/generated/testscript b/tests/test/simple/generated/testscript
index 9ec5220..f7ab8d6 100644
--- a/tests/test/simple/generated/testscript
+++ b/tests/test/simple/generated/testscript
@@ -17,26 +17,29 @@ name: test
version: 1.2.3
EOI
-+cat <<EOI >=build/root.build
-using cxx
-EOI
+# This one is a bit tricky since we need an executable to run. We don't want
+# to be building anything as part of our test project so what we do is test
+# the directory target with an overridden test target (note that $src_root
+# here refers to the root of the project being tested).
: input
:
-ln -s $src_base/driver.cxx ./;
-ln -s $src_base/utility.cxx ./;
+ln -s $src_base/input.in ./;
$* <<EOI
-exe{utility}: cxx{utility}
-exe{utility}: exe{driver}: test.input = true
-exe{driver}: cxx{driver}
+driver = $src_root/../exe{driver}
+dir{./}: test = $driver # @@ TMP (target/scope regularity)
+./: $driver
+./: file{input}: test.input = true
+file{input}: in{input} $src_root/file{manifest} #@@ in module
EOI
: output
:
-ln -s $src_base/driver.cxx ./;
ln -s $src_base/output.in ./;
$* <<EOI
-exe{driver}: cxx{driver}
-exe{driver}: file{output}: test.stdout = true
+driver = $src_root/../exe{driver}
+dir{./}: test = $driver # @@ TMP (target/scope regularity)
+./: $driver
+./: file{output}: test.stdout = true
file{output}: in{output} $src_root/file{manifest} #@@ in module
EOI
diff --git a/tests/test/simple/generated/utility.cxx b/tests/test/simple/generated/utility.cxx
deleted file mode 100644
index e2113bd..0000000
--- a/tests/test/simple/generated/utility.cxx
+++ /dev/null
@@ -1,28 +0,0 @@
-// file : tests/test/simple/generated/utility.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-
-int
-main (int argc, char* argv[])
-{
- if (argc != 2)
- {
- cerr << "usage: " << argv[0] << " <file>" << endl;
- return 1;
- }
-
- ifstream ifs (argv[1], ifstream::in | ifstream::binary | ifstream::ate);
-
- if (!ifs.is_open ())
- cerr << "unable to open " << argv[1] << endl;
-
- if (ifs.tellg () == 0)
- cerr << argv[1] << " is empty" << endl;
-
- return 0;
-}