From: Joel Rosdahl Date: Sat, 24 Aug 2019 12:49:16 +0000 (+0200) Subject: Extract Catch2 main to a separate object file X-Git-Tag: v4.0~816 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fc9afc66eaf558d1914d4627f9823ad27cac05c;p=thirdparty%2Fccache.git Extract Catch2 main to a separate object file This way the Catch2 object file (which takes a long time to compile) won’t be invalidated each time ccache.hpp is updated. --- diff --git a/Makefile.in b/Makefile.in index d0e7075ab..9ef3aa26e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) diff --git a/dev.mk.in b/dev.mk.in index 1b8b0883c..5663ec6e4 100644 --- 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 index 000000000..9d3b33646 --- /dev/null +++ b/unittest/catch2_tests.cpp @@ -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 + +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 index 000000000..f86b15e35 --- /dev/null +++ b/unittest/catch2_tests.hpp @@ -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); diff --git a/unittest/main.cpp b/unittest/main.cpp index cd16e88ab..f802566dc 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -16,11 +16,9 @@ // 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 - 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) {