From 9e122005cf5aa1ac288f9d7229d1fc2f7d472270 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 31 Jul 2013 21:25:46 +0300 Subject: [PATCH] Can print status info to log in compiles(). --- interpreter.py | 12 +++++++++++- test cases/common/33 try compile/meson.build | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/interpreter.py b/interpreter.py index 26c502139..359e50ce8 100644 --- a/interpreter.py +++ b/interpreter.py @@ -734,11 +734,21 @@ class CompilerHolder(InterpreterObject): if len(args) != 1: raise InterpreterException('compiles method takes exactly one argument.') string = args[0] + testname = kwargs.get('testname', '') + if not isinstance(testname, str): + raise InterpreterException('Testname argument must be a string.') if isinstance(string, nodes.StringStatement): string = string.value if not isinstance(string, str): raise InterpreterException('Argument to compiles() must be a string') - return self.compiler.compiles(string) + result = self.compiler.compiles(string) + if len(testname) > 0: + if result: + h = mlog.green('YES') + else: + h = mlog.red('NO') + mlog.log('Checking if "', mlog.bold(testname), '" compiles : ', h, sep='') + return result def has_header_method(self, args, kwargs): if len(args) != 1: diff --git a/test cases/common/33 try compile/meson.build b/test cases/common/33 try compile/meson.build index da3978439..010e844f5 100644 --- a/test cases/common/33 try compile/meson.build +++ b/test cases/common/33 try compile/meson.build @@ -9,10 +9,10 @@ void func() { printf("This won't work.\n"); } ''' compiler = meson.get_compiler('c') -if compiler.compiles(code) == false +if compiler.compiles(code, testname : 'should succeed') == false error('Compiler is fail.') endif -if compiler.compiles(breakcode) +if compiler.compiles(breakcode, testname : 'should fail') error('Compiler returned true on broken code.') endif