Skip to content

Commit b1b0933

Browse files
[[ cpptest ]] Adds Google Test submodule and associated build rules
1 parent 04fe961 commit b1b0933

File tree

9 files changed

+235
-1
lines changed

9 files changed

+235
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "thirdparty"]
55
path = thirdparty
66
url = https://github.com/runrev/livecode-thirdparty
7+
[submodule "libcpptest/googletest"]
8+
path = libcpptest/googletest
9+
url = https://github.com/google/googletest.git

config/cpptest.gypi

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'test-<(module_name)',
5+
'type': 'executable',
6+
7+
'dependencies':
8+
[
9+
'libcpptest'
10+
],
11+
12+
'sources':
13+
[
14+
'<!@(ls -1 test/*.cpp)',
15+
],
16+
},
17+
],
18+
19+
'conditions':
20+
[
21+
[
22+
'OS == "emscripten"',
23+
{
24+
'targets':
25+
[
26+
{
27+
'target_name': 'test-<(module_name)-javascriptify',
28+
'type': 'none',
29+
30+
'dependencies':
31+
[
32+
'test-<(module_name)',
33+
],
34+
35+
'actions':
36+
[
37+
{
38+
'action_name': 'test-<(module_name)-javascriptify',
39+
'message': 'Javascript-ifying test-<(module_name)',
40+
41+
'inputs':
42+
[
43+
'../engine/emscripten-javascriptify.py',
44+
'<(PRODUCT_DIR)/test-<(module_name).bc',
45+
],
46+
47+
'outputs':
48+
[
49+
'<(PRODUCT_DIR)/test-<(module_name).js',
50+
'<(PRODUCT_DIR)/test-<(module_name).html',
51+
'<(PRODUCT_DIR)/test-<(module_name).html.mem',
52+
],
53+
54+
'action':
55+
[
56+
'../engine/emscripten-javascriptify.py',
57+
'--input',
58+
'<(PRODUCT_DIR)/test-<(module_name).bc',
59+
'--output',
60+
'<(PRODUCT_DIR)/test-<(module_name).html',
61+
],
62+
},
63+
],
64+
},
65+
],
66+
},
67+
],
68+
],
69+
}

config/emscripten.gypi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
],
3737
},
3838
],
39+
[
40+
'_toolset == "target" and _type == "executable"',
41+
{
42+
'product_extension': 'bc',
43+
},
44+
],
3945
],
4046
},
4147
}

engine/engine.gyp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@
435435
[
436436
'OS == "emscripten"',
437437
{
438-
'product_name': 'standalone-community.bc',
439438
'all_dependent_settings':
440439
{
441440
'variables':

libcpptest/googletest

Submodule googletest added at 0dd5ef8

libcpptest/libcpptest.gyp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
'variables':
3+
{
4+
'module_name': 'libcpptest',
5+
},
6+
7+
'includes':
8+
[
9+
'../common.gypi',
10+
'../config/cpptest.gypi',
11+
],
12+
13+
'targets':
14+
[
15+
{
16+
'target_name': 'libcpptest',
17+
'type': 'static_library',
18+
19+
'variables':
20+
{
21+
'library_for_module': 1,
22+
},
23+
24+
'include_dirs':
25+
[
26+
'googletest/googletest/include',
27+
'googletest/googletest',
28+
],
29+
30+
'sources':
31+
[
32+
'googletest/googletest/src/gtest-all.cc',
33+
'src/gtest_main.cpp',
34+
],
35+
36+
'defines':
37+
[
38+
'GTEST_HAS_POSIX_RE=0',
39+
'GTEST_HAS_PTHREAD=0',
40+
'GTEST_HAS_RTTI=0',
41+
],
42+
43+
'all_dependent_settings':
44+
{
45+
'defines':
46+
[
47+
'GTEST_HAS_POSIX_RE=0',
48+
'GTEST_HAS_PTHREAD=0',
49+
'GTEST_HAS_RTTI=0',
50+
],
51+
52+
'include_dirs':
53+
[
54+
'googletest/googletest/include',
55+
],
56+
},
57+
58+
'conditions':
59+
[
60+
[
61+
'OS == "emscripten"',
62+
{
63+
'include_dirs':
64+
[
65+
'$(EMSCRIPTEN)/system/lib/libcxxabi/include',
66+
],
67+
68+
'all_dependent_settings':
69+
{
70+
'include_dirs':
71+
[
72+
'$(EMSCRIPTEN)/system/lib/libcxxabi/include',
73+
],
74+
},
75+
},
76+
],
77+
],
78+
},
79+
],
80+
}

libcpptest/src/gtest_main.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Copyright (C) 2003-2015 LiveCode Ltd.
2+
3+
This file is part of LiveCode.
4+
5+
LiveCode is free software; you can redistribute it and/or modify it under
6+
the terms of the GNU General Public License v3 as published by the Free
7+
Software Foundation.
8+
9+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
16+
17+
#include "gtest/gtest.h"
18+
19+
int main(int argc, char **argv) {
20+
testing::InitGoogleTest(&argc, argv);
21+
return RUN_ALL_TESTS();
22+
}

libcpptest/test/trivial.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Copyright (C) 2003-2015 LiveCode Ltd.
2+
3+
This file is part of LiveCode.
4+
5+
LiveCode is free software; you can redistribute it and/or modify it under
6+
the terms of the GNU General Public License v3 as published by the Free
7+
Software Foundation.
8+
9+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
16+
17+
#include "gtest/gtest.h"
18+
19+
TEST(trivial, trivial)
20+
//
21+
// Trivial test to check the test runner is functional.
22+
//
23+
{
24+
ASSERT_TRUE(true);
25+
}

livecode.gyp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,34 @@
180180
'files': [ '>@(dist_files)', '>@(dist_aux_files)', ],
181181
}],
182182
},
183+
184+
{
185+
'target_name': 'cpptest-all',
186+
'type': 'none',
187+
188+
'variables':
189+
{
190+
'javascriptify': ''
191+
},
192+
193+
'conditions':
194+
[
195+
[
196+
'OS == "emscripten"',
197+
{
198+
'variables':
199+
{
200+
'javascriptify': '-javascriptify'
201+
},
202+
},
203+
],
204+
],
205+
206+
'dependencies':
207+
[
208+
'libcpptest/libcpptest.gyp:test-libcpptest<(javascriptify)',
209+
],
210+
211+
},
183212
],
184213
}

0 commit comments

Comments
 (0)