def test_auto_generate_source(self): result = self.context['object_file'](file='main.qrc') intermediate = result.creator.file self.assertSameFile(result, self.output_file('main')) self.assertSameFile(intermediate, file_types.SourceFile( Path('main.cpp'), lang='c++' )) self.assertSameFile(intermediate.creator.file, file_types.SourceFile( Path('main.qrc', Root.srcdir), lang='qrc' )) src = self.context['auto_file']('main.hpp', lang='qtmoc') result = self.context['object_file'](file=src) intermediate = result.creator.file self.assertSameFile(result, self.output_file('moc_main')) self.assertSameFile(intermediate, file_types.SourceFile( Path('moc_main.cpp', Root.builddir), lang='c++' )) self.assertSameFile(intermediate.creator.file, file_types.HeaderFile( Path('main.hpp', Root.srcdir), lang='qtmoc' )) result = self.context['object_file'](file='main.qrc', directory='dir') intermediate = result.creator.file self.assertSameFile(result, self.output_file('dir/main')) self.assertSameFile(intermediate, file_types.SourceFile( Path('dir/main.cpp'), lang='c++' )) self.assertSameFile(intermediate.creator.file, file_types.SourceFile( Path('main.qrc', Root.srcdir), lang='qrc' ))
def test_multiple_outputs(self): result = self.context['build_step'](['hello.tab.h', 'hello.tab.c'], cmd=['bison', 'hello.y']) expected = [ file_types.HeaderFile(Path('hello.tab.h', Root.builddir), 'c'), file_types.SourceFile(Path('hello.tab.c', Root.builddir), 'c') ] for i, j in zip(result, expected): self.assertSameFile(i, j) self.assertCommand(i.creator, [['bison', 'hello.y']], phony=False)
def test_multiple_types(self): result = self.context['build_step']( ['hello.tab.h', 'hello.tab.c'], cmd=['bison', 'hello.y'], type=[self.context['generic_file'], self.context['header_file']]) expected = [ file_types.File(Path('hello.tab.h', Root.builddir)), file_types.HeaderFile(Path('hello.tab.c', Root.builddir), None) ] for i, j in zip(result, expected): self.assertSameFile(i, j) self.assertCommand(i.creator, [['bison', 'hello.y']], phony=False)
def test_make_no_lang(self): with mock.patch('bfg9000.builtins.file_types.generated_file', return_value=self.MockFile()): compiler = self.env.builder('c++').pch_compiler pch = self.builtin_dict['precompiled_header'] result = pch('object', 'main.goofy', lang='c++') self.assertEqual(result, self.output_file(compiler, 'object', self.Context())) self.assertRaises(ValueError, pch, 'object', 'main.goofy') src = file_types.HeaderFile(Path('main.goofy', Root.srcdir)) self.assertRaises(ValueError, pch, 'object', src)
def test_default_name(self): hdr = file_types.HeaderFile(Path('file.hpp', Root.srcdir), 'c++') self.assertEqual(self.compiler.default_name(hdr, None), 'file.hpp')