Exemplo n.º 1
0
    def test_clean_stage_state_common_files(self):
        self.assertRaises(errors.NoLatestStepError, self.handler.latest_step)
        bindir = os.path.join(self.stage_dir, "bin")
        os.makedirs(bindir)
        open(os.path.join(bindir, "1"), "w").close()
        open(os.path.join(bindir, "2"), "w").close()

        self.handler.mark_done(steps.BUILD)

        self.handler.mark_done(steps.STAGE,
                               states.StageState({"bin/1", "bin/2"}, {"bin"}))

        self.handler.clean_stage(
            {"other_part": states.StageState({"bin/2"}, {"bin"})})

        self.assertThat(self.handler.latest_step(), Equals(steps.BUILD))
        self.assertThat(self.handler.next_step(), Equals(steps.STAGE))
        self.assertFalse(os.path.exists(os.path.join(bindir, "1")))
        self.assertTrue(
            os.path.exists(os.path.join(bindir, "2")),
            "Expected 'bin/2' to remain as it's required by other parts",
        )
Exemplo n.º 2
0
    def test_clean_stage_state(self):
        self.assertRaises(errors.NoLatestStepError, self.handler.latest_step)
        self.assertThat(self.handler.next_step(), Equals(steps.PULL))
        bindir = os.path.join(self.stage_dir, "bin")
        os.makedirs(bindir)
        open(os.path.join(bindir, "1"), "w").close()
        open(os.path.join(bindir, "2"), "w").close()

        self.handler.mark_done(steps.BUILD)

        self.handler.mark_done(steps.STAGE,
                               states.StageState({"bin/1", "bin/2"}, {"bin"}))

        self.handler.clean_stage({})

        self.assertThat(self.handler.latest_step(), Equals(steps.BUILD))
        self.assertThat(self.handler.next_step(), Equals(steps.STAGE))
        self.assertFalse(os.path.exists(bindir))
Exemplo n.º 3
0
    def test_clean_stage_state_multiple_parts(self):
        self.assertRaises(errors.NoLatestStepError, self.handler.latest_step)
        bindir = os.path.join(self.stage_dir, "bin")
        os.makedirs(bindir)
        open(os.path.join(bindir, "1"), "w").close()
        open(os.path.join(bindir, "2"), "w").close()
        open(os.path.join(bindir, "3"), "w").close()

        self.handler.mark_done(steps.BUILD)

        self.handler.mark_done(steps.STAGE,
                               states.StageState({"bin/1", "bin/2"}, {"bin"}))

        self.handler.clean_stage({})

        self.assertThat(self.handler.latest_step(), Equals(steps.BUILD))
        self.assertThat(self.handler.next_step(), Equals(steps.STAGE))
        self.assertFalse(os.path.exists(os.path.join(bindir, "1")))
        self.assertFalse(os.path.exists(os.path.join(bindir, "2")))
        self.assertTrue(
            os.path.exists(os.path.join(bindir, "3")),
            "Expected 'bin/3' to remain as it wasn't staged by this part",
        )
Exemplo n.º 4
0
def stage_state():
    """Return a StageState."""
    project, files, directories, part_properties = _STAGE_DEFAULT

    return states.StageState(files, directories, part_properties, project)
Exemplo n.º 5
0
def stage_state_variant(request):
    """Return variants of stage_state."""
    project, files, directories, part_properties = request.param

    return states.StageState(files, directories, part_properties, project)