cue: warnings for STATIC and misspelled configuration

fixes #47
This commit is contained in:
Ralph Lange
2020-06-15 10:42:37 +02:00
parent 22652da198
commit 7585b573d3
2 changed files with 61 additions and 8 deletions

View File

@@ -512,6 +512,28 @@ class TestTravisDetectContext(unittest.TestCase):
"ci['configuration'] is {0} (expected: shared-optimized)"
.format(cue.ci['configuration']))
def test_StaticGetsWarning(self):
os.environ['TRAVIS'] = 'true'
os.environ['TRAVIS_OS_NAME'] = 'osx'
os.environ['TRAVIS_COMPILER'] = 'clang'
os.environ['STATIC'] = 'YES'
capturedOutput = getStringIO()
sys.stdout = capturedOutput
cue.detect_context()
sys.stdout = sys.__stdout__
self.assertRegexpMatches(capturedOutput.getvalue(), "Variable 'STATIC' not supported anymore")
def test_MisspelledBcfgGetsWarning(self):
os.environ['TRAVIS'] = 'true'
os.environ['TRAVIS_OS_NAME'] = 'osx'
os.environ['TRAVIS_COMPILER'] = 'clang'
os.environ['BCFG'] = 'static-dubug'
capturedOutput = getStringIO()
sys.stdout = capturedOutput
cue.detect_context()
sys.stdout = sys.__stdout__
self.assertRegexpMatches(capturedOutput.getvalue(), "Unrecognized build configuration setting")
@unittest.skipIf(ci_service != 'appveyor', 'Run appveyor tests only on appveyor')
class TestAppveyorDetectContext(unittest.TestCase):
@@ -689,6 +711,28 @@ class TestAppveyorDetectContext(unittest.TestCase):
.format(cue.ci['configuration']))
self.assertIn('make', cue.ci['choco'], "'make' is not in ci['choco']")
def test_StaticGetsWarning(self):
os.environ['APPVEYOR'] = 'True'
os.environ['APPVEYOR_BUILD_WORKER_IMAGE'] = 'Visual Studio 2019'
os.environ['CMP'] = 'vs2019'
os.environ['STATIC'] = 'YES'
capturedOutput = getStringIO()
sys.stdout = capturedOutput
cue.detect_context()
sys.stdout = sys.__stdout__
self.assertRegexpMatches(capturedOutput.getvalue(), "Variable 'STATIC' not supported anymore")
def test_MisspelledConfigurationGetsWarning(self):
os.environ['APPVEYOR'] = 'True'
os.environ['APPVEYOR_BUILD_WORKER_IMAGE'] = 'Visual Studio 2019'
os.environ['CMP'] = 'vs2019'
os.environ['CONFIGURATION'] = 'static-dubug'
capturedOutput = getStringIO()
sys.stdout = capturedOutput
cue.detect_context()
sys.stdout = sys.__stdout__
self.assertRegexpMatches(capturedOutput.getvalue(), "Unrecognized build configuration setting")
class TestSetupForBuild(unittest.TestCase):
args = Namespace(paths=[])

25
cue.py
View File

@@ -16,6 +16,7 @@ logger = logging.getLogger(__name__)
# Detect the service and set up context hash accordingly
def detect_context():
buildconfig = 'default'
if 'TRAVIS' in os.environ:
ci['service'] = 'travis'
ci['os'] = os.environ['TRAVIS_OS_NAME']
@@ -27,10 +28,7 @@ def detect_context():
# Only Visual Studio 2017 available
ci['compiler'] = 'vs2017'
if 'BCFG' in os.environ:
if re.search('static', os.environ['BCFG']):
ci['static'] = True
if re.search('debug', os.environ['BCFG']):
ci['debug'] = True
buildconfig = os.environ['BCFG'].lower()
if 'APPVEYOR' in os.environ:
ci['service'] = 'appveyor'
@@ -43,10 +41,21 @@ def detect_context():
ci['platform'] = os.environ['PLATFORM'].lower()
if 'CMP' in os.environ:
ci['compiler'] = os.environ['CMP']
if re.search('static', os.environ['CONFIGURATION']):
ci['static'] = True
if re.search('debug', os.environ['CONFIGURATION']):
ci['debug'] = True
buildconfig = os.environ['CONFIGURATION'].lower()
if 'STATIC' in os.environ:
print("{0}WARNING: Variable 'STATIC' not supported anymore; use 'BCFG' instead{1}"
.format(ANSI_RED, ANSI_RESET))
sys.stdout.flush()
if not re.match(r'^((default|static|shared|dynamic|optimized|debug)-?)+$', buildconfig):
print("{0}WARNING: Unrecognized build configuration setting '{1}'{2}"
.format(ANSI_RED, buildconfig, ANSI_RESET))
sys.stdout.flush()
if re.search('static', buildconfig):
ci['static'] = True
if re.search('debug', buildconfig):
ci['debug'] = True
if ci['static']:
ci['configuration'] = 'static'