summaryrefslogtreecommitdiff
path: root/test cases/d/9 features/meson.build
blob: 736ce7535fa34f6dfccab0edeed06b599955a50d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
project('D Features', 'd', meson_version: '>=1.6', default_options : ['debug=false'])

dc = meson.get_compiler('d')

# See: https://dlang.org/changelog/2.111.0.html#dmd.deprecation-version-debug-number
# GDC fails even before that: https://github.com/mesonbuild/meson/pull/11996
if dc.get_id() == 'gcc'
  number_options_supported = dc.version().version_compare('<13')
elif dc.get_id() == 'dmd'
  number_options_supported = dc.version().version_compare('<2.111')
elif dc.get_id() == 'llvm'
  number_options_supported = dc.version().version_compare('<1.41')
else
  error(f'Unknown D compiler id')
endif

# ONLY FOR BACKWARDS COMPATIBILITY.
# DO NOT DO THIS IN NEW CODE!
# USE include_directories() INSTEAD OF BUILDING
# STRINGS TO PATHS MANUALLY!
data_dir = join_paths(meson.current_source_dir(), 'data')

test_src = ['app.d', 'extra.d']

e_plain_bcompat = executable('dapp_menu_bcompat',
    test_src,
    d_import_dirs: [data_dir]
)
test('dapp_menu_t_fail_bcompat', e_plain_bcompat, should_fail: true)
test('dapp_menu_t_bcompat', e_plain_bcompat, args: ['menu'])

# directory for data
# This is the correct way to do this.
data_dir = include_directories('data')

e_plain = executable('dapp_menu',
    test_src,
    d_import_dirs: [data_dir]
)
test('dapp_menu_t_fail', e_plain, should_fail: true)
test('dapp_menu_t', e_plain, args: ['menu'])


# test feature versions and string imports
e_versions = executable('dapp_versions',
    test_src,
    d_import_dirs: [data_dir],
    d_module_versions: ['No_Menu', 'With_People']
)
test('dapp_versions_t_fail', e_versions, args: ['menu'], should_fail: true)
test('dapp_versions_t', e_versions, args: ['people'])

# test everything and unittests
e_test = executable('dapp_test',
    test_src,
    d_import_dirs: [data_dir],
    d_module_versions: ['No_Menu', 'With_People'],
    d_unittest: true
)
test('dapp_test', e_test)

# test version level
if number_options_supported
    e_version_int = executable('dapp_version_int',
        test_src,
        d_import_dirs: [data_dir],
       d_module_versions: ['With_VersionInteger', 3],
    )
    test('dapp_version_int_t', e_version_int, args: ['debug'])

# test version level failure
e_version_int_fail = executable('dapp_version_int_fail',
    test_src,
    d_import_dirs: [data_dir],
    d_module_versions: ['With_VersionInteger', 2],
)
test('dapp_version_int_t_fail', e_version_int_fail, args: ['debug'], should_fail: true)
endif

# test debug conditions: disabled
e_no_debug = executable('dapp_no_debug',
    test_src,
    d_import_dirs: [data_dir],
    d_module_versions: ['With_Debug'],
)
test('dapp_no_debug_t_fail', e_no_debug, args: ['debug'], should_fail: true)

if number_options_supported
    # test debug conditions: enabled
    e_debug = executable('dapp_debug',
        test_src,
        d_import_dirs: [data_dir],
        d_module_versions: ['With_Debug'],
        d_debug: 1,
    )
    test('dapp_debug_t', e_debug, args: ['debug'])

    # test debug conditions: integer
    e_debug_int = executable('dapp_debug_int',
        test_src,
        d_import_dirs: [data_dir],
        d_module_versions: ['With_DebugInteger'],
        d_debug: 3,
    )
    test('dapp_debug_int_t', e_debug_int, args: ['debug'])

    # test with all debug conditions at once, and with redundant values
    e_debug_all = executable('dapp_debug_all',
        test_src,
        d_import_dirs: [data_dir],
        d_module_versions: ['With_DebugAll'],
        d_debug: ['4', 'DebugIdentifier', 2, 'DebugIdentifierUnused'],
    )
    test('dapp_debug_all_t', e_debug_all, args: ['debug'])
endif

# test debug conditions: identifier
e_debug_ident = executable('dapp_debug_ident',
    test_src,
    d_import_dirs: [data_dir],
    d_module_versions: ['With_DebugIdentifier'],
    d_debug: 'DebugIdentifier',
)
test('dapp_debug_ident_t', e_debug_ident, args: ['debug'])