From 6236fe2b1eae72629ede617118568af644c37d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosmin=20=C8=98tefan=20Ciocan?= <57830279+cosminc98@users.noreply.github.com> Date: Tue, 23 Jan 2024 23:44:36 +0000 Subject: [PATCH] Improve tests coverage by testing for bad arguments and the error output during a failed compilation --- tests/test_plugin.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 2d6dbcb..674392d 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -103,6 +103,17 @@ def test_compile_args( with pytest.raises(subprocess.CalledProcessError): exec_fpath = plugin._compile(gname, compiler_args="--std c++14") + output = plugin._compile_and_run( + group_name=gname, + args=argparse.Namespace( + timeit=False, + profile=True, + profiler_args="", + compiler_args="--std c++14", + ), + ) + assert "errors detected in the compilation of" in output + def test_run( plugin: NVCCPlugin, @@ -213,6 +224,16 @@ def test_magic_cuda( check_profiler_output(capsys.readouterr().out) +def test_magic_cuda_bad_args( + capsys, + plugin: NVCCPlugin, + sample_cuda_code: str, +): + plugin.cuda("--this-is-an-unrecognized-argument", sample_cuda_code) + output = capsys.readouterr().out + assert output.startswith("usage: ") + + def test_magic_cuda_group_save(plugin: NVCCPlugin, sample_cuda_code: str): gname = "test_save_source" sname = "sample.cu"