コード例 #1
0
ファイル: test_gnu_make.py プロジェクト: isciences/wsim
    def test_step_comments(self):
        s = Step(targets='a',
                 dependencies=[],
                 commands=[['touch', 'a']],
                 comment='Step to build a')

        self.assertEqual(write_step(s).split('\n')[0], '# Step to build a')
コード例 #2
0
ファイル: test_gnu_make.py プロジェクト: isciences/wsim
    def test_tab_indentation(self):
        # Make requires that all command lines be tab-indented
        s = Step(targets=['a', 'b'],
                 dependencies=['c', 'd'],
                 commands=[['echo', 'c', '>', 'a'], ['echo', 'd', '>', 'b']])

        lines = write_step(s).strip().split('\n')
        for line in lines[1:]:
            self.assertEqual(line[0], '\t')
コード例 #3
0
ファイル: test_gnu_make.py プロジェクト: isciences/wsim
    def test_target_directories_created_but_only_once(self):
        s = Step(
            targets=['/tmp/fizz/fuzz/ok.txt', '/src/junk.h', '/src/junk.c'],
            dependencies=[],
            commands=[['do_something']])

        commands = unformat(write_step(s)).split('\n')[1:]

        self.assertTrue('mkdir -p /src /tmp/fizz/fuzz' in commands)
        self.assertEqual(2, len(commands))
コード例 #4
0
ファイル: test_gnu_make.py プロジェクト: isciences/wsim
    def test_pattern_rule_conversion(self):
        s = Step(targets=['a.txt', 'b.txt'],
                 dependencies='source.txt',
                 commands=[['process', 'source.txt', 'a.txt', 'b.txt']])

        declaration_line, command_line = write_step(s).split('\n')[:2]

        self.assertTrue('a%txt' in declaration_line)
        self.assertTrue('b%txt' in declaration_line)
        self.assertTrue('source%txt' in declaration_line)

        self.assertTrue('a.txt' in command_line)
        self.assertTrue('b.txt' in command_line)
        self.assertTrue('source.txt' in command_line)
コード例 #5
0
ファイル: test_gnu_make.py プロジェクト: isciences/wsim
    def test_variable_substitution(self):
        s = Step(
            targets=['{ROOT_DIR}/fizz'],
            dependencies=['{SOURCE_DIR}/buzz'],
            commands=[['echo', '{SOURCE_DIR}/buzz', '>', '{ROOT_DIR}/fizz']])

        step_text = write_step(
            s, dict(ROOT_DIR='/tmp/root', SOURCE_DIR='/tmp/src'))

        self.assertTrue('/tmp/root/fizz' in step_text)
        self.assertTrue('/tmp/src/buzz' in step_text)

        self.assertFalse('ROOT_DIR' in step_text)
        self.assertFalse('SRC_DIR' in step_text)

        self.assertFalse('{' in step_text)
        self.assertFalse('}' in step_text)
コード例 #6
0
ファイル: test_gnu_make.py プロジェクト: isciences/wsim
    def test_commands_arguments_aligned(self):
        s = Step(targets='outputs/results.nc',
                 dependencies='inputs.nc',
                 commands=[[
                     'process.py', '--input', 'inputs.nc', '--output',
                     'outputs/results.nc', '--compress', '3', '--nohistory'
                 ]])

        command_lines = [
            line.strip() for line in write_step(s).split('\n')
            if line.startswith('\t')
        ]

        self.assertEqual(7, len(command_lines))
        self.assertTrue(
            all(
                line.startswith('mkdir') or line.startswith('process.py')
                or line.startswith('-') for line in command_lines))
コード例 #7
0
ファイル: test_gnu_make.py プロジェクト: isciences/wsim
    def test_variable_substitution_error(self):
        s = Step(targets='a',
                 dependencies='b',
                 commands=[['{PROGRAM}', 'a', 'b']])

        self.assertRaises(KeyError, lambda: write_step(s, dict(PROG='q')))