From 22652da198ed7de4aa1a66746d59a704c56f1e7c Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Mon, 15 Jun 2020 09:30:47 +0200 Subject: [PATCH] cue: support setting TEST=NO to skip tests --- cue-test.py | 16 ++++++++++++++++ cue.py | 42 +++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/cue-test.py b/cue-test.py index 4286a7d..18947b5 100644 --- a/cue-test.py +++ b/cue-test.py @@ -422,6 +422,14 @@ class TestTravisDetectContext(unittest.TestCase): "ci['configuration'] is {0} (expected: static-debug)" .format(cue.ci['configuration'])) + def test_TestNo(self): + os.environ['TRAVIS'] = 'true' + os.environ['TRAVIS_OS_NAME'] = 'linux' + os.environ['TRAVIS_COMPILER'] = 'gcc' + os.environ['TEST'] = 'NO' + cue.detect_context() + self.assertFalse(cue.ci['test'], "ci['test'] is True (expected: False)") + def test_WindowsGccNone(self): os.environ['TRAVIS'] = 'true' os.environ['TRAVIS_OS_NAME'] = 'windows' @@ -607,6 +615,14 @@ class TestAppveyorDetectContext(unittest.TestCase): "ci['configuration'] is {0} (expected: static-debug)" .format(cue.ci['configuration'])) + def test_TestNo(self): + os.environ['APPVEYOR'] = 'True' + os.environ['APPVEYOR_BUILD_WORKER_IMAGE'] = 'Visual Studio 2019' + os.environ['CMP'] = 'gcc' + os.environ['TEST'] = 'NO' + cue.detect_context() + self.assertFalse(cue.ci['test'], "ci['test'] is True (expected: False)") + def test_WindowsGccNone(self): os.environ['APPVEYOR'] = 'True' os.environ['APPVEYOR_BUILD_WORKER_IMAGE'] = 'Visual Studio 2019' diff --git a/cue.py b/cue.py index d642754..98d28a0 100644 --- a/cue.py +++ b/cue.py @@ -62,8 +62,12 @@ def detect_context(): if 'CHOCO' in os.environ: ci['choco'].extend(os.environ['CHOCO'].split()) - logger.debug('Detected a build hosted on %s, using %s on %s (%s) configured as %s', - ci['service'], ci['compiler'], ci['os'], ci['platform'], ci['configuration']) + ci['test'] = True + if 'TEST' in os.environ and os.environ['TEST'].lower() == 'no': + ci['test'] = False + + logger.debug('Detected a build hosted on %s, using %s on %s (%s) configured as %s (test: %s)', + ci['service'], ci['compiler'], ci['os'], ci['platform'], ci['configuration'], ci['test']) curdir = os.getcwd() @@ -864,24 +868,32 @@ def build(args): def test(args): - setup_for_build(args) - fold_start('test.module', 'Run the main module tests') - if has_test_results: - call_make(['tapfiles']) + if ci['test']: + setup_for_build(args) + fold_start('test.module', 'Run the main module tests') + if has_test_results: + call_make(['tapfiles']) + else: + call_make(['runtests']) + fold_end('test.module', 'Run the main module tests') else: - call_make(['runtests']) - fold_end('test.module', 'Run the main module tests') + print("{0}Action 'test' skipped as per configuration{1}" + .format(ANSI_YELLOW, ANSI_RESET)) def test_results(args): - setup_for_build(args) - fold_start('test.results', 'Sum up main module test results') - if has_test_results: - call_make(['test-results'], parallel=0, silent=True) + if ci['test']: + setup_for_build(args) + fold_start('test.results', 'Sum up main module test results') + if has_test_results: + call_make(['test-results'], parallel=0, silent=True) + else: + print("{0}Base in {1} does not implement 'test-results' target{2}" + .format(ANSI_YELLOW, places['EPICS_BASE'], ANSI_RESET)) + fold_end('test.results', 'Sum up main module test results') else: - print("{0}Base in {1} does not implement 'test-results' target{2}" - .format(ANSI_YELLOW, places['EPICS_BASE'], ANSI_RESET)) - fold_end('test.results', 'Sum up main module test results') + print("{0}Action 'test-results' skipped as per configuration{1}" + .format(ANSI_YELLOW, ANSI_RESET)) def doExec(args):