예제 #1
0
 def tearDown(self):
     try:
         for p in Path('.').glob('lib*'):
             p.unlink()
         Path('myprogram').unlink()
     except:
         pass
예제 #2
0
 def test_mod_times(self):
     ComputeSum().make()
     file = 'item_5_price.txt'
     mod_time1 = Path(file).stat().st_mtime_ns
     time.sleep(1)
     with open(file, 'w', encoding='UTF-8') as f:
         f.write('150')
     mod_time2 = Path(file).stat().st_mtime_ns
     self.assertGreater(mod_time2, mod_time1)
예제 #3
0
class CreateProgram(Task):
    def __init__(self, prog_file):
        self._prog_file = Path(prog_file)
        self.trigger_exception_if_buit = False

    def target(self):
        return self._prog_file

    def build(self, lib1_obj, lib2_obj, lib3_obj=None):
        if self.trigger_exception_if_buit:
            raise Exception('Sould not be rebuilt')
        # os.system('gcc lib1.o lib2.o -o myprogram')
        assert lib1_obj.exists()
        assert lib2_obj.exists()
        if lib3_obj:
            assert lib3_obj.exists()
        self._prog_file.touch()
예제 #4
0
    def build(self, *tax_files):
        sum_ = 0
        for file in tax_files:
            with file.open(encoding='UTF-8') as f:
                sum_ += int(f.read())

        with Path('total.txt').open('w', encoding='UTF-8') as f:
            f.write('%d' % sum_)
예제 #5
0
class CreateItem(Task):
    def __init__(self, num):
        self._output_path = Path('item_%d_price.txt' % num)

    def target(self):
        return self._output_path

    def build(self):
        with self._output_path.open('w', encoding='UTF-8') as f:
            f.write('100')
예제 #6
0
class CreateItem(Task):
    def __init__(self, num):
        self._output_path = Path('item_%d_price.txt' % num)

    def target(self):
        return self._output_path

    def build(self):
        with self._output_path.open('w', encoding='UTF-8') as f:
            f.write('100')
예제 #7
0
class AddTaxToItem(Task):
    def __init__(self, num):
        self._output_path = Path('item_%d_tax.txt' % num)

    def target(self):
        return self._output_path

    def build(self, input_path):
        with input_path.open(encoding='UTF-8') as f:
            price = int(f.read())
        with self._output_path.open('w', encoding='UTF-8') as f:
            f.write('%d' % int(price * 1.3))
예제 #8
0
class AddTaxToItem(Task):
    def __init__(self, num):
        self._output_path = Path('item_%d_tax.txt' % num)

    def target(self):
        return self._output_path

    def build(self, input_path):
        with input_path.open(encoding='UTF-8') as f:
            price = int(f.read())
        with self._output_path.open('w', encoding='UTF-8') as f:
            f.write('%d' % int(price * 1.3))
예제 #9
0
 def setUp(self):
     Path('lib1.c').touch()
     Path('lib2.c').touch()
     Path('lib3.c').touch()
     create_lib1 = CreateObjFile('lib1') << Path('lib1.c')
     create_lib2 = CreateObjFile('lib1') << Path('lib2.c')
     create_lib3 = CreateObjFile('lib3') << Path('lib3.c')
     self.create_prog1 = CreateProgram('myprogram') << create_lib1 + \
                                                       create_lib2
     self.create_prog2 = CreateProgram('myprogram') << create_lib1 + \
                                                       create_lib2 + \
                                                       create_lib3
예제 #10
0
 def test_compile_with_three_dependencies(self):
     self.create_prog2.make()
     self.assertTrue(Path('myprogram').exists())
예제 #11
0
 def test_recompile_from_scratch(self):
     self.create_prog1.make()
     self.assertTrue(Path('myprogram').exists())
     time.sleep(1.1)
     self.create_prog1.trigger_exception_if_buit = True
     self.create_prog1.make()
예제 #12
0
 def test_compile_from_scratch(self):
     self.create_prog1.make()
     self.assertTrue(Path('myprogram').exists())
예제 #13
0
파일: copy.py 프로젝트: rayene/buildall
 def __init__(self, destination):
     self._destination = Path(destination)
예제 #14
0
 def __init__(self, prog_file):
     self._prog_file = Path(prog_file)
     self.trigger_exception_if_buit = False
예제 #15
0
 def target(self):
     return Path(self._decompressed)
예제 #16
0
 def __init__(self, num):
     self._output_path = Path('item_%d_price.txt' % num)
예제 #17
0
 def __init__(self, num):
     self._output_path = Path('item_%d_price.txt' % num)
예제 #18
0
 def tearDown(self):
     for f in Path('.').glob('*.txt'):
         f.unlink()
예제 #19
0
 def target(self):
     return Path('total.txt')
예제 #20
0
 def target(self):
     return Path(self.filename + '.o')
예제 #21
0
 def build(self, c_file):
     # os.system('gcc -c %s.o -o %s.o'%c_file)
     assert c_file.exists()
     Path(self.filename + '.o').touch()
예제 #22
0
파일: download.py 프로젝트: rayene/buildall
 def target(self):
     return Path(self._destination)
예제 #23
0
 def build(self, compressed):
     self.debug('Decompressing %s to %s' % (compressed, self._decompressed))
     with tarfile.open(str(compressed)) as f:
         f.extractall(str(Path(self._decompressed).parent))
     assert Path(self._decompressed).exists()
     Path(self._decompressed).touch()