]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Extract Catch2 main to a separate object file
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 24 Aug 2019 12:49:16 +0000 (14:49 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 5 Sep 2019 20:04:43 +0000 (22:04 +0200)
This way the Catch2 object file (which takes a long time to compile)
won’t be invalidated each time ccache.hpp is updated.

Makefile.in
dev.mk.in
unittest/catch2_tests.cpp [new file with mode: 0644]
unittest/catch2_tests.hpp [new file with mode: 0644]
unittest/main.cpp

index d0e7075ab5378dc9a0848288e9b6d0323f0e378d..9ef3aa26ee65e38b342ffdec388593795affd0f6 100644 (file)
@@ -85,7 +85,10 @@ test_suites += unittest/test_lockfile.cpp
 test_suites += unittest/test_stats.cpp
 test_suites += unittest/test_util.cpp
 
-test_sources = unittest/main.cpp unittest/framework.cpp unittest/util.cpp
+test_sources += unittest/catch2_tests.cpp
+test_sources += unittest/framework.cpp
+test_sources += unittest/main.cpp
+test_sources += unittest/util.cpp
 test_sources += $(test_suites)
 test_objs = $(test_sources:.cpp=.o)
 
index 1b8b0883ca95ecaa8ffaa39812ede412b998736a..5663ec6e4903c383da334ba6a571604ea660cf32 100644 (file)
--- a/dev.mk.in
+++ b/dev.mk.in
@@ -92,7 +92,9 @@ source_dist_files = \
     src/main.cpp \
     src/third_party/minitrace.c \
     test/run \
-    test/suites/*.bash
+    test/suites/*.bash \
+    unittest/catch2_tests.cpp \
+    unittest/catch2_tests.hpp
 
 dist_files = \
     $(addprefix $(srcdir)/, $(source_dist_files)) \
diff --git a/unittest/catch2_tests.cpp b/unittest/catch2_tests.cpp
new file mode 100644 (file)
index 0000000..9d3b336
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (C) 2019 Joel Rosdahl and other contributors
+//
+// See doc/AUTHORS.adoc for a complete list of contributors.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+#include "catch2_tests.hpp"
+
+#define CATCH_CONFIG_RUNNER
+#include <catch.hpp>
+
+int
+run_catch2_tests(int argc, char** argv)
+{
+  return Catch::Session().run(argc, argv);
+}
diff --git a/unittest/catch2_tests.hpp b/unittest/catch2_tests.hpp
new file mode 100644 (file)
index 0000000..f86b15e
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright (C) 2019 Joel Rosdahl and other contributors
+//
+// See doc/AUTHORS.adoc for a complete list of contributors.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+#pragma once
+
+int run_catch2_tests(int argc, char** argv);
index cd16e88ab856ad13e1c7184b2c39965ed44f975e..f802566dcf755e9d35dbd1f2f29659398291c43b 100644 (file)
 // this program; if not, write to the Free Software Foundation, Inc., 51
 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
+#include "catch2_tests.hpp"
 #include "framework.hpp"
 
-#define CATCH_CONFIG_RUNNER
-#include <catch.hpp>
-
 unsigned suite_args(unsigned);
 unsigned suite_argument_processing(unsigned);
 unsigned suite_compopt(unsigned);
@@ -60,8 +58,7 @@ main(int argc, char** argv)
   cct_chdir(testdir);
 
   // Run Catch2 tests.
-  Catch::Session session;
-  int result = session.run(argc, argv);
+  int result = run_catch2_tests(argc, argv);
 
   // Run legacy tests.
   if (result == 0) {