aboutsummaryrefslogtreecommitdiff
path: root/tests/test/simple/generated
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test/simple/generated')
-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
5 files changed, 41 insertions, 42 deletions
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;
-}