def test_rule(self):
    out = StringIO()
    rule = Rule()
    rule.dump(out)
    self.assertEqual(out.getvalue(), '')
    out.truncate(0)
    rule.add_targets(['foo', 'bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar:\n')
    out.truncate(0)
    rule.add_targets(['baz'])
    rule.add_dependencies(['qux', 'hoge', 'piyo'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar baz: qux hoge piyo\n')
    out.truncate(0)
    rule = Rule(['foo', 'bar'])
    rule.add_dependencies(['baz'])
    rule.add_commands(['echo $@'])
    rule.add_commands(['$(BAZ) -o $@ $<', '$(TOUCH) $@'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), ((('foo bar: baz\n' + '\techo $@\n') + '\t$(BAZ) -o $@ $<\n') + '\t$(TOUCH) $@\n'))
    out.truncate(0)
    rule = Rule(['foo'])
    rule.add_dependencies(['bar', 'foo', 'baz'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo: bar baz\n')
    out.truncate(0)
    rule.add_targets(['bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz\n')
    out.truncate(0)
    rule.add_targets(['bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz\n')
    out.truncate(0)
    rule.add_dependencies(['bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz\n')
    out.truncate(0)
    rule.add_dependencies(['qux'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz qux\n')
    out.truncate(0)
    rule.add_dependencies(['qux'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz qux\n')
    out.truncate(0)
    rule.add_dependencies(['hoge', 'hoge'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz qux hoge\n')
    out.truncate(0)
    rule.add_targets(['fuga', 'fuga'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar fuga: baz qux hoge\n')
def test_rule(self):
    out = StringIO()
    rule = Rule()
    rule.dump(out)
    self.assertEqual(out.getvalue(), )
    out.truncate(0)
    rule.add_targets(['foo', 'bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar:\n')
    out.truncate(0)
    rule.add_targets(['baz'])
    rule.add_dependencies(['qux', 'hoge', 'piyo'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar baz: qux hoge piyo\n')
    out.truncate(0)
    rule = Rule(['foo', 'bar'])
    rule.add_dependencies(['baz'])
    rule.add_commands(['echo $@'])
    rule.add_commands(['$(BAZ) -o $@ $<', '$(TOUCH) $@'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), ((('foo bar: baz\n' + '\techo $@\n') + '\t$(BAZ) -o $@ $<\n') + '\t$(TOUCH) $@\n'))
    out.truncate(0)
    rule = Rule(['foo'])
    rule.add_dependencies(['bar', 'foo', 'baz'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo: bar baz\n')
    out.truncate(0)
    rule.add_targets(['bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz\n')
    out.truncate(0)
    rule.add_targets(['bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz\n')
    out.truncate(0)
    rule.add_dependencies(['bar'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz\n')
    out.truncate(0)
    rule.add_dependencies(['qux'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz qux\n')
    out.truncate(0)
    rule.add_dependencies(['qux'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz qux\n')
    out.truncate(0)
    rule.add_dependencies(['hoge', 'hoge'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar: baz qux hoge\n')
    out.truncate(0)
    rule.add_targets(['fuga', 'fuga'])
    rule.dump(out)
    self.assertEqual(out.getvalue(), 'foo bar fuga: baz qux hoge\n')