def test_extra_deps(self): dep = self.context['generic_file']('dep.txt') result = self.context['command']('foo', cmd=['echo', 'foo'], extra_deps=dep) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [['echo', 'foo']], extra_deps=[dep]) script = self.context['source_file']('script.py') script.creator = 'foo' result = self.context['command']('foo', cmd=script, extra_deps=dep) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], extra_deps=[script, dep])
def test_file_cmd_deps(self): script = self.context['source_file']('script.py') script.creator = 'foo' result = self.context['command']('foo', cmd=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], extra_deps=[script])
def test_env(self): result = self.context['command']('foo', cmd=['echo', 'foo'], environment={ 'NAME': 'value' }) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [['echo', 'foo']], env={'NAME': 'value'})
def test_input_deps(self): script = self.context['source_file']('script.py') script.creator = 'foo' command = self.context['command'] result = command('foo', cmd=[command.input], files=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [script])
def test_input(self): script = self.context['source_file']('script.py') command = self.context['command'] result = command('foo', cmd=[command.input], files=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [script]) result = command('foo', cmd=[command.input[0]], files=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [script]) result = command('foo', cmd=[command.input[0:]], files=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [script]) with self.assertRaises(IndexError): command('foo', cmd=[command.input[1]], files=script)
def test_input_line(self): script = self.builtin_dict['source_file']('script.py') command = self.builtin_dict['command'] result = command('foo', cmd=command.input, files=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [script]) result = command('foo', cmd=command.input[0], files=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [script]) result = command('foo', cmd=command.input[0:], files=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [script]) with self.assertRaises(IndexError): command('foo', cmd=command.input[1], files=script) with self.assertRaises(ValueError): command('foo', cmd=command.input, files=[script, script])
def test_submodule(self): with self.context.push_path(Path('dir/build.bfg', Root.srcdir)): result = self.context['command']('foo', cmd=['echo', 'foo']) self.assertSameFile(result, file_types.Phony('foo'))
def test_file_cmd_list(self): script = self.context['source_file']('script.py') result = self.context['command']('foo', cmd=[script, '--foo']) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script) + ['--foo']], [])
def test_string_cmd(self): result = self.context['command']('foo', cmd='echo foo') self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, ['echo foo'])
def test_multiple_cmds(self): result = self.context['command']('foo', cmds=[['echo', 'foo'], ['touch', 'bar']]) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [['echo', 'foo'], ['touch', 'bar']])
def test_invalid(self): phony = file_types.Phony('name') self.assertRaises(TypeError, self.builtin_dict['install'], phony) exe = file_types.Executable(Path('/path/to/exe', Root.absolute), None) self.assertRaises(ValueError, self.builtin_dict['install'], exe)
def test_file_cmd(self): script = self.builtin_dict['source_file']('script.py') result = self.builtin_dict['command']('foo', cmd=script) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [self.env.tool('python')(script)], [])
def test_single_cmd(self): result = self.builtin_dict['command']('foo', cmd=['echo', 'foo']) self.assertSameFile(result, file_types.Phony('foo')) self.assertCommand(result.creator, [['echo', 'foo']])
def test_alias(self): expected = file_types.Phony('foo') alias = self.context['alias']('foo') self.assertSameFile(alias, expected) self.assertEqual(alias.creator.extra_deps, [])
def test_submodule(self): with self.context.push_path(Path('dir/build.bfg', Root.srcdir)): expected = file_types.Phony('foo') alias = self.context['alias']('foo') self.assertSameFile(alias, expected)
def test_deps(self): dep = self.context['generic_file']('dep.txt') expected = file_types.Phony('foo') alias = self.context['alias']('foo', dep) self.assertSameFile(alias, expected) self.assertEqual(alias.creator.extra_deps, [dep])