Exemple #1
0
 def test_cmd(self):
     self.maxDiff = None
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=NinjuWarning)
         n = Ninju(no_cwd_check=True)
         n.cmd('echo', '/path/echo', description='echo test')
         result = generate_ninja(n, newline=False)
         self.assertEqual(result, expected[1])
Exemple #2
0
 def test_var(self):
     self.maxDiff = None
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=NinjuWarning)
         n = Ninju(no_cwd_check=True)
         n.var('myvar', 'myvalue')
         result = generate_ninja(n, newline=False)
         self.assertEqual(result, expected[0])
Exemple #3
0
 def test_pool(self):
     self.maxDiff = None
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=NinjuWarning)
         n = Ninju(no_cwd_check=True)
         n.cmd('cmd1', 'bin1', pool=1)
         n.cmd('cmd2', 'bin2', pool=3)
         n.cmd('cmd3', 'bin3', pool='console')
         result = generate_ninja(n, newline=False)
         self.assertEqual(result, expected[7])
Exemple #4
0
 def test_exec_cmd(self):
     self.maxDiff = None
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=NinjuWarning)
         n = Ninju(no_cwd_check=True)
         root = n.dir()
         n.exec_cmd('cmd1', 'bin1', '${in} ${out}')
         n.target('target').cmd1()
         result = generate_ninja(n, newline=False)
         self.assertEqual(result, expected[5])
Exemple #5
0
 def test_phony(self):
     self.maxDiff = None
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=NinjuWarning)
         n = Ninju(no_cwd_check=True)
         root = n.dir()
         n.cmd('cmd1', 'bin1', '${in} ${out}')
         a = root('file1.txt').cmd1(root('file2.txt'))
         b = root('file3.txt').cmd1(outputs=2)
         n.target('one').phony(a)
         n.target('all').phony(n.files(a, b))
         result = generate_ninja(n, newline=False)
         self.assertEqual(result, expected[4])
Exemple #6
0
 def test_build(self):
     self.maxDiff = None
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=NinjuWarning)
         n = Ninju(no_cwd_check=True)
         root = n.dir()
         src = n.dir('src')
         tmp = n.dir('tmp')
         n.cmd('copy', '/path/cp', '${in} ${out}', description='copy file')
         a = root('file1.txt').copy(tmp('file2.txt'))
         a.copy(os.path.join('${root}', 'file3.txt'))
         result = generate_ninja(n, newline=False)
         self.assertEqual(result, expected[3])
Exemple #7
0
 def test_dir(self):
     self.maxDiff = None
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=NinjuWarning)
         n = Ninju(no_cwd_check=True)
         root = n.root
         tmp = n.dir('tmp')
         dst = n.dir('dst', 'dir1', var='dst')
         n.cmd('copy', '/path/cp', '${in} ${out}', description='copy file')
         root('file1.txt').copy(tmp('file2.txt'))
         root('file3.txt').copy(dst('file4.txt'))
         result = generate_ninja(n, newline=False)
         self.assertEqual(result, expected[2])
Exemple #8
0
    def test_multiple_outputs(self):
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', category=NinjuWarning)
            n = Ninju(no_cwd_check=True)
            src = n.dir('src')
            n.cmd('cmd1', 'bin1', '${in} ${out}')
            n.cmd('cmd2', 'bin2', '${in} ${out}')

            a = src('a.txt')
            b = a.cmd1(outputs=2)
            c = b.cmd2()

            result = generate_ninja(n, newline=False)
            self.assertEqual(result, expected[2])
Exemple #9
0
    def test_pipeline(self):
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', category=NinjuWarning)
            n = Ninju(no_cwd_check=True)
            src = n.dir('src')
            n.cmd('cmd1', 'bin1', '${in} ${out}')
            n.cmd('cmd2', 'bin2', '${in} ${out}')
            n.cmd('cmd3', 'bin3', '${in} ${out}')

            input = src('a.txt')
            output = n.builddir('b.txt')
            input.cmd1().cmd2().cmd3(output)

            result = generate_ninja(n, newline=False)
            self.assertEqual(result, expected[0])
Exemple #10
0
    def test_inputs_from_multiple_commands(self):
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', category=NinjuWarning)
            n = Ninju(no_cwd_check=True)
            src = n.dir('src')
            n.cmd('cmd1', 'bin1', '${in} ${out}')
            n.cmd('cmd2', 'bin2', '${in} ${out}')
            n.cmd('cmd3', 'bin3', '${in} ${out}')

            a = src('a.txt')
            b = src('b.txt')
            c = a.cmd1()
            d = b.cmd2()
            e = n.files(c, d).cmd3()

            result = generate_ninja(n, newline=False)
            self.assertEqual(result, expected[1])