Esempio n. 1
0
    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])
Esempio n. 2
0
    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])
Esempio n. 3
0
 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'})
Esempio n. 4
0
    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])
Esempio n. 5
0
    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)
Esempio n. 6
0
    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])
Esempio n. 7
0
 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'))
Esempio n. 8
0
 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']], [])
Esempio n. 9
0
 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'])
Esempio n. 10
0
 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']])
Esempio n. 11
0
    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)
Esempio n. 12
0
 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)],
                        [])
Esempio n. 13
0
 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']])
Esempio n. 14
0
 def test_alias(self):
     expected = file_types.Phony('foo')
     alias = self.context['alias']('foo')
     self.assertSameFile(alias, expected)
     self.assertEqual(alias.creator.extra_deps, [])
Esempio n. 15
0
 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)
Esempio n. 16
0
 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])