示例#1
0
    def testMultipleInputsAndOutputs(self):
        in1 = Artifact("in1", None)
        in2 = Artifact("in2", None)
        action = Action(self.rule, "")
        out1 = Artifact("out1", action)
        out2 = Artifact("out2", action)
        action.command = MockCommand([in1, in2], [out1, out2])

        # outputs don't exist.
        self.dir.add("in1", 20, "")
        self.dir.add("in2", 40, "")
        self.assertEqual([action], self.doBuild(out1, out2))

        # only one output exists
        self.dir.add("out1", 50, "")
        self.assertEqual([action], self.doBuild(out1, out2))
        self.assertEqual([], self.doBuild(out1))

        # both outputs exist, one is outdated
        self.dir.add("out2", 10, "")
        self.assertEqual([action], self.doBuild(out1, out2))
        self.assertEqual([], self.doBuild(out1))

        # both outputs exist, one is older than *one* of the inputs
        self.dir.add("out2", 30, "")
        self.assertEqual([action], self.doBuild(out1, out2))
        self.assertEqual([], self.doBuild(out1))

        # both outputs exist and are up-to-date.
        self.dir.add("out2", 50, "")
        self.assertEqual([], self.doBuild(out1, out2))
示例#2
0
  def testMultipleInputsAndOutputs(self):
    in1 = Artifact("in1", None)
    in2 = Artifact("in2", None)
    action = Action(self.rule, "")
    out1 = Artifact("out1", action)
    out2 = Artifact("out2", action)
    action.command = MockCommand([in1, in2], [out1, out2])

    # outputs don't exist.
    self.dir.add("in1", 20, "")
    self.dir.add("in2", 40, "")
    self.assertEqual([action], self.doBuild(out1, out2))

    # only one output exists
    self.dir.add("out1", 50, "")
    self.assertEqual([action], self.doBuild(out1, out2))
    self.assertEqual([], self.doBuild(out1))

    # both outputs exist, one is outdated
    self.dir.add("out2", 10, "")
    self.assertEqual([action], self.doBuild(out1, out2))
    self.assertEqual([], self.doBuild(out1))

    # both outputs exist, one is older than *one* of the inputs
    self.dir.add("out2", 30, "")
    self.assertEqual([action], self.doBuild(out1, out2))
    self.assertEqual([], self.doBuild(out1))

    # both outputs exist and are up-to-date.
    self.dir.add("out2", 50, "")
    self.assertEqual([], self.doBuild(out1, out2))
示例#3
0
  def testConditionalInputs(self):
    input = Artifact("input", None)
    condition = Artifact("cond", None)
    conditional_action = Action(self.rule, "", "conditional_action")
    conditional_input = Artifact("cond_input", conditional_action)
    conditional_action.command = MockCommand([], [conditional_input])
    action = Action(self.rule, "", "action")
    output = Artifact("output", action)
    action.command = ConditionalMockCommand(
        condition, [input], [conditional_input], [output])

    # output doesn't exist, condition is false.
    self.dir.add("cond", 20, "false")
    self.dir.add("input", 20, "")
    self.assertEqual([action], self.doBuild(output))

    # output exists, condition still false.
    self.dir.add("output", 30, "")
    self.assertEqual([], self.doBuild(output))

    # condition newer than output.
    self.dir.add("cond", 40, "")
    self.assertEqual([action], self.doBuild(output))
    self.dir.add("cond", 20, "")

    # input newer than output.
    self.dir.add("input", 40, "")
    self.assertEqual([action], self.doBuild(output))
    self.dir.add("input", 20, "")

    # condition is true, cond_input doesn't exist.
    self.dir.add("cond", 20, "true")
    self.assertEqual([conditional_action, action], self.doBuild(output))

    # cond_input newer than output -- doesn't matter since cond is false.
    self.dir.add("cond_input", 40, "")
    self.dir.add("cond", 20, "false")
    self.assertEqual([], self.doBuild(output))

    # condition is true, cond_input is newer than output.
    self.dir.add("cond", 20, "true")
    self.assertEqual([action], self.doBuild(output))

    # output newer than cond_input.
    self.dir.add("cond_input", 20, "")
    self.assertEqual([], self.doBuild(output))
示例#4
0
    def testSimpleAction(self):
        input = Artifact("input", None)
        action = Action(self.rule, "")
        output = Artifact("output", action)
        action.command = MockCommand([input], [output])

        # output doesn't exist.
        self.dir.add("input", 20, "")
        self.assertEqual([action], self.doBuild(output))

        # output exists but is older than input.
        self.dir.add("output", 10, "")
        self.assertEqual([action], self.doBuild(output))

        # output exists and is newer than input.
        self.dir.add("output", 40, "")
        self.assertEqual([], self.doBuild(output))

        # SEBS file is newer than output.
        self.context.timestamp = 50
        self.assertEqual([action], self.doBuild(output))
示例#5
0
  def testSimpleAction(self):
    input = Artifact("input", None)
    action = Action(self.rule, "")
    output = Artifact("output", action)
    action.command = MockCommand([input], [output])

    # output doesn't exist.
    self.dir.add("input", 20, "")
    self.assertEqual([action], self.doBuild(output))

    # output exists but is older than input.
    self.dir.add("output", 10, "")
    self.assertEqual([action], self.doBuild(output))

    # output exists and is newer than input.
    self.dir.add("output", 40, "")
    self.assertEqual([], self.doBuild(output))

    # SEBS file is newer than output.
    self.context.timestamp = 50
    self.assertEqual([action], self.doBuild(output))
示例#6
0
  def testActionWithDependency(self):
    input = Artifact("input", None)
    action1 = Action(self.rule, "")
    temp = Artifact("temp", action1)
    action1.command = MockCommand([input], [temp])
    action2 = Action(self.rule, "")
    output = Artifact("output", action2)
    action2.command = MockCommand([temp], [output])

    # outputs don't exist.
    self.dir.add("input", 20, "")
    self.assertEqual([action1, action2], self.doBuild(output))
    self.assertEqual([action1], self.doBuild(temp))

    # temp exists but is outdated.
    self.dir.add("temp", 10, "")
    self.assertEqual([action1, action2], self.doBuild(output))
    self.assertEqual([action1], self.doBuild(temp))

    # temp exists and is up-to-date.
    self.dir.add("temp", 30, "")
    self.assertEqual([action2], self.doBuild(output))
    self.assertEqual([], self.doBuild(temp))

    # output exists but is outdated.
    self.dir.add("output", 10, "")
    self.assertEqual([action2], self.doBuild(output))
    self.assertEqual([], self.doBuild(temp))

    # output exists and is up-to-date.
    self.dir.add("output", 40, "")
    self.assertEqual([], self.doBuild(output))
    self.assertEqual([], self.doBuild(temp))

    # temp is outdated but output is up-to-date.
    self.dir.add("temp", 10, "")
    self.assertEqual([action1, action2], self.doBuild(output))
    self.assertEqual([action1], self.doBuild(temp))
示例#7
0
    def testDerivedCondition(self):
        condition_dep = Artifact("cond_dep", None)

        # Note that MockRunner special-cases this action to make it copy cond_dep
        # to cond.
        condition_builder = Action(self.rule, "", "condition_builder")
        condition = Artifact("cond", condition_builder)
        condition_builder.command = MockCommand([condition_dep], [condition])

        conditional_action = Action(self.rule, "", "conditional_action")
        conditional_input = Artifact("cond_input", conditional_action)
        conditional_action.command = MockCommand([], [conditional_input])

        action = Action(self.rule, "", "action")
        output = Artifact("output", action)
        action.command = ConditionalMockCommand(condition, [],
                                                [conditional_input], [output])

        # Condition is false.
        self.dir.add("cond_dep", 20, "false")
        self.assertEqual([condition_builder, action], self.doBuild(output))

        # Condition is "true" but will become "false" when rebuilt.  This should
        # not cause conditional_action to be triggered because action should not
        # be allowed to read "cond" while it is dirty.
        self.dir.add("cond_dep", 30, "false")
        self.dir.add("cond", 20, "true")
        self.assertEqual([condition_builder, action], self.doBuild(output))

        # Condition is "false" but will become "true" when rebuilt.  This should
        # trigger conditional_action *even though* conditional_input was not listed
        # among the inputs in the first pass.
        self.dir.add("cond_dep", 30, "true")
        self.dir.add("cond", 20, "false")
        self.assertEqual([condition_builder, conditional_action, action],
                         self.doBuild(output))
示例#8
0
    def testDiamondDependency(self):
        input = Artifact("input", None)
        action1 = Action(self.rule, "")
        temp1 = Artifact("temp1", action1)
        action1.command = MockCommand([input], [temp1])
        action2 = Action(self.rule, "")
        temp2 = Artifact("temp2", action2)
        action2.command = MockCommand([input], [temp2])
        action3 = Action(self.rule, "")
        output = Artifact("output", action3)
        action3.command = MockCommand([temp1, temp2], [output])

        # outputs don't exist.
        self.dir.add("input", 20, "")
        self.assertEqual([action1, action2, action3], self.doBuild(output))
        self.assertEqual([action1], self.doBuild(temp1))
        self.assertEqual([action2], self.doBuild(temp2))

        # one side is up-to-date, other isn't.
        self.dir.add("temp1", 30, "")
        self.dir.add("output", 40, "")
        self.assertEqual([action2, action3], self.doBuild(output))
        self.assertEqual([], self.doBuild(temp1))
        self.assertEqual([action2], self.doBuild(temp2))

        # everything up-to-date.
        self.dir.add("temp2", 30, "")
        self.assertEqual([], self.doBuild(output))
        self.assertEqual([], self.doBuild(temp1))
        self.assertEqual([], self.doBuild(temp2))

        # original input too new.
        self.dir.add("input", 60, "")
        self.assertEqual([action1, action2, action3], self.doBuild(output))
        self.assertEqual([action1], self.doBuild(temp1))
        self.assertEqual([action2], self.doBuild(temp2))
示例#9
0
    def testConditionalInputs(self):
        input = Artifact("input", None)
        condition = Artifact("cond", None)
        conditional_action = Action(self.rule, "", "conditional_action")
        conditional_input = Artifact("cond_input", conditional_action)
        conditional_action.command = MockCommand([], [conditional_input])
        action = Action(self.rule, "", "action")
        output = Artifact("output", action)
        action.command = ConditionalMockCommand(condition, [input],
                                                [conditional_input], [output])

        # output doesn't exist, condition is false.
        self.dir.add("cond", 20, "false")
        self.dir.add("input", 20, "")
        self.assertEqual([action], self.doBuild(output))

        # output exists, condition still false.
        self.dir.add("output", 30, "")
        self.assertEqual([], self.doBuild(output))

        # condition newer than output.
        self.dir.add("cond", 40, "")
        self.assertEqual([action], self.doBuild(output))
        self.dir.add("cond", 20, "")

        # input newer than output.
        self.dir.add("input", 40, "")
        self.assertEqual([action], self.doBuild(output))
        self.dir.add("input", 20, "")

        # condition is true, cond_input doesn't exist.
        self.dir.add("cond", 20, "true")
        self.assertEqual([conditional_action, action], self.doBuild(output))

        # cond_input newer than output -- doesn't matter since cond is false.
        self.dir.add("cond_input", 40, "")
        self.dir.add("cond", 20, "false")
        self.assertEqual([], self.doBuild(output))

        # condition is true, cond_input is newer than output.
        self.dir.add("cond", 20, "true")
        self.assertEqual([action], self.doBuild(output))

        # output newer than cond_input.
        self.dir.add("cond_input", 20, "")
        self.assertEqual([], self.doBuild(output))
示例#10
0
    def testActionWithDependency(self):
        input = Artifact("input", None)
        action1 = Action(self.rule, "")
        temp = Artifact("temp", action1)
        action1.command = MockCommand([input], [temp])
        action2 = Action(self.rule, "")
        output = Artifact("output", action2)
        action2.command = MockCommand([temp], [output])

        # outputs don't exist.
        self.dir.add("input", 20, "")
        self.assertEqual([action1, action2], self.doBuild(output))
        self.assertEqual([action1], self.doBuild(temp))

        # temp exists but is outdated.
        self.dir.add("temp", 10, "")
        self.assertEqual([action1, action2], self.doBuild(output))
        self.assertEqual([action1], self.doBuild(temp))

        # temp exists and is up-to-date.
        self.dir.add("temp", 30, "")
        self.assertEqual([action2], self.doBuild(output))
        self.assertEqual([], self.doBuild(temp))

        # output exists but is outdated.
        self.dir.add("output", 10, "")
        self.assertEqual([action2], self.doBuild(output))
        self.assertEqual([], self.doBuild(temp))

        # output exists and is up-to-date.
        self.dir.add("output", 40, "")
        self.assertEqual([], self.doBuild(output))
        self.assertEqual([], self.doBuild(temp))

        # temp is outdated but output is up-to-date.
        self.dir.add("temp", 10, "")
        self.assertEqual([action1, action2], self.doBuild(output))
        self.assertEqual([action1], self.doBuild(temp))
示例#11
0
  def testDerivedCondition(self):
    condition_dep = Artifact("cond_dep", None)

    # Note that MockRunner special-cases this action to make it copy cond_dep
    # to cond.
    condition_builder = Action(self.rule, "", "condition_builder")
    condition = Artifact("cond", condition_builder)
    condition_builder.command = MockCommand([condition_dep], [condition])

    conditional_action = Action(self.rule, "", "conditional_action")
    conditional_input = Artifact("cond_input", conditional_action)
    conditional_action.command = MockCommand([], [conditional_input])

    action = Action(self.rule, "", "action")
    output = Artifact("output", action)
    action.command = ConditionalMockCommand(
        condition, [], [conditional_input], [output])

    # Condition is false.
    self.dir.add("cond_dep", 20, "false")
    self.assertEqual([condition_builder, action], self.doBuild(output))

    # Condition is "true" but will become "false" when rebuilt.  This should
    # not cause conditional_action to be triggered because action should not
    # be allowed to read "cond" while it is dirty.
    self.dir.add("cond_dep", 30, "false")
    self.dir.add("cond", 20, "true")
    self.assertEqual([condition_builder, action], self.doBuild(output))

    # Condition is "false" but will become "true" when rebuilt.  This should
    # trigger conditional_action *even though* conditional_input was not listed
    # among the inputs in the first pass.
    self.dir.add("cond_dep", 30, "true")
    self.dir.add("cond", 20, "false")
    self.assertEqual([condition_builder, conditional_action, action],
                     self.doBuild(output))
示例#12
0
  def testDiamondDependency(self):
    input = Artifact("input", None)
    action1 = Action(self.rule, "")
    temp1 = Artifact("temp1", action1)
    action1.command = MockCommand([input], [temp1])
    action2 = Action(self.rule, "")
    temp2 = Artifact("temp2", action2)
    action2.command = MockCommand([input], [temp2])
    action3 = Action(self.rule, "")
    output = Artifact("output", action3)
    action3.command = MockCommand([temp1, temp2], [output])

    # outputs don't exist.
    self.dir.add("input", 20, "")
    self.assertEqual([action1, action2, action3], self.doBuild(output))
    self.assertEqual([action1], self.doBuild(temp1))
    self.assertEqual([action2], self.doBuild(temp2))

    # one side is up-to-date, other isn't.
    self.dir.add("temp1", 30, "")
    self.dir.add("output", 40, "")
    self.assertEqual([action2, action3], self.doBuild(output))
    self.assertEqual([], self.doBuild(temp1))
    self.assertEqual([action2], self.doBuild(temp2))

    # everything up-to-date.
    self.dir.add("temp2", 30, "")
    self.assertEqual([], self.doBuild(output))
    self.assertEqual([], self.doBuild(temp1))
    self.assertEqual([], self.doBuild(temp2))

    # original input too new.
    self.dir.add("input", 60, "")
    self.assertEqual([action1, action2, action3], self.doBuild(output))
    self.assertEqual([action1], self.doBuild(temp1))
    self.assertEqual([action2], self.doBuild(temp2))
示例#13
0
 def action(self, *vargs, **kwargs):
     return Action(*vargs, **kwargs)
示例#14
0
 def setUp(self):
     self.__action = Action(None, "dummy", "dummy")
     self.__artifact = Artifact("filename", None)
     self.__dir = VirtualDirectory()