aboutsummaryrefslogtreecommitdiff
path: root/tests/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-04-11 14:44:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-04-30 16:56:08 +0200
commita14b9bc18431c6aed8441261d28b6ff20bd25935 (patch)
treeae1f07caef838b5b03fa3f82a2cfccbb62b24ed3 /tests/cc
parentca0f9c71be279aee845bf5328ac0af8c02c8849e (diff)
Initial take on header unit and include translation support
Diffstat (limited to 'tests/cc')
-rw-r--r--tests/cc/modules/buildfile2
-rw-r--r--tests/cc/modules/common.testscript49
-rw-r--r--tests/cc/modules/headers.testscript31
-rw-r--r--tests/cc/modules/modules.testscript (renamed from tests/cc/modules/testscript)43
-rw-r--r--tests/cc/preprocessed/testscript6
5 files changed, 87 insertions, 44 deletions
diff --git a/tests/cc/modules/buildfile b/tests/cc/modules/buildfile
index 1c998f4..9136224 100644
--- a/tests/cc/modules/buildfile
+++ b/tests/cc/modules/buildfile
@@ -5,4 +5,4 @@
# Test C++ modules support.
#
-./: testscript $b
+./: testscript{* -common} file{common.testscript} $b
diff --git a/tests/cc/modules/common.testscript b/tests/cc/modules/common.testscript
new file mode 100644
index 0000000..4f043c9
--- /dev/null
+++ b/tests/cc/modules/common.testscript
@@ -0,0 +1,49 @@
+# file : tests/cc/modules/common.testscript
+# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+crosstest = false
+test.arguments = config.cxx="$recall($cxx.path)"
+
+.include ../../common.testscript
+
++cat <<EOI >+build/bootstrap.build
+using test
+EOI
+
++cat <<EOI >=build/root.build
+cxx.std = experimental
+
+cxx.features.symexport = true
+
+# Force modules.
+#
+cxx.features.modules = true
+
+using cxx
+
+# We forced modules but for VC we need at least 15u5 (19.12). So "unforce"
+# them in this case.
+#
+if ($cxx.id == 'msvc' && $cxx.version.major == 19 && $cxx.version.minor < 12)
+ cxx.features.modules = false
+
+hxx{*}: extension = hxx
+mxx{*}: extension = mxx
+cxx{*}: extension = cxx
+
+if ($cxx.target.class == 'windows')
+ bmis{*}: cxx.poptions += '-DLIBFOO_EXPORT=__declspec(dllexport)'
+
+exe{*}: test = true
+EOI
+
+# Determine if we have modules and header units support.
+#
++$* noop <<EOI | set modules
+print $cxx.features.modules
+EOI
+
++$* noop <<EOI | set headers
+print ($cxx.features.modules && $cxx.id == 'gcc')
+EOI
diff --git a/tests/cc/modules/headers.testscript b/tests/cc/modules/headers.testscript
new file mode 100644
index 0000000..43a200e
--- /dev/null
+++ b/tests/cc/modules/headers.testscript
@@ -0,0 +1,31 @@
+# file : tests/cc/modules/headers.testscript
+# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+# Test header units.
+#
+
+.include common.testscript
+
++$headers || exit
+
+: include-translation
+:
+cat <<EOI >=core.hxx;
+ #ifdef CORE_IN
+ # error macro isolation
+ #endif
+ #define CORE_OUT 1
+ inline int f () {return 1;}
+ EOI
+cat <<EOI >=driver.cxx;
+ #define CORE_IN 1
+ #include "core.hxx"
+ #ifndef CORE_OUT
+ # error macro export
+ #endif
+ int main () {return f () - 1 /* CORE_OUT */;}
+ EOI
+$* test clean config.cxx.header_units="$~/core.hxx" &$~/../build/cc/*** <<EOI
+ exe{test}: cxx{driver}
+ EOI
diff --git a/tests/cc/modules/testscript b/tests/cc/modules/modules.testscript
index b5b94c1..87b104d 100644
--- a/tests/cc/modules/testscript
+++ b/tests/cc/modules/modules.testscript
@@ -1,48 +1,11 @@
-# file : tests/cc/modules/testscript
+# file : tests/cc/modules/modules.testscript
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-crosstest = false
-test.arguments = config.cxx="$recall($cxx.path)"
-
-.include ../../common.testscript
-
-+cat <<EOI >+build/bootstrap.build
-using test
-EOI
-
-+cat <<EOI >=build/root.build
-cxx.std = experimental
-
-cxx.features.symexport = true
-
-# Force modules.
+# Test modules proper.
#
-cxx.features.modules = true
-using cxx
-
-# We forced modules but for VC we need at least 15u5 (19.12). So "unforce"
-# them in this case.
-#
-if ($cxx.id == 'msvc' && $cxx.version.major == 19 && $cxx.version.minor < 12)
- cxx.features.modules = false
-
-hxx{*}: extension = hxx
-mxx{*}: extension = mxx
-cxx{*}: extension = cxx
-
-if ($cxx.target.class == 'windows')
- bmis{*}: cxx.poptions += '-DLIBFOO_EXPORT=__declspec(dllexport)'
-
-exe{*}: test = true
-EOI
-
-# Determine if we have module support.
-#
-+$* noop <<EOI | set modules
-print $cxx.features.modules
-EOI
+.include common.testscript
+$modules || exit
diff --git a/tests/cc/preprocessed/testscript b/tests/cc/preprocessed/testscript
index 8e36b2d..844e140 100644
--- a/tests/cc/preprocessed/testscript
+++ b/tests/cc/preprocessed/testscript
@@ -9,10 +9,10 @@ test.arguments = config.cxx="$recall($cxx.path)" update
# Trace filter.
#
-# trace: cxx::compile::extract_(headers|modules): target: .../obje{(test).o...}
+# trace: cxx::compile::apply extracting (headers|modules) from: .../obje{(test).o...}
#
filter = sed -n -e \
- \''s/^trace: cxx::compile_rule::extract_([^:]+): target:[^{]+\{([^.]+).*/\1 \2/p'\'
+ \''s/^trace: cxx::compile_rule::apply: extracting ([^ ]+) from[^{]+\{([^.]+).*/\1 \2/p'\'
+cat <<EOI >=build/root.build
cxx.std = latest
@@ -98,7 +98,7 @@ $* &test* <<EOI 2>>EOE != 0
cxx.preprocessed = modules
exe{test}: cxx{test}
EOI
- test.cxx: error: modules support not available or not enabled
+ error: modules support required by cxx{test}
EOE
: all