Add test to check that D feature flags get applied to all files
This adds regression tests for issue #3337
This commit is contained in:
parent
b4aee4675a
commit
ad2ab56e5f
|
@ -23,10 +23,14 @@ unittest
|
||||||
{
|
{
|
||||||
writeln ("TEST");
|
writeln ("TEST");
|
||||||
import core.stdc.stdlib : exit;
|
import core.stdc.stdlib : exit;
|
||||||
|
import second_unit;
|
||||||
|
|
||||||
assert (getFour () > 2);
|
assert (getFour () > 2);
|
||||||
assert (getFour () == 4);
|
assert (getFour () == 4);
|
||||||
|
|
||||||
|
// this is a regression test for https://github.com/mesonbuild/meson/issues/3337
|
||||||
|
secondModuleTestFunc ();
|
||||||
|
|
||||||
// we explicitly terminate here to give the unittest program a different exit
|
// we explicitly terminate here to give the unittest program a different exit
|
||||||
// code than the main application has.
|
// code than the main application has.
|
||||||
// (this prevents the regular main() from being executed)
|
// (this prevents the regular main() from being executed)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
project('D Unittests', 'd')
|
project('D Unittests', 'd')
|
||||||
|
|
||||||
e = executable('dapp', 'app.d', install : true)
|
e = executable('dapp', ['app.d', 'second_unit.d'], install : true)
|
||||||
test('dapp_run', e, should_fail: true)
|
test('dapp_run', e, should_fail: true)
|
||||||
|
|
||||||
e_test = executable('dapp_test', 'app.d',
|
e_test = executable('dapp_test', ['app.d', 'second_unit.d'],
|
||||||
d_args: meson.get_compiler('d').unittest_args())
|
d_unittest: true)
|
||||||
test('dapp_test', e_test)
|
test('dapp_test', e_test)
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
void secondModuleTestFunc ()
|
||||||
|
{
|
||||||
|
import std.stdio : writeln;
|
||||||
|
|
||||||
|
version (unittest)
|
||||||
|
writeln ("Hello!");
|
||||||
|
else
|
||||||
|
assert (0);
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ import std.stdio;
|
||||||
import std.array : split;
|
import std.array : split;
|
||||||
import std.string : strip;
|
import std.string : strip;
|
||||||
|
|
||||||
|
import extra;
|
||||||
|
|
||||||
auto getMenu ()
|
auto getMenu ()
|
||||||
{
|
{
|
||||||
auto foods = import ("food.txt").strip.split ("\n");
|
auto foods = import ("food.txt").strip.split ("\n");
|
||||||
|
@ -31,7 +33,12 @@ void main (string[] args)
|
||||||
version (With_People) {
|
version (With_People) {
|
||||||
if (request == "people") {
|
if (request == "people") {
|
||||||
writeln ("People: ", getPeople.join (", "));
|
writeln ("People: ", getPeople.join (", "));
|
||||||
exit (0);
|
|
||||||
|
// only exit successfully if the second module also had its module version set.
|
||||||
|
// this checks for issue https://github.com/mesonbuild/meson/issues/3337
|
||||||
|
if (secondModulePeopleVersionSet ())
|
||||||
|
exit (0);
|
||||||
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
auto secondModulePeopleVersionSet ()
|
||||||
|
{
|
||||||
|
version (With_People) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,8 +6,10 @@ project('D Features', 'd')
|
||||||
# STRINGS TO PATHS MANUALLY!
|
# STRINGS TO PATHS MANUALLY!
|
||||||
data_dir = join_paths(meson.current_source_dir(), 'data')
|
data_dir = join_paths(meson.current_source_dir(), 'data')
|
||||||
|
|
||||||
|
test_src = ['app.d', 'extra.d']
|
||||||
|
|
||||||
e_plain_bcompat = executable('dapp_menu_bcompat',
|
e_plain_bcompat = executable('dapp_menu_bcompat',
|
||||||
'app.d',
|
test_src,
|
||||||
d_import_dirs: [data_dir]
|
d_import_dirs: [data_dir]
|
||||||
)
|
)
|
||||||
test('dapp_menu_t_fail_bcompat', e_plain_bcompat, should_fail: true)
|
test('dapp_menu_t_fail_bcompat', e_plain_bcompat, should_fail: true)
|
||||||
|
@ -18,7 +20,7 @@ test('dapp_menu_t_bcompat', e_plain_bcompat, args: ['menu'])
|
||||||
data_dir = include_directories('data')
|
data_dir = include_directories('data')
|
||||||
|
|
||||||
e_plain = executable('dapp_menu',
|
e_plain = executable('dapp_menu',
|
||||||
'app.d',
|
test_src,
|
||||||
d_import_dirs: [data_dir]
|
d_import_dirs: [data_dir]
|
||||||
)
|
)
|
||||||
test('dapp_menu_t_fail', e_plain, should_fail: true)
|
test('dapp_menu_t_fail', e_plain, should_fail: true)
|
||||||
|
@ -27,7 +29,7 @@ test('dapp_menu_t', e_plain, args: ['menu'])
|
||||||
|
|
||||||
# test feature versions and string imports
|
# test feature versions and string imports
|
||||||
e_versions = executable('dapp_versions',
|
e_versions = executable('dapp_versions',
|
||||||
'app.d',
|
test_src,
|
||||||
d_import_dirs: [data_dir],
|
d_import_dirs: [data_dir],
|
||||||
d_module_versions: ['No_Menu', 'With_People']
|
d_module_versions: ['No_Menu', 'With_People']
|
||||||
)
|
)
|
||||||
|
@ -36,7 +38,7 @@ test('dapp_versions_t', e_versions, args: ['people'])
|
||||||
|
|
||||||
# test everything and unittests
|
# test everything and unittests
|
||||||
e_test = executable('dapp_test',
|
e_test = executable('dapp_test',
|
||||||
'app.d',
|
test_src,
|
||||||
d_import_dirs: [data_dir],
|
d_import_dirs: [data_dir],
|
||||||
d_module_versions: ['No_Menu', 'With_People'],
|
d_module_versions: ['No_Menu', 'With_People'],
|
||||||
d_unittest: true
|
d_unittest: true
|
||||||
|
|
Loading…
Reference in New Issue