diff --git a/reframe/core/buildsystems.py b/reframe/core/buildsystems.py index ee820c45f7..db16ca3fb5 100644 --- a/reframe/core/buildsystems.py +++ b/reframe/core/buildsystems.py @@ -426,8 +426,9 @@ def emit_build_commands(self, environ): cmd_parts += [nvcc, *cppflags, *cxxflags, self.srcfile, '-o', executable, *ldflags] else: - BuildSystemError('could not guess language of file: %s' % - self.srcfile) + raise BuildSystemError( + f'could not guess language of file: {self.srcfile}' + ) return [' '.join(cmd_parts)] diff --git a/unittests/test_buildsystems.py b/unittests/test_buildsystems.py index 3cf698aaff..fdd2017715 100644 --- a/unittests/test_buildsystems.py +++ b/unittests/test_buildsystems.py @@ -235,3 +235,10 @@ def test_compiler_pick(lang): } assert ([f'{compilers[lang]} {build_system.srcfile} -o foo.x'] == build_system.emit_build_commands(ProgEnvironment('testenv'))) + + +def test_singlesource_unknown_language(): + build_system = bs.SingleSource() + build_system.srcfile = 'foo.bar' + with pytest.raises(BuildSystemError, match='could not guess language'): + build_system.emit_build_commands(ProgEnvironment('testenv')) diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index 1e330a072f..b4187fdf35 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -457,6 +457,21 @@ def __init__(self): test.compile() +def test_sourcepath_non_existent(local_exec_ctx): + @fixtures.custom_prefix('unittests/resources/checks') + class MyTest(rfm.CompileOnlyRegressionTest): + def __init__(self): + self.valid_prog_environs = ['*'] + self.valid_systems = ['*'] + + test = MyTest() + test.setup(*local_exec_ctx) + test.sourcepath = 'non_existent.c' + test.compile() + with pytest.raises(BuildError): + test.compile_wait() + + def test_extra_resources(testsys_system): @fixtures.custom_prefix('unittests/resources/checks') class MyTest(HelloTest):