mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
* Common code extracted to Python directories. * Read ~/.scons file for scons environment defaults. * Override scons settings with shell environment variables. * New "tags" for debug, nodebug, optimize, nooptimize builds. * Universal platform detection. * Default value of environment variables set through prefix dictionaries. * Check for correct Boost value and fail otherwise. * Extract git describe --tags into a preprocesor variable, -DTIP_BRANCH * More colors - blue for unchanged defaults, green for changed defaults, red for error. * Contain unit tests for non-obvious stuff. * Check to see that boost libraries have been built. * Right now, we accept both .dylib and .a versions but it'd be easy to enforce .a only.
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
from unittest import TestCase
|
|
from beast.env.ReadEnvFile import read_env_file
|
|
|
|
from beast.util import Terminal
|
|
Terminal.CAN_CHANGE_COLOR = False
|
|
|
|
JSON = """
|
|
{
|
|
"FOO": "foo",
|
|
"BAR": "bar bar bar",
|
|
"CPPFLAGS": "-std=c++11 -frtti -fno-strict-aliasing -DWOMBAT"
|
|
}"""
|
|
|
|
ENV = """
|
|
# An env file.
|
|
|
|
FOO=foo
|
|
export BAR="bar bar bar"
|
|
CPPFLAGS=-std=c++11 -frtti -fno-strict-aliasing -DWOMBAT
|
|
|
|
# export BAZ=baz should be ignored.
|
|
|
|
"""
|
|
|
|
RESULT = {
|
|
'FOO': 'foo',
|
|
'BAR': 'bar bar bar',
|
|
'CPPFLAGS': '-std=c++11 -frtti -fno-strict-aliasing -DWOMBAT',
|
|
}
|
|
|
|
BAD_ENV = ENV + """
|
|
This line isn't right.
|
|
NO SPACES IN NAMES="valid value"
|
|
"""
|
|
|
|
class test_ReadEnvFile(TestCase):
|
|
def test_read_json(self):
|
|
self.assertEqual(read_env_file(JSON), RESULT)
|
|
|
|
def test_read_env(self):
|
|
self.assertEqual(read_env_file(ENV), RESULT)
|
|
|
|
def test_read_env_error(self):
|
|
errors = []
|
|
self.assertEqual(read_env_file(BAD_ENV, errors.append), RESULT)
|
|
self.assertEqual(errors, [
|
|
"WARNING: Didn't understand the following environment file lines:",
|
|
"11. >>> This line isn't right.",
|
|
'12. >>> NO SPACES IN NAMES="valid value"'])
|