diff options
author | James Hilliard <james.hilliard1@gmail.com> | 2019-05-26 12:31:43 -0600 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-08-12 01:05:45 +0300 |
commit | b21fd95f737ab96f57c45e15a1d89d5c483daec8 (patch) | |
tree | f19e6f869220b3832d4e586901d10bb059d5a5d8 /test cases | |
parent | 8764e4f579287d2bc15d5ea8b0a5382c90712ec0 (diff) | |
download | meson-b21fd95f737ab96f57c45e15a1d89d5c483daec8.zip meson-b21fd95f737ab96f57c45e15a1d89d5c483daec8.tar.gz meson-b21fd95f737ab96f57c45e15a1d89d5c483daec8.tar.bz2 |
Add is_disabler function
This is useful if one needs to check if a variable is a disabler.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/common/1 trivial/meson.build | 10 | ||||
-rw-r--r-- | test cases/common/156 index customtarget/meson.build | 22 | ||||
-rw-r--r-- | test cases/common/163 disabler/meson.build | 35 | ||||
-rw-r--r-- | test cases/common/2 cpp/meson.build | 10 | ||||
-rw-r--r-- | test cases/common/3 static/meson.build | 10 | ||||
-rw-r--r-- | test cases/common/4 shared/meson.build | 10 | ||||
-rw-r--r-- | test cases/common/52 custom target/meson.build | 10 |
7 files changed, 107 insertions, 0 deletions
diff --git a/test cases/common/1 trivial/meson.build b/test cases/common/1 trivial/meson.build index c71d9b0..557274f 100644 --- a/test cases/common/1 trivial/meson.build +++ b/test cases/common/1 trivial/meson.build @@ -22,3 +22,13 @@ endif exe = executable('trivialprog', sources : sources) test('runtest', exe) # This is a comment + +has_not_changed = false +if is_disabler(exe) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'Executable has changed.') + +assert(not is_disabler(exe), 'Executable is a disabler.') diff --git a/test cases/common/156 index customtarget/meson.build b/test cases/common/156 index customtarget/meson.build index 27d28b5..b06ceea 100644 --- a/test cases/common/156 index customtarget/meson.build +++ b/test cases/common/156 index customtarget/meson.build @@ -24,11 +24,33 @@ gen = custom_target( command : [prog_python, '@INPUT@', '--header', '@OUTPUT1@', '--code', '@OUTPUT0@'], ) +has_not_changed = false +if is_disabler(gen) + has_not_changed = true +else + has_not_changed = true +endif + +assert(has_not_changed, 'Custom target has changed.') + +assert(not is_disabler(gen), 'Custom target is a disabler.') + lib = static_library( 'libfoo', ['lib.c', gen[1]], ) +has_not_changed = false +if is_disabler(lib) + has_not_changed = true +else + has_not_changed = true +endif + +assert(has_not_changed, 'Static library has changed.') + +assert(not is_disabler(lib), 'Static library is a disabler.') + custom_target( 'foo', input: gen[0], diff --git a/test cases/common/163 disabler/meson.build b/test cases/common/163 disabler/meson.build index 9437ace..5eb24ba 100644 --- a/test cases/common/163 disabler/meson.build +++ b/test cases/common/163 disabler/meson.build @@ -7,6 +7,20 @@ d3 = (d == d2) d4 = d + 0 d5 = d2 or true +has_not_changed = false +if is_disabler(d) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'Disabler has changed.') + +assert(is_disabler(d), 'Disabler was not identified correctly.') +assert(is_disabler(d2), 'Function laundered disabler was not identified correctly.') +assert(is_disabler(d3), 'Disabler comparison should yield disabler.') +assert(is_disabler(d4), 'Disabler addition should yield disabler.') +assert(is_disabler(d5), 'Disabler logic op should yield disabler.') + assert(d, 'Disabler did not cause this to be skipped.') assert(d2, 'Function laundered disabler did not cause this to be skipped.') assert(d3, 'Disabler comparison should yield disabler and thus this would not be called.') @@ -21,6 +35,15 @@ else number = 2 endif +has_not_changed = false +if is_disabler(number) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'Number has changed.') + +assert(not is_disabler(number), 'Number should not be a disabler.') assert(number == 0, 'Plain if handled incorrectly, value should be 0 but is @0@'.format(number)) if d.found() @@ -33,11 +56,23 @@ assert(number == 2, 'If found handled incorrectly, value should be 2 but is @0@' dep = dependency('notfounddep', required : false, disabler : true) app = executable('myapp', 'notfound.c', dependencies : [dep]) +assert(is_disabler(app), 'App is not a disabler.') app = executable('myapp', 'notfound.c', dependencies : [[dep]]) +assert(is_disabler(app), 'App is not a disabler.') cc = meson.get_compiler('c') dep = cc.find_library('notfounddep', required : false, disabler : true) app = executable('myapp', 'notfound.c', dependencies : [dep]) +assert(is_disabler(app), 'App is not a disabler.') dep = find_program('donotfindme', required : false, disabler : true) app = executable('myapp', 'notfound.c', dependencies : [dep]) +assert(is_disabler(app), 'App is not a disabler.') + +has_not_changed = false +if is_disabler(app) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'App has changed.') diff --git a/test cases/common/2 cpp/meson.build b/test cases/common/2 cpp/meson.build index 27c4321..23c8e72 100644 --- a/test cases/common/2 cpp/meson.build +++ b/test cases/common/2 cpp/meson.build @@ -10,3 +10,13 @@ endif exe = executable('trivialprog', 'trivial.cc', extra_files : 'something.txt') test('runtest', exe) + +has_not_changed = false +if is_disabler(exe) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'Executable has changed.') + +assert(not is_disabler(exe), 'Executable is a disabler.') diff --git a/test cases/common/3 static/meson.build b/test cases/common/3 static/meson.build index e539956..84dab95 100644 --- a/test cases/common/3 static/meson.build +++ b/test cases/common/3 static/meson.build @@ -2,3 +2,13 @@ project('static library test', 'c') lib = static_library('mylib', get_option('source'), link_args : '-THISMUSTNOBEUSED') # Static linker needs to ignore all link args. + +has_not_changed = false +if is_disabler(lib) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'Static library has changed.') + +assert(not is_disabler(lib), 'Static library is a disabler.') diff --git a/test cases/common/4 shared/meson.build b/test cases/common/4 shared/meson.build index b2c8fa3..1c88bc5 100644 --- a/test cases/common/4 shared/meson.build +++ b/test cases/common/4 shared/meson.build @@ -1,3 +1,13 @@ project('shared library test', 'c') lib = shared_library('mylib', 'libfile.c') build_target('mylib2', 'libfile.c', target_type: 'shared_library') + +has_not_changed = false +if is_disabler(lib) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'Shared library has changed.') + +assert(not is_disabler(lib), 'Shared library is a disabler.') diff --git a/test cases/common/52 custom target/meson.build b/test cases/common/52 custom target/meson.build index 2e6f69c..824ab48 100644 --- a/test cases/common/52 custom target/meson.build +++ b/test cases/common/52 custom target/meson.build @@ -19,4 +19,14 @@ install : true, install_dir : 'subdir' ) +has_not_changed = false +if is_disabler(mytarget) + has_not_changed = true +else + has_not_changed = true +endif +assert(has_not_changed, 'Custom target has changed.') + +assert(not is_disabler(mytarget), 'Custom target is a disabler.') + subdir('depfile') |