示例#1
0
    def generate_file(tmp_dir, start, stop):
        tmp = Tempfile(folder=tmp_dir)
        tmp.write(bytearray(map(lambda v: v % 256, range(start, stop))))

        tmp.close()

        return tmp
示例#2
0
    def generate_file(tmp_dir, size, suffix='.tmp'):
        tmp = Tempfile(root_dir=tmp_dir, suffix=suffix)
        tmp.write(bytearray(random.randint(0, 255) for i in range(size)))

        tmp.close()

        return tmp
示例#3
0
    def test_node_batch(self):

        with Tempdir() as tmp_dir:
            vfile_name = Tempfile(folder=tmp_dir)
            vfile_name.close()
            with EntitiesFile(vfile_name) as vfile:
                src_files = self.generate_source_files(tmp_dir, 5, 100)

                self._rebuild_batch_node(vfile, src_files, len(src_files))
                self._rebuild_batch_node(vfile, src_files, 0)
                self._rebuild_batch_node(vfile, src_files[:-2], 0)
                self._rebuild_batch_node(vfile, src_files[0:1], 0)

                # -----------------------------------------------------------

                write_bin_file(src_files[1], b"src_file1")
                write_bin_file(src_files[2], b"src_file1")

                self._rebuild_batch_node(vfile, src_files, 2)
示例#4
0
    def test_node_batch(self):

        with Tempdir() as tmp_dir:
            vfile_name = Tempfile(root_dir=tmp_dir)
            vfile_name.close()
            with EntitiesFile(vfile_name) as vfile:
                src_files = self.generate_source_files(tmp_dir, 5, 100)

                self._rebuild_batch_node(vfile, src_files, len(src_files))
                self._rebuild_batch_node(vfile, src_files, 0)
                self._rebuild_batch_node(vfile, src_files[:-2], 0)
                self._rebuild_batch_node(vfile, src_files[0:1], 0)

                # -----------------------------------------------------------

                write_bin_file(src_files[1], b"src_file1")
                write_bin_file(src_files[2], b"src_file1")

                self._rebuild_batch_node(vfile, src_files, 2)
示例#5
0
 def test_node_batch(self):
   
   with Tempdir() as tmp_dir:
     vfile_name = Tempfile( dir = tmp_dir )
     vfile_name.close()
     with ValuesFile( vfile_name ) as vfile:
       src_files = self.generateSourceFiles( tmp_dir, 5, 100 )
       
       self._rebuildBatchNode( vfile, src_files, len(src_files) )
       self._rebuildBatchNode( vfile, src_files, 0 )
       self._rebuildBatchNode( vfile, src_files[:-2], 0 )
       self._rebuildBatchNode( vfile, src_files[0:1], 0 )
       
       #//-------------------------------------------------------//
       
       writeBinFile( src_files[1], b"src_file1" )
       writeBinFile( src_files[2], b"src_file1" )
       FileChecksumValue( src_files[1] )   # clear cached value
       FileChecksumValue( src_files[2] )   # clear cached value
       
       self._rebuildBatchNode( vfile, src_files, 2 )
示例#6
0
    def test_gcc_compiler_batch_error(self):
        with Tempdir() as tmp_dir:

            build_dir = os.path.join(tmp_dir, 'output')
            src_dir = os.path.join(tmp_dir, 'src')

            os.makedirs(src_dir)

            num_src_files = 5

            src_files, hdr_files = self.generate_cpp_files(
                src_dir, 'foo', num_src_files)

            src_file_orig = Tempfile(folder=tmp_dir)
            src_file_orig.close()

            self.copy_file(src_files[0], src_file_orig)

            self.add_error_to_cpp_file(src_files[0])

            cfg = ProjectConfig(args=["build_dir=%s" % build_dir])

            prj = Project(cfg)

            tools_path = os.path.join(os.path.dirname(__file__),
                                      '../../tools')
            cpp = prj.tools.try_tool('g++', tools_path=tools_path)
            if cpp is None:
                print("WARNING: g++ tool has not been found. Skip the test.")
                return

            cpp.Compile(src_files, batch_build=True, batch_groups=1)

            self.build_prj(prj, 0, num_failed_nodes=1)

            self.copy_file(src_file_orig, src_files[0])

            cpp.Compile(src_files)

            self.build_prj(prj, 1)
示例#7
0
 def   test_msvc_compiler_batch_error(self):
   with Tempdir() as tmp_dir:
     
     build_dir = os.path.join( tmp_dir, 'output')
     src_dir = os.path.join( tmp_dir, 'src')
     
     os.makedirs( src_dir )
     
     num_src_files = 5
     
     src_files, hdr_files = self.generateCppFiles( src_dir, 'foo', num_src_files )
     
     src_file_orig = Tempfile( dir = tmp_dir )
     src_file_orig.close()
     
     self.copyFile( src_files[0], src_file_orig )
     
     self.addErrorToCppFile( src_files[0] )
     
     cfg = ProjectConfig( args = [ "build_dir=%s" % build_dir] )
     
     prj = Project( cfg.options, cfg.targets )
     
     try:
       cpp = prj.tools['msvc++']
     except  ErrorToolNotFound:
       print("WARNING: MSVC tool has not been found. Skip the test.")
       return
     
     cpp.Compile( src_files, batch_build = True, batch_groups = 1 )
     
     self.buildPrj( prj, 0, num_failed_nodes = 1 )
     
     self.copyFile( src_file_orig, src_files[0] )
     
     cpp.Compile( src_files )
     
     self.buildPrj( prj, 1 )