Of course D compilers have different flags to set some important D-specific settings. This adds a simple method to change these flags in a compiler-agnostic way in Meson. This replaces the previous `unittest_args` method with a more generic variant.pull/2263/head
parent
e1fc17ef2a
commit
d83c289442
6 changed files with 153 additions and 9 deletions
@ -0,0 +1,51 @@ |
||||
|
||||
import std.stdio; |
||||
import std.array : split; |
||||
import std.string : strip; |
||||
|
||||
auto getMenu () |
||||
{ |
||||
auto foods = import ("food.txt").strip.split ("\n"); |
||||
return foods; |
||||
} |
||||
|
||||
auto getPeople () |
||||
{ |
||||
return import ("people.txt").strip.split ("\n"); |
||||
} |
||||
|
||||
void main (string[] args) |
||||
{ |
||||
import std.array : join; |
||||
import core.stdc.stdlib : exit; |
||||
|
||||
immutable request = args[1]; |
||||
if (request == "menu") { |
||||
version (No_Menu) { |
||||
} else { |
||||
writeln ("On the menu: ", getMenu.join (", ")); |
||||
exit (0); |
||||
} |
||||
} |
||||
|
||||
version (With_People) { |
||||
if (request == "people") { |
||||
writeln ("People: ", getPeople.join (", ")); |
||||
exit (0); |
||||
} |
||||
} |
||||
|
||||
// we fail here
|
||||
exit (1); |
||||
} |
||||
|
||||
unittest |
||||
{ |
||||
writeln ("TEST"); |
||||
import core.stdc.stdlib : exit; |
||||
|
||||
writeln(getMenu); |
||||
assert (getMenu () == ["Spam", "Eggs", "Spam", "Baked Beans", "Spam", "Spam"]); |
||||
|
||||
exit (0); |
||||
} |
@ -0,0 +1,6 @@ |
||||
Spam |
||||
Eggs |
||||
Spam |
||||
Baked Beans |
||||
Spam |
||||
Spam |
@ -0,0 +1,5 @@ |
||||
Rick |
||||
Morty |
||||
Summer |
||||
Beth |
||||
Jerry |
@ -0,0 +1,28 @@ |
||||
project('D Features', 'd') |
||||
dc = meson.get_compiler('d') |
||||
|
||||
# directory for data |
||||
data_dir = join_paths(meson.current_source_dir(), 'data') |
||||
|
||||
# test string import dirs only |
||||
dfeatures_simple = dc.feature_args(import_dirs: [data_dir]) |
||||
|
||||
e_plain = executable('dapp_menu', 'app.d', d_args: dfeatures_simple) |
||||
test('dapp_menu_t_fail', e_plain, should_fail: true) |
||||
test('dapp_menu_t', e_plain, args: ['menu']) |
||||
|
||||
# test feature versions and string imports |
||||
dfeatures_version = dc.feature_args(import_dirs: [data_dir], versions: ['No_Menu', 'With_People']) |
||||
e_versions = executable('dapp_versions', 'app.d', d_args: dfeatures_version) |
||||
test('dapp_versions_t_fail', e_versions, args: ['menu'], should_fail: true) |
||||
test('dapp_versions_t', e_versions, args: ['people']) |
||||
|
||||
# test everything and unittests |
||||
dfeatures_test = dc.feature_args( |
||||
import_dirs: [data_dir], |
||||
versions: ['No_Menu', 'With_People'], |
||||
unittest: true |
||||
) |
||||
e_test = executable('dapp_test', 'app.d', |
||||
d_args: dfeatures_test) |
||||
test('dapp_test', e_test) |
Loading…
Reference in new issue