diff --git a/environment.py b/environment.py index 1fb35d0df..0b7e3c61a 100644 --- a/environment.py +++ b/environment.py @@ -162,7 +162,7 @@ class CCompiler(): commands = self.get_exelist() commands.append(srcname) commands += self.get_output_flags(exename) - p = subprocess.Popen(commands, cwd=os.path.split(srcname)[0])#, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + p = subprocess.Popen(commands, cwd=os.path.split(srcname)[0], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) p.communicate() os.remove(srcname) if p.returncode != 0: diff --git a/interpreter.py b/interpreter.py index 75fad0462..45aa3b09f 100644 --- a/interpreter.py +++ b/interpreter.py @@ -671,9 +671,20 @@ class CompilerHolder(InterpreterObject): code = args[0] if isinstance(code, nodes.StringStatement): code = code.get_value() + testname = kwargs.get('name', '') + if not isinstance(testname, str): + raise InterpreterException('Testname argument must be a string.') if not isinstance(code, str): raise InterpreterException('First argument is not a string.') result = self.compiler.run(code) + if len(testname) > 0: + if not result.compiled: + h = mlog.red('DID NOT COMPILE') + elif result.returncode == 0: + h = mlog.green('YES') + else: + h = mlog.red('NO (%d)' % result.returncode) + mlog.log('Checking if "', mlog.bold(testname), '" runs : ', h, sep='') return TryRunResultHolder(result) def get_id_method(self, args, kwargs): diff --git a/test cases/common/39 tryrun/meson.build b/test cases/common/39 tryrun/meson.build index 212f9fa1c..a45d3e23f 100644 --- a/test cases/common/39 tryrun/meson.build +++ b/test cases/common/39 tryrun/meson.build @@ -18,9 +18,9 @@ error_code = '''int main(int argc, char **argv) { no_compile_code = '''int main(int argc, char **argv) { ''' -ok = cc.run(ok_code) -err = cc.run(error_code) -noc = cc.run(no_compile_code) +ok = cc.run(ok_code, name : 'should succeed') +err = cc.run(error_code, name : 'should fail') +noc = cc.run(no_compile_code, name : 'does not compile') if noc.compiled() error('Compilation fail test failed.')