Exemplo n.º 1
0
    def test_isStaleUponUserConfigurationChange(self):
        autoGeneratedFile = TEST_CONTENTS.format(attributes.VERSION,
                                                 CONFIG_FILE_TIME - 0.1,
                                                 VALID_PRODUCT)
        self.readTextFileAtOnce.return_value = autoGeneratedFile

        config = StatConfiguration()
        self.assertTrue(config.isStale())
Exemplo n.º 2
0
    def test_defaultProductInvalidSpecified(self):
        autoGeneratedFile = TEST_CONTENTS.format(attributes.VERSION,
                                                 CONFIG_FILE_TIME,
                                                 'some_invalid_product')
        self.readTextFileAtOnce.return_value = autoGeneratedFile

        config = StatConfiguration()
        self.assertIsNone(config.defaultProduct)
        self.assertTrue(config.isStale())
Exemplo n.º 3
0
 def test___init__basics(self):
     config = StatConfiguration()
     self.assertEqual(attributes.VERSION, config['TOOL_VERSION'])
     self.assertEqual(toPosixPath(attributes.OUTPUT_DIRECTORY),
                      toPosixPath(config['OUTPUT_DIR']))
     self.assertEqual(toPosixPath(os.path.relpath(attributes.TOOL_PATH)),
                      toPosixPath(config['STAT_ROOT']))
     self.assertEqual(toPosixPath(attributes.DUMMIES_DIRECTORY),
                      toPosixPath(config['DUMMIES_DIR']))
Exemplo n.º 4
0
    def test_isStaleUponAutoWithoutConfigVersion(self):
        newContents = (TEST_CONTENTS[:]).replace('CONFIG_VERSION',
                                                 'SOME_OTHER_FIELD')
        autoGeneratedFile = newContents.format(attributes.VERSION,
                                               CONFIG_FILE_TIME, VALID_PRODUCT)
        self.readTextFileAtOnce.return_value = autoGeneratedFile

        config = StatConfiguration()
        self.assertTrue(config.isStale())
Exemplo n.º 5
0
 def test___init__basics(self):
     config = StatConfiguration()
     self.assertEqual(attributes.VERSION, config['TOOL_VERSION'])
     self.assertCalls(self.statMakefile, [call(attributes.CONFIG_FILENAME)])
     self.assertEqual("Hello universe!", config['TEST_VARIABLE'])
     self.assertEqual(2008, config.getInt('MSVS_VERSION', 0))
     self.assertCalls(self.isFile, [
         call(
             os.path.join(attributes.PRODUCT_DIRECTORY,
                          attributes.IGNORE_FILENAME)),
         call(attributes.CONFIG_FILENAME),
         call(attributes.AUTO_GENERATED_MAKEFILE)
     ])
     self.assertCalls(self.statMakefile, [call(attributes.CONFIG_FILENAME)])
     self.assertCalls(self.readTextFileAtOnce,
                      [call(attributes.AUTO_GENERATED_MAKEFILE)])
    def test_generate(self):
        config = StatConfiguration()
        makFile = attributes.AUTO_GENERATED_MAKEFILE
        generator = StatMakefileGenerator(productMakefile=TEST_PRODUCT_FILE)
        generator.generate()
        self.assertTrue(os.path.isfile(makFile))

        self.parser = StatMakefile(makFile)

        for parameter in iter(config):
            self.assertEqual(config[parameter], self.parser[parameter])
        self.assertEqual(TEST_PRODUCT_NAME, self.parser[StatMakefile.NAME])
        self.assertEqual(TEST_PRODUCT_EXEC, self.parser[StatMakefile.EXEC])
        self.assertEqual(platform.system(), self.parser[StatMakefile.OS])

        self.__verifyProductMakefileIsIncluded()
        self.__verifyToolsMakefileIsIncluded()
        os.remove(makFile)
    def __constructVariablesInitialization(self):
        def _formatAssignment(_variable, _value):
            return '{0} = {1}'.format(_variable, _value)

        def _getValues(*_valueSets):
            return [
                _formatAssignment(_key, _values[_key])
                for _values in _valueSets for _key in iter(_values)
            ]

        values = [
            _formatAssignment(StatMakefile.OS, platform.system()),
            _formatAssignment(StatMakefile.NAME, self.__targetName),
            _formatAssignment(StatMakefile.EXEC,
                              nameExecutable(self.__targetName))
        ]
        values += _getValues(StatConfiguration(),
                             BuildToolsCrawler().getBuildAttributes())
        return '\n'.join(values)
Exemplo n.º 8
0
 def __init__(self):
     self.__config = StatConfiguration()
     self.__parser = StatArgumentParser(self.__config.products,
                                        self.__config.defaultProduct)
     self.__makeArguments = ['COPY_HEADERS="TRUE"']
     self.__report = StatReport()
Exemplo n.º 9
0
 def test_defaultProductExplicitlySpecified(self):
     config = StatConfiguration()
     self.assertEqual(VALID_PRODUCT, config.defaultProduct)
     self.assertFalse(config.isStale())
Exemplo n.º 10
0
 def test_defaultProduct(self):
     config = StatConfiguration()
     self.assertEqual(None, config.defaultProduct)
     self.assertTrue(config.isStale())
Exemplo n.º 11
0
 def test_products(self):
     config = StatConfiguration()
     expected = ['product', 'product_derived']
     self.assertSameItems(expected, config.products)
Exemplo n.º 12
0
 def test__new__isSingleton(self):
     self.assertEqual(self.config, StatConfiguration())
Exemplo n.º 13
0
 def setUp(self):
     self.setupCommon()
     self.config = StatConfiguration()
 def __init__(self):
     self.__msvsTools = MsvsTools(StatConfiguration()) if platform.system() == "Windows" else None
     self.__tools = [tools for tools in (self.__msvsTools,) if tools]