Пример #1
0
    def test_bm_node_names(self):

        with Tempdir() as tmp_dir:
            src_files = self.generate_source_files(tmp_dir, 3, 201)
            options = builtin_options()
            options.build_dir = tmp_dir

            builder = ChecksumBuilder(options, 0, 256, replace_ext=False)
            bm = BuildManager()
            try:
                src_entities = []
                for s in src_files:
                    src_entities.append(FileChecksumEntity(s))

                node0 = Node(builder, None)
                node1 = Node(builder, src_entities)
                node2 = Node(builder, node1)
                node3 = Node(builder, node2)
                node4 = Node(builder, node3)

                bm.add([node0, node1, node2, node3, node4])

                bm.build(1, False)

                print("node2: %s" % str(node4))
                print("node2: %s" % str(node3))
                print("node2: %s" % str(node2))
                print("node1: %s" % str(node1))
                print("node0: %s" % str(node0))

            finally:
                bm.close()
Пример #2
0
def   _addNodesToBM( builder, src_files, Node = Node ):
  bm = BuildManager()
  try:
    checksums_node = Node( builder, src_files )
    checksums_node2 = Node( builder, checksums_node )
    
    bm.add( checksums_node ); bm.selfTest()
    bm.add( checksums_node2 ); bm.selfTest()
  except Exception:
    bm.close()
    raise
  
  return bm
Пример #3
0
def _add_nodes_to_bm(builder, src_files):
    bm = BuildManager()
    try:
        checksums_node = Node(builder, src_files)
        checksums_node2 = Node(builder, checksums_node)

        bm.add([checksums_node])
        bm.self_test()
        bm.add([checksums_node2])
        bm.self_test()
    except Exception:
        bm.close()
        raise

    return bm
Пример #4
0
def _add_nodes_to_bm(builder, src_files):
    bm = BuildManager()
    try:
        checksums_node = Node(builder, src_files)
        checksums_node2 = Node(builder, checksums_node)

        bm.add([checksums_node])
        bm.self_test()
        bm.add([checksums_node2])
        bm.self_test()
    except Exception:
        bm.close()
        raise

    return bm
Пример #5
0
 def test_install(self):
   
   with Tempdir() as tmp_install_dir:
     with Tempdir() as tmp_dir:
       # tmp_install_dir = Tempdir()
       # tmp_dir = Tempdir()
       
       build_dir = os.path.join( tmp_dir, 'output' )
       
       options = builtinOptions()
 
       options.build_dir = build_dir
       
       num_sources = 3
       
       sources = self.generateSourceFiles( tmp_dir, num_sources, 200 )
       
       installer = InstallBuilder( options, str(tmp_install_dir) )
       
       bm = BuildManager()
       try:
         
         result = Node( installer, sources )
 
         bm.add( result )
         
         self._build( bm, jobs = 1, keep_going = False )
         
         self.assertEqual( self.building_started, 1 )
         self.assertEqual( self.building_started, self.building_finished )
         
         bm.close()
         
         result = Node( installer, sources )
 
         bm = BuildManager()
         bm.add( result )
         
         self.building_started = 0
         self._build( bm, jobs = 1, keep_going = False )
         
         self.assertEqual( self.building_started, 0 )
         
       finally:
         bm.close()
Пример #6
0
  def test_exec(self):
    
    with Tempdir() as tmp_dir:
      
      build_dir = FilePath(tmp_dir).join('build')
      
      options = builtinOptions()

      cmd = [ whereProgram( "python" ), '-c', 'print("TEST EXEC")']

      options.build_dir = build_dir
      
      exec_cmd = ExecuteCommand( options )
      
      bm = BuildManager()
      try:
        
        result = Node( exec_cmd, cmd )

        bm.add( result )
        
        self._build( bm, jobs = 1, keep_going = False )
        
        self.assertEqual( self.building_started, 1 )
        self.assertEqual( self.building_started, self.building_finished )
        
        bm.close()
        
        result = Node( exec_cmd, cmd )

        bm = BuildManager()
        bm.add( result )
        
        self.building_started = 0
        self._build( bm, jobs = 1, keep_going = False )
        
        self.assertEqual( self.building_started, 0 )
        
      finally:
        bm.close()
Пример #7
0
    def test_exec(self):

        with Tempdir() as tmp_dir:

            build_dir = os.path.join(tmp_dir, 'build')

            options = builtin_options()

            cmd = [sys.executable, '-c', 'print("TEST EXEC")']

            options.build_dir = build_dir

            exec_cmd = ExecuteCommandBuilder(options)

            bm = BuildManager()
            try:

                result = Node(exec_cmd, cmd)

                bm.add([result])

                self._build(bm, jobs=1, keep_going=False)

                self.assertEqual(self.building_started, 1)
                self.assertEqual(self.building_started, self.built_nodes)

                bm.close()

                result = Node(exec_cmd, cmd)

                bm = BuildManager()
                bm.add([result])

                self.building_started = 0
                self._build(bm, jobs=1, keep_going=False)

                self.assertEqual(self.building_started, 0)

            finally:
                bm.close()
Пример #8
0
    def test_exec(self):

        with Tempdir() as tmp_dir:

            build_dir = os.path.join(tmp_dir, 'build')

            options = builtin_options()

            cmd = [sys.executable, '-c', 'print("TEST EXEC")']

            options.build_dir = build_dir

            exec_cmd = ExecuteCommandBuilder(options)

            bm = BuildManager()
            try:

                result = Node(exec_cmd, cmd)

                bm.add([result])

                self._build(bm, jobs=1, keep_going=False)

                self.assertEqual(self.building_started, 1)
                self.assertEqual(self.building_started, self.built_nodes)

                bm.close()

                result = Node(exec_cmd, cmd)

                bm = BuildManager()
                bm.add([result])

                self.building_started = 0
                self._build(bm, jobs=1, keep_going=False)

                self.assertEqual(self.building_started, 0)

            finally:
                bm.close()
Пример #9
0
    def test_bm_nodes(self):

        def _make_nodes(builder):
            node1 = Node(builder, value1)
            copy_node1 = Node(builder, node1)
            copy2_node1 = Node(builder, copy_node1)
            node2 = Node(builder, value2)
            node3 = Node(builder, value3)
            copy_node3 = Node(builder, node3)

            copy2_node3 = Node(builder, copy_node3)
            copy2_node3.depends([node1, copy_node1])

            return node1, node2, node3, copy_node1,\
                copy_node3, copy2_node1, copy2_node3

        with Tempdir() as tmp_dir:
            options = builtin_options()
            options.build_dir = tmp_dir

            bm = BuildManager()

            value1 = SimpleEntity(
                "http://aql.org/download1", name="target_url1")
            value2 = SimpleEntity(
                "http://aql.org/download2", name="target_url2")
            value3 = SimpleEntity(
                "http://aql.org/download3", name="target_url3")

            builder = CopyValueBuilder(options)

            bm.add(_make_nodes(builder))

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False)
            bm.close()
            self.assertEqual(self.built_nodes, 7)

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

            bm.add(_make_nodes(builder))

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False)
            bm.close()
            self.assertEqual(self.built_nodes, 0)

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

            bm.add(_make_nodes(builder))

            self.removed_nodes = 0
            bm.clear()
            bm.close()
            self.assertEqual(self.removed_nodes, 7)

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

            nodes = _make_nodes(builder)
            copy_node3 = nodes[4]
            bm.add(nodes)

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False, nodes=[copy_node3])
            bm.close()
            self.assertEqual(self.built_nodes, 2)

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

            nodes = _make_nodes(builder)
            node2 = nodes[1]
            copy_node3 = nodes[4]
            bm.add(nodes)

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False, nodes=[node2, copy_node3])
            bm.close()
            self.assertEqual(self.built_nodes, 1)
Пример #10
0
    def test_bm_nodes(self):
        def _make_nodes(builder):
            node1 = Node(builder, value1)
            copy_node1 = Node(builder, node1)
            copy2_node1 = Node(builder, copy_node1)
            node2 = Node(builder, value2)
            node3 = Node(builder, value3)
            copy_node3 = Node(builder, node3)

            copy2_node3 = Node(builder, copy_node3)
            copy2_node3.depends([node1, copy_node1])

            return node1, node2, node3, copy_node1,\
                copy_node3, copy2_node1, copy2_node3

        with Tempdir() as tmp_dir:
            options = builtin_options()
            options.build_dir = tmp_dir

            bm = BuildManager()

            value1 = SimpleEntity("http://aql.org/download1",
                                  name="target_url1")
            value2 = SimpleEntity("http://aql.org/download2",
                                  name="target_url2")
            value3 = SimpleEntity("http://aql.org/download3",
                                  name="target_url3")

            builder = CopyValueBuilder(options)

            bm.add(_make_nodes(builder))

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False)
            bm.close()
            self.assertEqual(self.built_nodes, 7)

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

            bm.add(_make_nodes(builder))

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False)
            bm.close()
            self.assertEqual(self.built_nodes, 0)

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

            bm.add(_make_nodes(builder))

            self.removed_nodes = 0
            bm.clear()
            bm.close()
            self.assertEqual(self.removed_nodes, 7)

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

            nodes = _make_nodes(builder)
            copy_node3 = nodes[4]
            bm.add(nodes)

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False, nodes=[copy_node3])
            bm.close()
            self.assertEqual(self.built_nodes, 2)

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

            nodes = _make_nodes(builder)
            node2 = nodes[1]
            copy_node3 = nodes[4]
            bm.add(nodes)

            self.built_nodes = 0
            bm.build(jobs=1, keep_going=False, nodes=[node2, copy_node3])
            bm.close()
            self.assertEqual(self.built_nodes, 1)