From 2cac709a9325da0c31b8cae3374cc087cef9f398 Mon Sep 17 00:00:00 2001 From: codewithfourtix Date: Sun, 1 Mar 2026 19:43:09 +0500 Subject: [PATCH 1/3] Fix incorrect timing parameter passed to run_scanners The run_scanners call was passing 'timeout' (a float, default 120.0) as the 'timing' argument instead of the 'timing' boolean flag. This caused per-file scan timings to always be collected regardless of the --timing CLI option. Signed-off-by: codewithfourtix --- src/scancode/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scancode/cli.py b/src/scancode/cli.py index 1376c6cfee9..4705ec53c43 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -966,7 +966,7 @@ def echo_func(*_args, **_kwargs): codebase=codebase, processes=processes, timeout=timeout, - timing=timeout, + timing=timing, quiet=quiet, verbose=verbose, kwargs=requested_options, From 88c3ef78026f87b9d8ded0108dfad8dcd2c4285a Mon Sep 17 00:00:00 2001 From: codewithfourtix Date: Mon, 2 Mar 2026 21:41:04 +0500 Subject: [PATCH 2/3] Add regression test for timing flag not collecting timings Signed-off-by: codewithfourtix --- tests/scancode/test_cli.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/scancode/test_cli.py b/tests/scancode/test_cli.py index 858baf68ca7..33cc8324d3b 100644 --- a/tests/scancode/test_cli.py +++ b/tests/scancode/test_cli.py @@ -788,6 +788,19 @@ def test_scan_with_timing_json_return_timings_for_each_scanner(): @pytest.mark.scanslow @pytest.mark.skipif(on_windows, reason='Somehow this test fails for now on Python 3') +def test_scan_without_timing_flag_does_not_collect_scan_timings(): + test_dir = test_env.extract_test_tar('timing/basic.tgz') + result_file = test_env.get_temp_file('json') + args = ['--email', '--url', '--license', '--copyright', '--info', + '--package', '--json', result_file, test_dir] + run_scan_click(args) + file_results = load_json_result(result_file)['files'] + for res in file_results: + if res['type'] == 'file': + assert not res.get('scan_timings'), ( + 'scan_timings should be empty when --timing is not passed' + ) + def test_scan_with_timing_jsonpp_return_timings_for_each_scanner(): test_dir = test_env.extract_test_tar('timing/basic.tgz') result_file = test_env.get_temp_file('json') From 11c423781d05077a0b3c2fa4ea52815a55299617 Mon Sep 17 00:00:00 2001 From: codewithfourtix Date: Tue, 3 Mar 2026 23:19:41 +0500 Subject: [PATCH 3/3] Fix test decorators on test_scan_without_timing_flag Remove incorrect @pytest.mark.scanslow and @pytest.mark.skipif decorators that were accidentally copied from the test above. This test should run on all platforms including Windows. Signed-off-by: codewithfourtix --- tests/scancode/test_cli.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/scancode/test_cli.py b/tests/scancode/test_cli.py index 33cc8324d3b..000d1db3196 100644 --- a/tests/scancode/test_cli.py +++ b/tests/scancode/test_cli.py @@ -786,8 +786,6 @@ def test_scan_with_timing_json_return_timings_for_each_scanner(): check_timings(expected, file_results) -@pytest.mark.scanslow -@pytest.mark.skipif(on_windows, reason='Somehow this test fails for now on Python 3') def test_scan_without_timing_flag_does_not_collect_scan_timings(): test_dir = test_env.extract_test_tar('timing/basic.tgz') result_file = test_env.get_temp_file('json') @@ -800,6 +798,7 @@ def test_scan_without_timing_flag_does_not_collect_scan_timings(): assert not res.get('scan_timings'), ( 'scan_timings should be empty when --timing is not passed' ) + def test_scan_with_timing_jsonpp_return_timings_for_each_scanner(): test_dir = test_env.extract_test_tar('timing/basic.tgz')