def test_readGroups01(self): fileContents = textwrap.dedent(""" gcc, *, * { ccompiler = gcc cflags = -O0 testVariable = baseVar } gcc, release, * { cflags = -O2 testVariable = releaseVar } """) try: tempDir = mdTestUtilities.makeTempDir() filePath = mdTestUtilities.makeTempFile(tempDir, fileContents) groups = overrides.readGroups(filePath) self.assertNotEquals(groups, None, "readGroups() failed to read groups") self.assertEquals(len(groups), 2, "Wrong number of groups returned") self.assertEquals(groups[0].compiler, "gcc", "readGroups() has wrong information") self.assertEquals(groups[0].optimization, "*", "readGroups() has wrong information") self.assertEquals(groups[0].parallel, "*", "readGroups() has wrong information") self.assertEquals(fullCount(groups[0]), 3, "readGroups() has wrong information") self.assertEquals(groups[0]["ccompiler"], "gcc", "readGroups() has wrong information") self.assertEquals(groups[0]["cflags"], "-O0", "readGroups() has wrong information") self.assertEquals(groups[0].defines["testvariable"], "baseVar", "readGroups() has wrong information") self.assertEquals(groups[1].compiler, "gcc", "readGroups() has wrong information") self.assertEquals(groups[1].optimization, "release", "readGroups() has wrong information") self.assertEquals(groups[1].parallel, "*", "readGroups() has wrong information") self.assertEquals(fullCount(groups[1]), 2, "readGroups() has wrong information") self.assertEquals(groups[1]["cflags"], "-O2", "readGroups() has wrong information") self.assertEquals(groups[1].defines["testvariable"], "releaseVar", "readGroups() has wrong information") finally: utilityFunctions.removeDir(tempDir)
def test_readGroups12(self): fileContents = textwrap.dedent(""" foo,*,* { ccompiler = gcc cflags = -O0 testVariable = foo } """) try: tempDir = mdTestUtilities.makeTempDir() filePath = mdTestUtilities.makeTempFile(tempDir, fileContents) groups = overrides.readGroups(filePath) self.assertNotEquals(groups, None, "readGroups() failed to read groups") self.assertEquals(len(groups), 1, "Wrong number of groups returned") self.assertEquals(groups[0].compiler, "foo", "readGroups() has wrong information") self.assertEquals(groups[0].optimization, "*", "readGroups() has wrong information") self.assertEquals(groups[0].parallel, "*", "readGroups() has wrong information") self.assertEquals(fullCount(groups[0]), 3, "readGroups() has wrong information") self.assertEquals(groups[0]["ccompiler"], "gcc", "readGroups() has wrong information") self.assertEquals(groups[0]["cflags"], "-O0", "readGroups() has wrong information") self.assertEquals(groups[0].defines["testvariable"], "foo", "readGroups() has wrong information") finally: utilityFunctions.removeDir(tempDir)
def test_pathExists2(self): try: tempDir = mdTestUtilities.makeTempDir() tempFile = mdTestUtilities.makeTempFile(tempDir) self.assertEquals(utilityFunctions.pathExists(tempFile, True), True, "pathExists should have returned True") finally: utilityFunctions.removeDir(tempDir)
def test_readGroups13(self): fileContents = textwrap.dedent(""" wrongParens, *, * ( ccompiler = gcc cflags = -O0 testVariable = foo ) """) try: tempDir = mdTestUtilities.makeTempDir() filePath = mdTestUtilities.makeTempFile(tempDir, fileContents) groups = overrides.readGroups(filePath) self.assertEquals(groups, None, "readGroups() should have failed to read groups") finally: utilityFunctions.removeDir(tempDir)
def test_readGroups13(self): fileContents = textwrap.dedent(""" wrongParens, *, * ( ccompiler = gcc cflags = -O0 testVariable = foo ) """) try: tempDir = mdTestUtilities.makeTempDir() filePath = mdTestUtilities.makeTempFile(tempDir, fileContents) groups = overrides.readGroups(filePath) self.assertEquals( groups, None, "readGroups() should have failed to read groups") finally: utilityFunctions.removeDir(tempDir)
def test_readGroups05(self): fileContents = textwrap.dedent(""" empty, *, * { } """) try: tempDir = mdTestUtilities.makeTempDir() filePath = mdTestUtilities.makeTempFile(tempDir, fileContents) groups = overrides.readGroups(filePath) self.assertNotEquals(groups, None, "readGroups() failed to read groups") self.assertEquals(len(groups), 1, "Wrong number of groups returned") self.assertEquals(groups[0].compiler, "empty", "readGroups() has wrong information") self.assertEquals(groups[0].optimization, "*", "readGroups() has wrong information") self.assertEquals(groups[0].parallel, "*", "readGroups() has wrong information") self.assertEquals(fullCount(groups[0]), 0, "readGroups() has wrong information") finally: utilityFunctions.removeDir(tempDir)