| 1 |
project( |
| 2 |
'environment', |
| 3 |
meson_version: '>=1.4.0', |
| 4 |
) |
| 5 |
|
| 6 |
testenv = find_program(files('testenv.py')) |
| 7 |
|
| 8 |
|
| 9 |
env = environment() |
| 10 |
env.unset('foo') |
| 11 |
test('not set', testenv, args: ['foo'], env: env) |
| 12 |
|
| 13 |
testcase expect_error('You cannot set the already unset variable \'foo\'') |
| 14 |
env.set('foo', 'bar') |
| 15 |
endtestcase |
| 16 |
|
| 17 |
testcase expect_error('You cannot append to unset variable \'foo\'') |
| 18 |
env.append('foo', 'bar') |
| 19 |
endtestcase |
| 20 |
|
| 21 |
testcase expect_error('You cannot prepend to unset variable \'foo\'') |
| 22 |
env.prepend('foo', 'bar') |
| 23 |
endtestcase |
| 24 |
|
| 25 |
|
| 26 |
env1 = environment('foo=bar', method: 'append', separator: ':') |
| 27 |
env1.append('foo', 'baz', separator: ':') |
| 28 |
test('append', testenv, args: ['foo', 'bar:baz'], env: env1) |
| 29 |
|
| 30 |
testcase expect_error('You cannot unset the \'foo\' variable because it is already set') |
| 31 |
env1.unset('foo') |
| 32 |
endtestcase |
| 33 |
|
| 34 |
|
| 35 |
env2 = environment(['foo=baz'], method: 'prepend', separator: ':') |
| 36 |
env2.prepend('foo', 'bar', separator: ':') |
| 37 |
test('prepend', testenv, args: ['foo', 'bar:baz'], env: env2) |
| 38 |
|
| 39 |
testcase expect_error('You cannot unset the \'foo\' variable because it is already set') |
| 40 |
env2.unset('foo') |
| 41 |
endtestcase |
| 42 |
|
| 43 |
|
| 44 |
env3 = environment({'foo': 'foobar'}, method: 'set', separator: ':') |
| 45 |
env3.set('foo', 'qux') |
| 46 |
test('reset', testenv, args: ['foo', 'qux'], env: env3) |
| 47 |
|
| 48 |
testcase expect_error('You cannot unset the \'foo\' variable because it is already set') |
| 49 |
env3.unset('foo') |
| 50 |
endtestcase |