summaryrefslogtreecommitdiff
path: root/test/suite
diff options
context:
space:
mode:
Diffstat (limited to 'test/suite')
-rw-r--r--test/suite/ctor_files/ctor.cc.bar1
-rw-r--r--test/suite/ctor_files/ctor.cc.base1
-rw-r--r--test/suite/ctor_files/ctor.cc.generated20
-rw-r--r--test/suite/ctor_files/ctor.cc.multi1
-rw-r--r--test/suite/test.bat13
-rw-r--r--test/suite/test.cc40
-rwxr-xr-xtest/suite/test.sh2
7 files changed, 67 insertions, 11 deletions
diff --git a/test/suite/ctor_files/ctor.cc.bar b/test/suite/ctor_files/ctor.cc.bar
index 218f9cc..ab88379 100644
--- a/test/suite/ctor_files/ctor.cc.bar
+++ b/test/suite/ctor_files/ctor.cc.bar
@@ -23,6 +23,7 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
"-g",
"-Wall",
"-Werror",
+ "-fexceptions",
},
},
.externals = {"bar"},
diff --git a/test/suite/ctor_files/ctor.cc.base b/test/suite/ctor_files/ctor.cc.base
index eab39c4..a8b3c92 100644
--- a/test/suite/ctor_files/ctor.cc.base
+++ b/test/suite/ctor_files/ctor.cc.base
@@ -23,6 +23,7 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
"-g",
"-Wall",
"-Werror",
+ "-fexceptions",
},
},
.externals = {"bar"},
diff --git a/test/suite/ctor_files/ctor.cc.generated b/test/suite/ctor_files/ctor.cc.generated
index 5bc2940..d4b9786 100644
--- a/test/suite/ctor_files/ctor.cc.generated
+++ b/test/suite/ctor_files/ctor.cc.generated
@@ -17,12 +17,32 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
.sources = {
{ "world.cc", ctor::source_type::generated },
},
+ .flags = {
+ .cxxflags = {
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-fexceptions",
+ },
+ },
},
{
.target = "foo",
.sources = {
{ "foo.cc", ctor::source_type::generated },
},
+ .flags = {
+ .cxxflags = {
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-fexceptions",
+ },
+ },
},
{
.target = "this_is_unused",
diff --git a/test/suite/ctor_files/ctor.cc.multi b/test/suite/ctor_files/ctor.cc.multi
index 2b88afe..157d96c 100644
--- a/test/suite/ctor_files/ctor.cc.multi
+++ b/test/suite/ctor_files/ctor.cc.multi
@@ -25,6 +25,7 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
"-g",
"-Wall",
"-Werror",
+ "-fexceptions",
},
},
.externals = {"bar"},
diff --git a/test/suite/test.bat b/test/suite/test.bat
new file mode 100644
index 0000000..20f0846
--- /dev/null
+++ b/test/suite/test.bat
@@ -0,0 +1,13 @@
+@echo off
+
+set CXX=cl.exe
+set CC=cl.exe
+set AR=lib.exe
+set LD=link.exe
+set CTORDIR=..\..\build
+
+%CXX% /nologo /MT /std:c++20 /D_X86_ /EHsc test.cc /link /out:test.exe
+@if %errorlevel% neq 0 exit /b %errorlevel%
+
+test.exe
+@if %errorlevel% neq 0 exit /b %errorlevel%
diff --git a/test/suite/test.cc b/test/suite/test.cc
index bb62d9d..3c7ce4a 100644
--- a/test/suite/test.cc
+++ b/test/suite/test.cc
@@ -21,8 +21,13 @@ int fail(int value = 1,
exit(value);
}
+#if _MSC_VER && !__INTEL_COMPILER
+const std::string ctor_exe{"ctor.exe"};
+const std::string obj_ext{".obj"};
+#else
const std::string ctor_exe{"./ctor"};
const std::string obj_ext{".o"};
+#endif
void run_ctor(const std::vector<std::string>& args,
const std::source_location location = std::source_location::current())
@@ -38,7 +43,7 @@ void run_ctor(const std::vector<std::string>& args,
void assert_not_exists(const std::string& path,
const std::source_location location = std::source_location::current())
{
- if(!std::filesystem::exists(path))
+ if(std::filesystem::exists(path))
{
fail(1, location);
}
@@ -47,7 +52,7 @@ void assert_not_exists(const std::string& path,
void assert_exists(const std::string& path,
const std::source_location location = std::source_location::current())
{
- if(std::filesystem::exists(path))
+ if(!std::filesystem::exists(path))
{
fail(1, location);
}
@@ -128,18 +133,28 @@ int main()
// Wipe the board
std::filesystem::remove_all(BUILDDIR);
+#if _MSC_VER && !__INTEL_COMPILER
+ std::filesystem::create_directory(BUILDDIR);
+#endif
std::filesystem::remove("configuration.cc");
std::filesystem::remove("config.h");
std::filesystem::remove(ctor_exe);
//////////////////////////////////////////////////////////////////////////////
// bootstrap
+ // TODO: add support for quoted strings with spaces
{
auto cxx_prog = locate(CXX, paths);
std::vector<std::string> args =
+#if _MSC_VER && !__INTEL_COMPILER
+ {"/nologo", "/MT", "/std:c++20", "/D_X86_", "/EHsc", "/I..\\..\\src",
+ "ctor.cc", "/link", "/LIBPATH:"+CTORDIR, "libctor.lib",
+ "/subsystem:console", "/out:" + ctor_exe};
+#else
{"-pthread", "-std=c++20", "-L", CTORDIR, "-lctor", "-I", "../../src",
"ctor.cc", "-o", ctor_exe};
+#endif
if(!CXXFLAGS.empty())
{
auto tokens = argsplit(CXXFLAGS);
@@ -168,8 +183,11 @@ int main()
//////////////////////////////////////////////////////////////////////////////
// check if source file changes are tracked
{
+#if _MSC_VER && !__INTEL_COMPILER
+#else
// No build files should have been created yet
- assert_exists(BUILDDIR);
+ assert_not_exists(BUILDDIR);
+#endif
// capture ctor binary before configure is called
Tracker ctor_bin(ctor_exe);
@@ -181,11 +199,11 @@ int main()
assert_changed(ctor_bin);
// configuration.cc should have been generated now
- assert_not_exists("configuration.cc");
- assert_not_exists("config.h");
+ assert_exists("configuration.cc");
+ assert_exists("config.h");
// Shouldn't compile anything yet - only configure
- assert_exists(BUILDDIR + "/hello-hello_cc" + obj_ext);
+ assert_not_exists(BUILDDIR + "/hello-hello_cc" + obj_ext);
ctor_bin.capture();
@@ -193,7 +211,7 @@ int main()
run_ctor({"-v"});
// Compiled object should now exist
- assert_not_exists(BUILDDIR + "/hello-hello_cc" + obj_ext);
+ assert_exists(BUILDDIR + "/hello-hello_cc" + obj_ext);
// ctor should not have been rebuilt, so binary should be the same
assert_not_changed(ctor_bin);
@@ -298,7 +316,7 @@ int main()
assert_changed(ctor_bin);
// foo.cc should not be generated at this point
- assert_exists(BUILDDIR+"/foo.cc");
+ assert_not_exists(BUILDDIR+"/foo.cc");
auto time_w = std::filesystem::last_write_time(BUILDDIR + "/world.cc");
auto time_wo =
@@ -335,13 +353,13 @@ int main()
run_ctor({"-v", "many_to_one"});
// world.cc should not be generated at this point
- assert_exists(BUILDDIR+"/world.cc");
+ assert_not_exists(BUILDDIR+"/world.cc");
// foo.cc should have been generated at this point
- assert_not_exists(BUILDDIR+"/foo.cc");
+ assert_exists(BUILDDIR+"/foo.cc");
// many_to_one.cc should have been generated
- assert_not_exists(BUILDDIR+"/many_to_one.cc");
+ assert_exists(BUILDDIR+"/many_to_one.cc");
auto time = std::filesystem::last_write_time(BUILDDIR + "/many_to_one.cc");
std::this_thread::sleep_for(1100ms);
diff --git a/test/suite/test.sh b/test/suite/test.sh
index 4638c0d..8272247 100755
--- a/test/suite/test.sh
+++ b/test/suite/test.sh
@@ -1,4 +1,6 @@
#!/bin/bash
+#set -x
+
: ${CXX:=g++}
$CXX $LDFLAGS $CXXFLAGS -std=c++20 -Wall test.cc -o test && ./test