From: Jannik ZANDER Date: Mon, 16 Jul 2018 19:49:48 +0000 (+0200) Subject: Test and source in different dirs X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=090592ed7daea335c826f8d869e5ae2db7e20cb0;p=meson-test.git Test and source in different dirs --- diff --git a/folder1/folder1.h b/folder1/folder1.h index ae3e5bd..ec372ac 100644 --- a/folder1/folder1.h +++ b/folder1/folder1.h @@ -4,4 +4,4 @@ int function1(); int function2(); -#endif // FOLDER1_H \ No newline at end of file +#endif // FOLDER1_H diff --git a/folder1/folder1_test.cpp b/folder1/folder1_test.cpp deleted file mode 100644 index 68d7673..0000000 --- a/folder1/folder1_test.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "gtest/gtest.h" -extern "C" { -#include "folder1.h" -} - -TEST(function1_test, compare1) -{ - ASSERT_EQ(function1(), 1) << "Values are equal function1 == 1"; -} - -TEST(function2_test, compare2) -{ - ASSERT_EQ(function2(), 2) << "Values are equal function2 == 2"; -} - diff --git a/folder1/meson.build b/folder1/meson.build index cd5280e..fb58566 100644 --- a/folder1/meson.build +++ b/folder1/meson.build @@ -1,5 +1,5 @@ -folder1_inc = include_directories('') -folder1_lib = static_library('folder1', 'folder1.c') -folder1_dep = declare_dependency(link_with : folder1_lib, include_directories : folder1_inc) -folder1_tst = executable('test1', 'folder1_test.cpp', dependencies : [gtest, folder1_dep]) -test('test 1', folder1_tst) +folder1_inc = include_directories('.') + +folder1_lib = static_library('folder1', 'folder1.c', include_directories : folder1_inc) + +folder1_dep = declare_dependency(link_with: folder1_lib, include_directories : folder1_inc) diff --git a/folder1_test/folder1_test.cpp b/folder1_test/folder1_test.cpp new file mode 100644 index 0000000..68d7673 --- /dev/null +++ b/folder1_test/folder1_test.cpp @@ -0,0 +1,15 @@ +#include "gtest/gtest.h" +extern "C" { +#include "folder1.h" +} + +TEST(function1_test, compare1) +{ + ASSERT_EQ(function1(), 1) << "Values are equal function1 == 1"; +} + +TEST(function2_test, compare2) +{ + ASSERT_EQ(function2(), 2) << "Values are equal function2 == 2"; +} + diff --git a/folder1_test/meson.build b/folder1_test/meson.build new file mode 100644 index 0000000..2dc1dd8 --- /dev/null +++ b/folder1_test/meson.build @@ -0,0 +1,2 @@ +folder1_tst = executable('test1', 'folder1_test.cpp', dependencies : [gtest, folder1_dep]) +test('test 1', folder1_tst) diff --git a/folder2/folder2_test.cpp b/folder2/folder2_test.cpp deleted file mode 100644 index 6e0d942..0000000 --- a/folder2/folder2_test.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "gtest/gtest.h" -extern "C" { -#include "folder2.h" -} - -TEST(function3_test, compare3) -{ - ASSERT_EQ(function3(), 3) << "Values are equal function3 == 3"; -} diff --git a/folder2/meson.build b/folder2/meson.build index fb87cd2..0059eec 100644 --- a/folder2/meson.build +++ b/folder2/meson.build @@ -1,5 +1,5 @@ -folder2_inc = include_directories('') -folder2_lib = static_library('folder2', 'folder2.c') -folder2_dep = declare_dependency(link_with : folder2_lib, include_directories : folder2_inc, dependencies : folder1_dep) -folder2_tst = executable('test2', 'folder2_test.cpp', dependencies : [gtest, folder2_dep]) -test('test 2', folder2_tst) +folder2_inc = include_directories('.') + +folder2_lib = static_library('folder2', 'folder2.c', include_directories : folder2_inc) + +folder2_dep = declare_dependency(link_with: folder2_lib, include_directories : folder2_inc, dependencies : folder1_dep) diff --git a/folder2_test/folder2_test.cpp b/folder2_test/folder2_test.cpp new file mode 100644 index 0000000..6e0d942 --- /dev/null +++ b/folder2_test/folder2_test.cpp @@ -0,0 +1,9 @@ +#include "gtest/gtest.h" +extern "C" { +#include "folder2.h" +} + +TEST(function3_test, compare3) +{ + ASSERT_EQ(function3(), 3) << "Values are equal function3 == 3"; +} diff --git a/folder2_test/meson.build b/folder2_test/meson.build new file mode 100644 index 0000000..b09c6ba --- /dev/null +++ b/folder2_test/meson.build @@ -0,0 +1,3 @@ +folder2_tst = executable('test2', 'folder2_test.cpp', + dependencies : [gtest, folder2_dep]) +test('test 2', folder2_tst) diff --git a/meson.build b/meson.build index 1ca8186..1dc9707 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,7 @@ project('meson_test','cpp', 'c') gtest = dependency('gtest', main : true, required : false) subdir('folder1') +subdir('folder1_test') subdir('folder2') +subdir('folder2_test')