From 39c26d6fe007ae6012a3a4d41d8cadcafecc4048 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 14 Jun 2015 18:42:30 +0300 Subject: [PATCH] Can use both main and nomain gtest in same project. Fixes #149. --- dependencies.py | 2 +- test cases/frameworks/2 gtest/meson.build | 4 ++++ test cases/frameworks/2 gtest/test_nomain.cc | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test cases/frameworks/2 gtest/test_nomain.cc diff --git a/dependencies.py b/dependencies.py index aa225336e..ea914d956 100644 --- a/dependencies.py +++ b/dependencies.py @@ -978,7 +978,7 @@ def get_dep_identifier(name, kwargs): modlist = [modlist] for module in modlist: elements.append(module) - return '/'.join(elements) + return '/'.join(elements) + '/main' + str(kwargs.get('main', False)) def find_external_dependency(name, environment, kwargs): required = kwargs.get('required', True) diff --git a/test cases/frameworks/2 gtest/meson.build b/test cases/frameworks/2 gtest/meson.build index 50499a5e3..419f451b7 100644 --- a/test cases/frameworks/2 gtest/meson.build +++ b/test cases/frameworks/2 gtest/meson.build @@ -1,6 +1,10 @@ project('gtest', 'cpp') gtest = dependency('gtest', main : true) +gtest_nomain = dependency('gtest', main : false) e = executable('testprog', 'test.cc', dependencies : gtest) test('gtest test', e) + +e = executable('testprog_nomain', 'test_nomain.cc', dependencies : gtest_nomain) +test('gtest nomain test', e) diff --git a/test cases/frameworks/2 gtest/test_nomain.cc b/test cases/frameworks/2 gtest/test_nomain.cc new file mode 100644 index 000000000..bd0bcfe41 --- /dev/null +++ b/test cases/frameworks/2 gtest/test_nomain.cc @@ -0,0 +1,14 @@ +#include + +TEST(basic_test, eq_works) { + ASSERT_EQ(0, 1-1) << "Equality is broken. Mass panic!"; +} + +TEST(basic_test, neq_works) { + ASSERT_NE(15, 106) << "Inequal is equal. The foundations of space and time are in jeopardy."; +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}