示例#1
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 ) )
示例#2
0
    def testSimple( self ):
        self.a1.computePreview().returns( "a1's preview" )

        self.m.startTest()
        
        g1 = Graph( "action" )
        g1.nodeAttr[ "shape" ] = "box"
        g1.add( Node( "a1's preview" ) )
        
        g2 = self.a1.getGraph()
        
        self.assertTrue( Graph.areSame( g1, g2 ) )
示例#3
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 ) )
示例#4
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 ) )
示例#5
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 ) )
示例#6
0
 def testCompound( self ):
     atomic1 = AtomicArtifact( "TestArtefact1", [ os.path.join( "tmp", "file1" ), os.path.join( "tmp", "file2" ) ], [], [], [], False )
     atomic2 = AtomicArtifact( "TestArtefact2", [ os.path.join( "tmp", "file3" ), os.path.join( "tmp", "file4" ) ], [], [], [], False )
     artifact = CompoundArtifact( "TestArtefact3", [ atomic1, atomic2 ], False )
     
     g1 = Graph( "project" )
     mainCluster = Cluster( "TestArtefact3" )
     cluster = Cluster( "TestArtefact1" )
     cluster.add( Node( os.path.join( "tmp", "file1" ) ) )
     cluster.add( Node( os.path.join( "tmp", "file2" ) ) )
     mainCluster.add( cluster )
     cluster = Cluster( "TestArtefact2" )
     cluster.add( Node( os.path.join( "tmp", "file3" ) ) )
     cluster.add( Node( os.path.join( "tmp", "file4" ) ) )
     mainCluster.add( cluster )
     g1.add( mainCluster )
     
     g2 = Graph( "project" )
     g2.add( artifact.getGraphNode() )
     
     self.assertTrue( Graph.areSame( g1, g2 ) )
示例#7
0
    def testGetProductionAction( self ):
        self.recordGetProductionAction()
        with self.m.unorderedGroup():
            self.fileProductionAction1.computePreview().returns( "create file1" )
            self.fileProductionAction2.computePreview().returns( "create file2" )

        self.m.startTest()

        action = self.artifact.getProductionAction()

        model = Graph( "action" )
        model.nodeAttr[ "shape" ] = "box"
        n0 = Node( "" )
        n1 = Node( "create file1" )
        n11 = Node( "mkdir -p tmp1" )
        n12 = Node( "rm -f " + os.path.join( "tmp1", "file1" ) )
        n2 = Node( "create file2" )
        n21 = Node( "mkdir -p tmp2" )
        n22 = Node( "rm -f " + os.path.join( "tmp2", "file2" ) )
        model.add( n0 )
        model.add( n1 )
        model.add( n11 )
        model.add( n12 )
        model.add( n2 )
        model.add( n21 )
        model.add( n22 )
        model.add( Link( n0, n1 ) )
        model.add( Link( n0, n2 ) )
        model.add( Link( n1, n11 ) )
        model.add( Link( n1, n12 ) )
        model.add( Link( n2, n21 ) )
        model.add( Link( n2, n22 ) )
        
        self.assertTrue( actionHasGraph( action, model ) )
示例#8
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 ) )
示例#9
0
    def testGetProductionAction( self ):
        self.recordGetProductionAction()
        self.productionAction.computePreview().returns( "create file1 and file2" )

        self.m.startTest()

        action = self.artifact.getProductionAction()

        model = Graph( "action" )
        model.nodeAttr[ "shape" ] = "box"
        n0 = Node( "create file1 and file2" )
        n1 = Node( "mkdir -p tmp1" )
        n2 = Node( "mkdir -p tmp2" )
        n3 = Node( "rm -f " + os.path.join( "tmp1", "file1" ) )
        n4 = Node( "rm -f " + os.path.join( "tmp2", "file2" ) )
        model.add( n0 )
        model.add( n1 )
        model.add( n2 )
        model.add( n3 )
        model.add( n4 )
        model.add( Link( n0, n1 ) )
        model.add( Link( n0, n2 ) )
        model.add( Link( n0, n3 ) )
        model.add( Link( n0, n4 ) )
        
        self.assertTrue( actionHasGraph( action, model ) )
示例#10
0
def actionHasGraph( a, g ):
    return Graph.areSame( a.getGraph(), g )
示例#11
0
    def testDeep( self ):
        self.a1.addPredecessor( self.a2 )
        self.a2.addPredecessor( self.a3 )

        self.a1.computePreview().returns( "a1's preview" )
        self.a2.computePreview().returns( "a2's preview" )
        self.a3.computePreview().returns( "a3's preview" )
        
        self.m.startTest()
        
        g1 = Graph( "action" )
        g1.nodeAttr[ "shape" ] = "box"
        n1 = Node( "a1's preview" )
        g1.add( n1 )
        n2 = Node( "a2's preview" )
        g1.add( n2 )
        n3 = Node( "a3's preview" )
        g1.add( n3 )
        g1.add( Link( n1, n2 ) )
        g1.add( Link( n2, n3 ) )
        
        g2 = self.a1.getGraph()
        
        self.assertTrue( Graph.areSame( g1, g2 ) )