Ejemplo n.º 1
0
    def testOrderOnlyDependency( self ):
        artifact1 = AtomicArtifact( "TestArtefact1", [ os.path.join( "tmp", "file1" ), os.path.join( "tmp", "file2" ) ], [], [], [], False )
        compound = CompoundArtifact( "TestArtefact3", [ artifact1 ], False )
        artifact2 = AtomicArtifact( "TestArtefact2", [ os.path.join( "tmp", "file3" ), os.path.join( "tmp", "file4" ) ], [], [ artifact1 ], [], False )
        
        g1 = Graph( "project" )
        cluster1 = Cluster( "TestArtefact1" )
        cluster1.add( Node( os.path.join( "tmp", "file1" ) ) )
        cluster1.add( Node( os.path.join( "tmp", "file2" ) ) )
        cluster = Cluster( "TestArtefact3" )
        cluster.add( cluster1 )
        g1.add( cluster )
        cluster2 = Cluster( "TestArtefact2" )
        cluster2.add( Node( os.path.join( "tmp", "file3" ) ) )
        cluster2.add( Node( os.path.join( "tmp", "file4" ) ) )
        g1.add( cluster2 )
        link = Link( cluster2, cluster1 )
        link.attr[ "style" ] = "dashed"
        g1.add( link )
        
        g2 = Graph( "project" )
        g2.add( artifact2.getGraphNode() )
        g2.add( compound.getGraphNode() )
        for l in artifact2.getGraphLinks():
            g2.add( l )
        for l in compound.getGraphLinks():
            g2.add( l )

        self.assertTrue( Graph.areSame( g1, g2 ) )
Ejemplo n.º 2
0
    def testGetProductionActionWhenAutomaticDependencyMustBeProduced( self ):
        AtomicArtifact._AtomicArtifact__fileIsMissing( os.path.join( "tmp1", "file1" ) ).returns( False )
        self.strongDependency.computeIfMustBeProduced( [], [], False ).returns( False )
        self.automaticDependency.computeIfMustBeProduced( [], [], False ).returns( True )
        self.artifact.doGetProductionAction().returns( self.productionAction )
        self.orderOnlyDependency.computeIfMustBeProduced( [], [], False ).returns( False )
        self.automaticDependency.computeProductionAction( [], [], False, DontCheck() ).returns( self.automaticDependencyProductionAction )

        self.productionAction.computePreview().returns( "create file1" )
        self.automaticDependencyProductionAction.computePreview().returns( "create automaticDependency" )

        self.m.startTest()

        action = self.artifact.getProductionAction()
        
        model = Graph( "action" )
        model.nodeAttr[ "shape" ] = "box"
        n0 = Node( "create file1" )
        n2 = Node( "create automaticDependency" )
        n3 = Node( "mkdir -p tmp1" )
        n4 = Node( "rm -f " + os.path.join( "tmp1", "file1" ) )
        model.add( n0 )
        model.add( n2 )
        model.add( n3 )
        model.add( n4 )
        model.add( Link( n0, n2 ) )
        model.add( Link( n0, n3 ) )
        model.add( Link( n0, n4 ) )
        
        self.assertTrue( actionHasGraph( action, model ) )
Ejemplo n.º 3
0
    def testGetProductionActionWhenOrderOnlyDependencyMustBeProduced( self ):
        AtomicArtifact._AtomicArtifact__fileIsMissing( os.path.join( "tmp1", "file1" ) ).returns( False )
        self.strongDependency.computeIfMustBeProduced( [], [], False ).returns( False )
        self.automaticDependency.computeIfMustBeProduced( [], [], False ).returns( False )
        self.artifact.getOldestFile( [], [] ).returns( 1200001 )
        self.strongDependency.getNewestFile( [], [] ).returns( 1200000 )
        self.automaticDependency.getNewestFile( [], [] ).returns( 1200000 )
        self.orderOnlyDependency.computeIfMustBeProduced( [], [], False ).returns( True )
        self.orderOnlyDependency.computeProductionAction( [], [], False, DontCheck() ).returns( self.orderOnlyDependencyProductionAction )
        
        self.orderOnlyDependencyProductionAction.computePreview().returns( "create orderOnlyDependency" )

        self.m.startTest()

        action = self.artifact.getProductionAction()
        
        model = Graph( "action" )
        model.nodeAttr[ "shape" ] = "box"
        n0 = Node( "" )
        n1 = Node( "create orderOnlyDependency" )
        model.add( n0 )
        model.add( n1 )
        model.add( Link( n0, n1 ) )
        
        self.assertTrue( actionHasGraph( action, model ) )
Ejemplo n.º 4
0
 def testAtomic( self ):
     artifact = AtomicArtifact( "TestArtefact", [ os.path.join( "tmp", "file1" ), os.path.join( "tmp", "file2" ) ], [], [], [], False )
     
     g1 = Graph( "project" )
     cluster = Cluster( "TestArtefact" )
     cluster.add( Node( os.path.join( "tmp", "file1" ) ) )
     cluster.add( Node( os.path.join( "tmp", "file2" ) ) )
     g1.add( cluster )
     
     g2 = Graph( "project" )
     g2.add( artifact.getGraphNode() )
     
     self.assertTrue( Graph.areSame( g1, g2 ) )
Ejemplo n.º 5
0
    def testGetProductionActionWithNoReasonToProduce( self ):
        AtomicArtifact._AtomicArtifact__fileIsMissing( os.path.join( "tmp1", "file1" ) ).returns( False )
        self.strongDependency.computeIfMustBeProduced( [], [], False ).returns( False )
        self.automaticDependency.computeIfMustBeProduced( [], [], False ).returns( False )
        self.artifact.getOldestFile( [], [] ).returns( 1200001 )
        self.strongDependency.getNewestFile( [], [] ).returns( 1200000 )
        self.automaticDependency.getNewestFile( [], [] ).returns( 1200000 )
        self.orderOnlyDependency.computeIfMustBeProduced( [], [], False ).returns( False )

        self.m.startTest()

        action = self.artifact.getProductionAction()
        model = Graph( "action" )
        model.nodeAttr[ "shape" ] = "box"
        model.add( Node( "" ) )
        self.assertTrue( actionHasGraph( action, model ) )
Ejemplo n.º 6
0
 def recordGetProductionAction( self ):
     AtomicArtifact._AtomicArtifact__fileIsMissing( os.path.join( "tmp1", "file1" ) ).returns( True )
     self.atomicArtifact1.doGetProductionAction().returns( self.fileProductionAction1 )
     AtomicArtifact._AtomicArtifact__fileIsMissing( os.path.join( "tmp2", "file2" ) ).returns( True )
     self.atomicArtifact2.doGetProductionAction().returns( self.fileProductionAction2 )
Ejemplo n.º 7
0
 def recordGetProductionAction( self ):
     AtomicArtifact._AtomicArtifact__fileIsMissing( os.path.join( "tmp1", "file1" ) ).returns( False )
     AtomicArtifact._AtomicArtifact__fileIsMissing( os.path.join( "tmp2", "file2" ) ).returns( True )
     self.artifact.doGetProductionAction().returns( self.productionAction )