def test_DuplicateRuleError(self): build = Build() build.createRule('a.txt', FileTouchRule) with self.assertRaises(DuplicateRuleError): build.createRule('a.txt', FileTouchRule)
def test_exists(self): touchFile('a.txt') build = Build() build.createRule('a.txt', FileTouchRule) build.build('a.txt') self.assertListEqual(build.trace, [])
def test_DependentTargets_DNE(self): build = Build() a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') build.createRule('b.txt', FileTouchRule) build.build('a.txt') self.assertListEqual(build.trace, [['b.txt'],['a.txt']])
def test_IndependentTargets_DNE(self): build = Build() build.createRule('a.txt', FileTouchRule) build.createRule('b.txt', FileTouchRule) build.build('a.txt') self.assertListEqual(build.trace, [['a.txt']]) build.build('b.txt') self.assertListEqual(build.trace, [['b.txt']])
def test_MultipleTargers(self): build = Build() ab = build.createRule(['a.txt', 'b.txt'], FileTouchRule) ab.addPrerequisite('c.txt') cd = build.createRule(['c.txt', 'd.txt'], FileTouchRule) build.build('a.txt') self.assertListEqual(sortBuildTrace(build.trace), [['c.txt','d.txt'],['a.txt','b.txt']])
def test_Tree_SubTreeDNE(self): touchFile('b.txt') build = Build() a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') a.addPrerequisite('c.txt') build.createRule('b.txt', FileTouchRule) build.createRule('c.txt', FileTouchRule) build.build('a.txt') self.assertListEqual(build.trace, [['c.txt'],['a.txt']])
def test_CyclicGraphError(self): build = Build() a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') b = build.createRule('b.txt', FileTouchRule) b.addPrerequisite('c.txt') c = build.createRule('c.txt', FileTouchRule) c.addPrerequisite('a.txt') with self.assertRaises(CyclicGraphError): build.build('a.txt')
def test_DependentTargets_BottomForceRebuild(self): touchFile('b.txt') touchFile('a.txt') build = Build() a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') b = build.createRule('b.txt', FileTouchRule) b.setForceRebuild(True) build.build('a.txt') self.assertListEqual(build.trace, [['b.txt'], ['a.txt']])
def test_Tree_TopNewer(self): touchFile('c.txt') touchFile('b.txt') touchFile('a.txt') build = Build() a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') a.addPrerequisite('c.txt') build.createRule('b.txt', FileTouchRule) build.createRule('c.txt', FileTouchRule) build.build('a.txt') self.assertListEqual(build.trace, [])
def test_NoSettingDefined(self): build = Build() setSetting(build,'b', 'b') touchFile('b.txt') touchFile('a.txt') a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') a.addSetting('a') b = build.createRule('b.txt', FileTouchRule) b.addSetting('b') with self.assertRaises(NoSettingError): build.build('a.txt')
def test_Line_BottomNewer(self): touchFile('b.txt') touchFile('a.txt') touchFile('c.txt') build = Build() a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') b = build.createRule('b.txt', FileTouchRule) b.addPrerequisite('c.txt') build.createRule('c.txt', FileTouchRule) build.build('a.txt') self.assertListEqual(build.trace, [['b.txt'], ['a.txt']])
def test_MissingPrerequisite(self): build = Build() a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') with self.assertRaises(NoRuleError): build.build('a.txt')
def test_TopSettingNewer(self): build = Build() setSetting(build,'b', 'b') touchFile('b.txt') touchFile('a.txt') setSetting(build,'a', 'a') a = build.createRule('a.txt', FileTouchRule) a.addPrerequisite('b.txt') a.addSetting('a') b = build.createRule('b.txt', FileTouchRule) b.addSetting('b') build.build('a.txt') self.assertListEqual(build.trace, [['a.txt']])
def test_DNE(self): build = Build() build.createRule('a.txt', FileTouchRule) build.build('a.txt') self.assertListEqual(build.trace, [['a.txt']])