From 2d68e3ea1178d47018140aecff60980fee1f9a49 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Wed, 21 Oct 2026 10:54:02 -0400 Subject: [PATCH] Apply EXTRA make arguments to the test stage Also add a test to the unit tests. (closes #118) --- README.md | 3 ++- cue-test.py | 25 +++++++++++++++++++++++++ cue.py | 4 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c60d0c..3a3edaa 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,8 @@ Execute the remainder of the line using the default command shell. ## Extra arguments to `make` You can add additional arguments to the make runs that the `cue.py` script -starts. Put your additional arguments into environment variables named +starts for building and testing your main module (`build` and `test` +actions). Put your additional arguments into environment variables named `EXTRA`, `EXTRA1`, ... `EXTRA5`. The variables may contain multiple arguments, separated by whitespace. diff --git a/cue-test.py b/cue-test.py index 6d253c1..60a09f6 100644 --- a/cue-test.py +++ b/cue-test.py @@ -977,6 +977,31 @@ def test_ExtraMakeArgs(self): 'Extra make arg [{0}] not set (expected "bla {0}", found "{1}")' .format(ind, cue.extra_makeargs[ind])) + def test_ExtraMakeArgsUsedForTest(self): + for tag in ['EXTRA', 'EXTRA1', 'EXTRA2', 'EXTRA3', 'EXTRA4', 'EXTRA5']: + os.environ.pop(tag, None) + os.environ['EXTRA'] = 'bla' + os.environ['EXTRA1'] = '"bla 1"' + make_calls = [] + orig_call_make = cue.call_make + cue.call_make = lambda args=None, **kws: make_calls.append((args, kws)) + try: + for has_test_results in [False, True]: + self.setTestResultsTarget('test-results' if has_test_results else 'not-test-results') + del make_calls[:] + del cue.extra_makeargs[:] + cue.test(self.args) + self.assertEqual(len(make_calls), 1, 'Expected one make call, found {0}'.format(len(make_calls))) + args, kws = make_calls[0] + self.assertTrue(kws.get('use_extra', False), + 'Extra make args not used for make {0}'.format(args)) + self.assertEqual(cue.extra_makeargs, ['bla', 'bla 1'], + 'Extra make args not set (found {0})'.format(cue.extra_makeargs)) + finally: + cue.call_make = orig_call_make + os.environ.pop('EXTRA', None) + os.environ.pop('EXTRA1', None) + class TestHooks(unittest.TestCase): location = os.path.join(cue.ci['cachedir'], 'hook_test') diff --git a/cue.py b/cue.py index cc0fbd0..bfac20d 100644 --- a/cue.py +++ b/cue.py @@ -1515,9 +1515,9 @@ def test(args): setup_for_build(args) fold_start('test.module', 'Run the main module tests') if has_test_results: - call_make(['tapfiles']) + call_make(['tapfiles'], use_extra=True) else: - call_make(['runtests']) + call_make(['runtests'], use_extra=True) fold_end('test.module', 'Run the main module tests') else: print("{0}Action 'test' skipped as per configuration{1}"