aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-03-23 23:11:04 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-03-23 23:11:04 +0200
commitd289887b1badb079835d0c9734e38150d35e3d15 (patch)
tree8fdaef7edf6bb22c66ece3f11a28d4c97fb64a1d
parent85132e894860b54c39f29c1491e353a12decc5f6 (diff)
downloadmeson-d289887b1badb079835d0c9734e38150d35e3d15.zip
meson-d289887b1badb079835d0c9734e38150d35e3d15.tar.gz
meson-d289887b1badb079835d0c9734e38150d35e3d15.tar.bz2
Add should_fail kwarg to test to indicate tests that should fail.
-rw-r--r--backends.py5
-rw-r--r--interpreter.py8
-rwxr-xr-xmeson_test.py3
-rw-r--r--test cases/common/75 should fail/failing.c3
-rw-r--r--test cases/common/75 should fail/meson.build4
5 files changed, 18 insertions, 5 deletions
diff --git a/backends.py b/backends.py
index f00e76c..cb59453 100644
--- a/backends.py
+++ b/backends.py
@@ -87,7 +87,7 @@ def do_conf_file(src, dst, confdata):
class TestSerialisation:
def __init__(self, name, fname, is_cross, exe_wrapper, is_parallel, cmd_args, env,
- valgrind_args):
+ should_fail, valgrind_args):
self.name = name
self.fname = fname
self.is_cross = is_cross
@@ -95,6 +95,7 @@ class TestSerialisation:
self.is_parallel = is_parallel
self.cmd_args = cmd_args
self.env = env
+ self.should_fail = should_fail
self.valgrind_args = valgrind_args
# This class contains the basic functionality that is needed by all backends.
@@ -315,7 +316,7 @@ class Backend():
else:
exe_wrapper = None
ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper,
- t.is_parallel, t.cmd_args, t.env, t.valgrind_args)
+ t.is_parallel, t.cmd_args, t.env, t.should_fail, t.valgrind_args)
arr.append(ts)
pickle.dump(arr, datafile)
diff --git a/interpreter.py b/interpreter.py
index 9aae7a4..dfd5330 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -429,13 +429,14 @@ class RunTargetHolder(InterpreterObject):
self.held_object = build.RunTarget(name, command, args, subdir)
class Test(InterpreterObject):
- def __init__(self, name, exe, is_parallel, cmd_args, env, valgrind_args):
+ def __init__(self, name, exe, is_parallel, cmd_args, env, should_fail, valgrind_args):
InterpreterObject.__init__(self)
self.name = name
self.exe = exe
self.is_parallel = is_parallel
self.cmd_args = cmd_args
self.env = env
+ self.should_fail = should_fail
self.valgrind_args = valgrind_args
def get_exe(self):
@@ -1310,7 +1311,10 @@ class Interpreter():
for a in valgrind_args:
if not isinstance(a, str):
raise InterpreterException('Valgrind_arg not a string.')
- t = Test(args[0], args[1].held_object, par, cmd_args, env, valgrind_args)
+ should_fail = kwargs.get('should_fail', False)
+ if not isinstance(should_fail, bool):
+ raise InterpreterException('Keyword argument should_fail must be a boolean.')
+ t = Test(args[0], args[1].held_object, par, cmd_args, env, should_fail, valgrind_args)
self.build.tests.append(t)
mlog.debug('Adding test "', mlog.bold(args[0]), '".', sep='')
diff --git a/meson_test.py b/meson_test.py
index 533cd87..51a7db6 100755
--- a/meson_test.py
+++ b/meson_test.py
@@ -99,7 +99,8 @@ def run_single_test(wrap, test):
duration = endtime - starttime
stdo = stdo.decode()
stde = stde.decode()
- if p.returncode == 0:
+ if (not test.should_fail and p.returncode == 0) or \
+ (test.should_fail and p.returncode != 0):
res = 'OK'
else:
res = 'FAIL'
diff --git a/test cases/common/75 should fail/failing.c b/test cases/common/75 should fail/failing.c
new file mode 100644
index 0000000..adada8d
--- /dev/null
+++ b/test cases/common/75 should fail/failing.c
@@ -0,0 +1,3 @@
+int main(int argc, char **argv) {
+ return 1;
+}
diff --git a/test cases/common/75 should fail/meson.build b/test cases/common/75 should fail/meson.build
new file mode 100644
index 0000000..dffbbb3
--- /dev/null
+++ b/test cases/common/75 should fail/meson.build
@@ -0,0 +1,4 @@
+project('should fail', 'c')
+
+exe = executable('prog', 'failing.c')
+test('failing', exe, should_fail : true)