summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ctor.cc47
-rwxr-xr-xtest/suite/test.sh2
-rw-r--r--test/testprog.cc2
-rw-r--r--test/tmpfile.h16
-rw-r--r--test/tools_test.cc5
5 files changed, 57 insertions, 15 deletions
diff --git a/test/ctor.cc b/test/ctor.cc
index ccf1c31..56218f9 100644
--- a/test/ctor.cc
+++ b/test/ctor.cc
@@ -10,15 +10,17 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
return
{
{
+ .name = "testprog",
.type = ctor::target_type::unit_test,
.system = ctor::output_system::build,
.target = "testprog",
.sources = {
- "testprog.cc",
+ {"testprog.cc"},
},
.flags = {
.cxxflags = {
- "-std=c++20", "-O3", "-Wall", "-Werror",
+ "-std=c++20", "-O3", "-Wall",// "-Werror",
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/EHsc"},
},
},
},
@@ -35,9 +37,10 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
.depends = { "testprog", },
.flags = {
.cxxflags = {
- "-std=c++20", "-O3", "-Wall", "-Werror",
+ "-std=c++20", "-O3", "-Wall",// "-Werror",
"-I../src", "-Iuunit",
"-DOUTPUT=\"execute\"",
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/EHsc"},
},
.ldflags = { "-pthread" },
},
@@ -50,12 +53,13 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"tasks_test.cc",
"testmain.cc",
},
- .depends = { "libctor_nomain.a" },
+ .depends = { "libctor_nomain.lib" },
.flags = {
.cxxflags = {
- "-std=c++20", "-O3", "-Wall", "-Werror",
+ "-std=c++20", "-O3", "-Wall",// "-Werror",
"-I../src", "-Iuunit",
"-DOUTPUT=\"tasks\"",
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/EHsc"},
},
.ldflags = { "-pthread" },
},
@@ -68,12 +72,13 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"source_type_test.cc",
"testmain.cc",
},
- .depends = { "libctor_nomain.a" },
+ .depends = { "libctor_nomain.lib" },
.flags = {
.cxxflags = {
- "-std=c++20", "-O3", "-Wall", "-Werror",
+ "-std=c++20", "-O3", "-Wall",// "-Werror",
"-I../src", "-Iuunit",
"-DOUTPUT=\"source_type\"",
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/EHsc"},
},
.ldflags = { "-pthread" },
},
@@ -91,16 +96,17 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
//.depends = { "libctor_nomain.a" },
.flags = {
.cxxflags = {
- "-std=c++20", "-O3", "-Wall", "-Werror",
+ "-std=c++20", "-O3", "-Wall",// "-Werror",
"-I../src", "-Iuunit",
"-DOUTPUT=\"tools\"",
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/EHsc"},
},
},
},
{
.type = ctor::target_type::unit_test_library,
.system = ctor::output_system::build,
- .target = "libctor_nomain.a",
+ .target = "libctor_nomain.lib",
.sources = {
"../src/build.cc",
"../src/configure.cc",
@@ -116,11 +122,32 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"../src/tools.cc",
"../src/util.cc",
"../src/externals_manual.cc",
+ {ctor::toolchain::msvc, "../getopt-for-windows/getopt.c"},
},
.flags = {
+ .cflags = {
+ "-O3",
+// "-g",
+// "-Wall",
+// "-Wconversion",
+// "-Wextra",
+ //"-Werror",
+ "-I../src",
+ {ctor::toolchain::msvc, ctor::c_opt::custom, "/I../getopt-for-windows"},
+ {ctor::toolchain::msvc, ctor::c_opt::custom, "/D_X86_"},
+ {ctor::toolchain::msvc, ctor::c_opt::custom, "/EHsc"},
+ {ctor::toolchain::msvc, ctor::c_opt::custom, "/external:W0"},
+ {ctor::toolchain::msvc, ctor::c_opt::custom, "/D_CRT_SECURE_NO_WARNINGS"},
+ },
.cxxflags = {
- "-std=c++20", "-O3", "-Wall", "-Werror",
+ "-std=c++20", "-O3", "-Wall",// "-Werror",
"-I../src",
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/Igetopt-for-windows"},
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/D_X86_"},
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/EHsc"},
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/external:W0"},
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/D_CRT_SECURE_NO_WARNINGS"},
+ {ctor::toolchain::msvc, ctor::cxx_opt::custom, "/Dstrdup=_strdup"},
},
.ldflags = { "-pthread" },
},
diff --git a/test/suite/test.sh b/test/suite/test.sh
index c112351..23740a9 100755
--- a/test/suite/test.sh
+++ b/test/suite/test.sh
@@ -1,4 +1,6 @@
#!/bin/bash
+#set -x
+
: ${CXX:=g++}
: ${CTORDIR:=../../build}
: ${BUILDDIR:=build}
diff --git a/test/testprog.cc b/test/testprog.cc
index dbfb665..2b6619e 100644
--- a/test/testprog.cc
+++ b/test/testprog.cc
@@ -2,7 +2,7 @@
#include <fstream>
#include <string>
-extern const char **environ; // see 'man environ'
+extern char **environ; // see 'man environ'
int main(int argc, const char* argv[])
{
diff --git a/test/tmpfile.h b/test/tmpfile.h
index 5d114d0..e1a2ff6 100644
--- a/test/tmpfile.h
+++ b/test/tmpfile.h
@@ -4,7 +4,6 @@
#pragma once
#include <cstdlib>
-#include <unistd.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@@ -12,6 +11,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <io.h>
+#else
+#include <unistd.h>
#endif
struct tmp_file
@@ -22,20 +24,28 @@ struct tmp_file
#ifdef _WIN32
char templ[] = "ctor_tmp_file-XXXXXX"; // buffer for filename
_mktemp_s(templ, sizeof(templ));
- fd = open(templ, O_CREAT | O_RDWR);
+ fd = _open(templ, O_CREAT | O_RDWR);
+ filename = templ;
+ auto sz = _write(fd, data.data(), data.size());
+ (void)sz;
+ _close(fd);
#else
char templ[] = "/tmp/ctor_tmp_file-XXXXXX"; // buffer for filename
fd = mkstemp(templ);
-#endif
filename = templ;
auto sz = write(fd, data.data(), data.size());
(void)sz;
close(fd);
+#endif
}
~tmp_file()
{
+#ifdef _WIN32
+ _unlink(filename.data());
+#else
unlink(filename.data());
+#endif
}
const std::string& get() const
diff --git a/test/tools_test.cc b/test/tools_test.cc
index a428ea1..d5f84f4 100644
--- a/test/tools_test.cc
+++ b/test/tools_test.cc
@@ -22,6 +22,9 @@ std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& toolchain)
case ctor::toolchain::clang:
stream << "ctor::toolchain::clang";
break;
+ case ctor::toolchain::msvc:
+ stream << "ctor::toolchain::msvc";
+ break;
}
return stream;
}
@@ -125,7 +128,7 @@ const ctor::configuration& ctor::get_configuration()
return cfg;
}
-const std::string& ctor::configuration::get(const std::string& key, const std::string& defval) const
+std::string ctor::configuration::get(const std::string& key, [[maybe_unused]]const std::string& default_value) const
{
if(key == ctor::cfg::host_cxx)
{