def test_basic_cpp_rule(self): ''' Test that we can correctly handle a basic Makefile rule. ''' filename = self.mkstemp() # Create a basic rule. with open(filename, 'wt') as f: f.write('target: a b\n') # Confirm we get the correct dependencies. with open(filename) as f: deps = set(parse_makefile_rule(f)) self.assertSetEqual(deps, set(['a', 'b']))
def test_no_cpp_rules(self): ''' Test that an empty list of Makefile rules yields no dependencies. ''' filename = self.mkstemp() # Create the file with no content. with open(filename, 'wt') as f: pass # Confirm that we get no dependencies out of it. with open(filename) as f: deps = list(parse_makefile_rule(f)) self.assertLen(deps, 0)
def test_split_cpp_rule2(self): ''' Test a more complicated split rule. ''' filename = self.mkstemp() # Create a complicated split rule. with open(filename, 'wt') as f: f.write('target: \\\n' 'a b \\\n' '\\\n' 'c\n') # Confirm we get the correct dependencies. with open(filename) as f: deps = set(parse_makefile_rule(f)) self.assertSetEqual(deps, set(['a', 'b', 'c']))
def test_split_cpp_rule(self): ''' Test that we can correctly handle rules split over multiple lines. ''' filename = self.mkstemp() # Create a split rule. with open(filename, 'wt') as f: f.write('target: a b \\\n' 'c \\\n' 'd\n') # Confirm we get the correct dependencies. with open(filename) as f: deps = set(parse_makefile_rule(f)) self.assertSetEqual(deps, set(['a', 'b', 'c', 'd']))
def test_multiple_cpp_rules(self): ''' We should ignore everything after the first Makefile dependency rule. Test that this is actually true. ''' filename = self.mkstemp() # Create a file with multiple rules. with open(filename, 'wt') as f: f.write('target: a b c\n' 'target2: d e f\n') # Confirm we only get the dependencies of the first rule. with open(filename) as f: deps = set(parse_makefile_rule(f)) self.assertSetEqual(deps, set(['a', 'b', 'c']))
def test_multiple_cpp_rules(self): ''' We should ignore everything after the first Makefile dependency rule. Test that this is actually true. ''' filename = self.mkstemp() # Create a file with multiple rules. with open(filename, 'wt') as f: f.write('target: a b c\n' 'target2: d e f\n') # Confirm we only get the dependencies of the first rule. with open(filename) as f: deps = set(parse_makefile_rule(f)) self.assertSetEqual(deps, set(['a', 'b', 'c']))
def test_split_cpp_rule(self): ''' Test that we can correctly handle rules split over multiple lines. ''' filename = self.mkstemp() # Create a split rule. with open(filename, 'wt') as f: f.write('target: a b \\\n' 'c \\\n' 'd\n') # Confirm we get the correct dependencies. with open(filename) as f: deps = set(parse_makefile_rule(f)) self.assertSetEqual(deps, set(['a', 'b', 'c', 'd']))
def test_split_cpp_rule2(self): ''' Test a more complicated split rule. ''' filename = self.mkstemp() # Create a complicated split rule. with open(filename, 'wt') as f: f.write('target: \\\n' 'a b \\\n' '\\\n' 'c\n') # Confirm we get the correct dependencies. with open(filename) as f: deps = set(parse_makefile_rule(f)) self.assertSetEqual(deps, set(['a', 'b', 'c']))