예제 #1
0
    def test_build_flags(self):
        class Options:
            source = "dir"
            crystal_channel = "latest/stable"
            crystal_build_options = ["-Dpreview_mt"]

        plugin = crystal.CrystalPlugin("test-part", Options(), self.project)

        # fake binaries being built
        self.useFixture(
            fixtures.MockPatch("snapcraft.internal.elf.ElfFile",
                               side_effect=MockElfFile))
        binaries = ["foo", "bar"]
        bin_dir = os.path.join(plugin.builddir, "bin")
        os.makedirs(bin_dir)
        for b in binaries:
            open(os.path.join(bin_dir, b), "w").close()

        plugin.build()

        self.fake_run.mock.assert_has_calls([
            mock.call(["shards", "install", "--production"],
                      cwd=plugin.builddir),
            mock.call(
                ["shards", "build", "--production", "-Dpreview_mt"],
                cwd=plugin.builddir,
            ),
        ])
        self.assertThat(self.fake_run.mock.call_count, Equals(2))
        for b in binaries:
            self.assertThat(os.path.join(plugin.installdir, "bin", b),
                            FileExists())
예제 #2
0
    def test_build_no_targets(self):
        class Options:
            source = "dir"
            crystal_channel = "latest/stable"
            crystal_build_options = []

        plugin = crystal.CrystalPlugin("test-part", Options(), self.project)

        self.assertRaises(errors.SnapcraftEnvironmentError, plugin.build)
예제 #3
0
    def test_pull(self):
        class Options:
            source = "dir"
            crystal_channel = "latest/stable"
            crystal_build_options = []

        plugin = crystal.CrystalPlugin("test-part", Options(), self.project)

        plugin.pull()

        self.fake_run.mock.assert_not_called()