Skip to content

Commit

Permalink
Merge pull request #11483 from keymanapp/refactor/common/10426-test_c…
Browse files Browse the repository at this point in the history
…olor.cpp

refactor(common): move `enabled` declaration into test_color.cpp
  • Loading branch information
mcdurdin authored May 21, 2024
2 parents 399833c + 682e141 commit 8d6a3de
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
5 changes: 5 additions & 0 deletions common/include/test_color.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "test_color.h"

namespace console_color {
bool enabled = false;
};
2 changes: 1 addition & 1 deletion common/include/test_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum ansi_code {
BRIGHT_RED = 196
};

bool enabled = false; // TODO: move to test_color.c because test_color.h cannot be #included in more than 1 file in a project otherwise.
extern bool enabled;

class fg {
ansi_code code;
Expand Down
2 changes: 1 addition & 1 deletion core/tests/unit/kmnkbd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if cpp_compiler.get_id() == 'emscripten'
endif

foreach t : tests
bin = executable(t[0], [t[1], '../emscripten_filesystem.cpp'],
bin = executable(t[0], [t[1], common_test_files],
cpp_args: local_defns + defns + warns,
include_directories: [inc, libsrc],
link_args: links + tests_flags,
Expand Down
8 changes: 4 additions & 4 deletions core/tests/unit/kmx/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if cpp_compiler.get_id() == 'emscripten'
endif

kmx = executable('kmx',
['kmx.cpp', '../emscripten_filesystem.cpp'],
['kmx.cpp', common_test_files],
cpp_args: defns + warns,
include_directories: [inc, libsrc, '../../kmx_test_source'],
link_args: links + tests_flags,
Expand Down Expand Up @@ -176,7 +176,7 @@ subdir('fixtures')
# should work for Linux, macOS, and WASM.
test_path = source_path

key_e = executable('key_list', ['kmx_key_list.cpp', '../emscripten_filesystem.cpp'],
key_e = executable('key_list', ['kmx_key_list.cpp', common_test_files],
cpp_args: defns + warns,
include_directories: [inc, libsrc],
link_args: links + tests_flags,
Expand All @@ -195,7 +195,7 @@ test('key_list', key_e, depends: kbd_log, args: [kbd_obj] )

# test for imx list

imx_e = executable('imx_list', ['kmx_imx.cpp', '../emscripten_filesystem.cpp'],
imx_e = executable('imx_list', ['kmx_imx.cpp', common_test_files],
cpp_args: defns + warns,
include_directories: [inc, libsrc],
link_args: links + tests_flags,
Expand All @@ -213,7 +213,7 @@ kbd_log = custom_target(test_kbd + '.kmx'.underscorify(),
)
test('imx_list', imx_e, depends: kbd_log, args: [kbd_obj] )

external_e = executable('ext_event', ['kmx_external_event.cpp', '../emscripten_filesystem.cpp'],
external_e = executable('ext_event', ['kmx_external_event.cpp', common_test_files],
cpp_args: defns + warns,
include_directories: [inc, libsrc],
link_args: links + tests_flags,
Expand Down
3 changes: 2 additions & 1 deletion core/tests/unit/ldml/ldml_test_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "unicode/uniset.h"
#include "unicode/usetiter.h"

#include <test_color.h>

#define assert_or_return(expr) if(!(expr)) { \
std::wcerr << __FILE__ << ":" << __LINE__ << ": " << \
console_color::fg(console_color::BRIGHT_RED) \
Expand All @@ -49,7 +51,6 @@
namespace km {
namespace tests {

#include <test_color.h>



Expand Down
7 changes: 5 additions & 2 deletions core/tests/unit/ldml/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ else
endif

ldml = executable('ldml',
'ldml.cpp',
['ldml.cpp',
'ldml_test_source.cpp',
'ldml_test_utils.cpp',
common_test_files],
cpp_args: defns + warns,
include_directories: [inc, libsrc, '../../../../developer/src/ext/json'],
link_args: links + tests_flags,
Expand All @@ -66,6 +67,7 @@ ldml = executable('ldml',

e = executable('test_kmx_plus', 'test_kmx_plus.cpp',
'ldml_test_utils.cpp',
common_test_files,
cpp_args: defns + warns,
include_directories: [inc, libsrc, '../../../../developer/src/ext/json'],
link_args: links + tests_flags,
Expand All @@ -76,6 +78,7 @@ test('test_kmx_plus', e, suite: 'ldml')
# run transforms / ldml utilities unit test

t = executable('test_transforms', 'test_transforms.cpp',
common_test_files,
cpp_args: defns + warns,
include_directories: [inc, libsrc, '../../../../developer/src/ext/json'],
link_args: links + tests_flags,
Expand All @@ -92,7 +95,7 @@ if cpp_compiler.get_id() == 'emscripten'
endif

t = executable('test_context_normalization',
['test_context_normalization.cpp', '../emscripten_filesystem.cpp'],
['test_context_normalization.cpp', common_test_files],
cpp_args: defns + warns,
include_directories: [inc, libsrc, '../../../../developer/src/ext/json'],
link_args: links + normalization_tests_flags,
Expand Down
5 changes: 5 additions & 0 deletions core/tests/unit/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
node = find_program('node', required: true)

common_test_files = [
meson.current_source_dir() / 'emscripten_filesystem.cpp',
meson.source_root() / '../common/include/test_color.cpp'
]

hextobin_root = join_paths(meson.source_root(),'..','common','tools','hextobin','build','hextobin.js')
hextobin_cmd = [node, hextobin_root]

Expand Down
6 changes: 4 additions & 2 deletions developer/src/kmcmplib/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ if get_option('full_test')

endif

common_test_files = [ meson.source_root() / '../../../common/include/test_color.cpp' ]

# Test the API endpoints

apitest = executable('api-test', ['api-test.cpp','util_filesystem.cpp','util_callbacks.cpp'],
apitest = executable('api-test', ['api-test.cpp','util_filesystem.cpp','util_callbacks.cpp', common_test_files],
cpp_args: defns + flags,
include_directories: inc,
name_suffix: name_suffix,
Expand All @@ -142,7 +144,7 @@ apitest = executable('api-test', ['api-test.cpp','util_filesystem.cpp','util_cal

test('api-test', apitest, args: [output_path / 'blank_keyboard.kmx'])

usetapitest = executable('uset-api-test', 'uset-api-test.cpp',
usetapitest = executable('uset-api-test', 'uset-api-test.cpp', common_test_files,
cpp_args: defns + flags,
include_directories: inc,
name_suffix: name_suffix,
Expand Down

0 comments on commit 8d6a3de

Please sign in to comment.