From 463f0740e1731c15917ffdb3e2f4b3f4c83aa024 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 31 Oct 2021 16:02:19 +0100 Subject: Change to testdir before executing tests and add global paths variables for easier path testing inside the unit-tests. --- test/testmain.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/testmain.cc (limited to 'test/testmain.cc') diff --git a/test/testmain.cc b/test/testmain.cc new file mode 100644 index 0000000..db8e22c --- /dev/null +++ b/test/testmain.cc @@ -0,0 +1,36 @@ +// -*- c++ -*- +// Distributed under the BSD 2-Clause License. +// See accompanying file LICENSE for details. +#define uUNIT_MAIN +#include "uunit.h" + +#include +#include +#include + +namespace paths +{ +std::string argv_0; +std::filesystem::path top_srcdir; +std::filesystem::path top_builddir; +std::filesystem::path testdir; +} + +int main(int argc, char* argv[]) +{ + (void)argc; + + paths::argv_0 = argv[0]; + + auto cur = std::filesystem::current_path(); + paths::testdir = std::filesystem::path(paths::argv_0).parent_path(); + // assuming /test + paths::top_builddir = paths::testdir.parent_path(); + paths::top_srcdir = std::filesystem::relative(cur, paths::testdir); + + std::filesystem::current_path(paths::testdir); + + std::ofstream xmlfile; + xmlfile.open("result_" OUTPUT ".xml"); + return uUnit::runTests(xmlfile); +} -- cgit v1.2.3