mirror of
https://github.com/mudler/luet.git
synced 2025-09-05 09:10:43 +00:00
Add test for compilation with version selection
This commit is contained in:
@@ -392,4 +392,48 @@ var _ = Describe("Compiler", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Context("Simple package build definition", func() {
|
||||||
|
It("Compiles it in parallel", func() {
|
||||||
|
generalRecipe := tree.NewCompilerRecipe(pkg.NewInMemoryDatabase(false))
|
||||||
|
|
||||||
|
err := generalRecipe.Load("../../tests/fixtures/expansion")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(generalRecipe.Tree()).ToNot(BeNil()) // It should be populated back at this point
|
||||||
|
|
||||||
|
Expect(len(generalRecipe.Tree().GetPackageSet().GetPackages())).To(Equal(3))
|
||||||
|
|
||||||
|
compiler := NewLuetCompiler(sd.NewSimpleDockerBackend(), generalRecipe.Tree(), generalRecipe.Tree().GetPackageSet())
|
||||||
|
err = compiler.Prepare(1)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
spec, err := compiler.FromPackage(&pkg.DefaultPackage{Name: "c", Category: "test", Version: "1.0"})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
Expect(spec.GetPackage().GetPath()).ToNot(Equal(""))
|
||||||
|
|
||||||
|
tmpdir, err := ioutil.TempDir("", "tree")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer os.RemoveAll(tmpdir) // clean up
|
||||||
|
|
||||||
|
spec.SetOutputPath(tmpdir)
|
||||||
|
artifacts, errs := compiler.CompileParallel(2, false, NewLuetCompilationspecs(spec))
|
||||||
|
Expect(errs).To(BeNil())
|
||||||
|
for _, artifact := range artifacts {
|
||||||
|
Expect(helpers.Exists(artifact.GetPath())).To(BeTrue())
|
||||||
|
Expect(helpers.Untar(artifact.GetPath(), tmpdir, false)).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
for _, d := range artifact.GetDependencies() {
|
||||||
|
Expect(helpers.Exists(d.GetPath())).To(BeTrue())
|
||||||
|
Expect(helpers.Untar(d.GetPath(), tmpdir, false)).ToNot(HaveOccurred())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Expect(helpers.Exists(spec.Rel("test3"))).To(BeTrue())
|
||||||
|
Expect(helpers.Exists(spec.Rel("test4"))).To(BeTrue())
|
||||||
|
Expect(helpers.Exists(spec.Rel("test5"))).To(BeTrue())
|
||||||
|
Expect(helpers.Exists(spec.Rel("test6"))).To(BeTrue())
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@@ -128,6 +128,7 @@ func (gb *DefaultTree) updatePackage(p pkg.Package) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("Simpleparser should deal only with DefaultPackages")
|
return errors.New("Simpleparser should deal only with DefaultPackages")
|
||||||
}
|
}
|
||||||
|
Info(":ok_hand: Automatically selected", found.GetName(), found.GetVersion())
|
||||||
p.GetRequires()[i] = found
|
p.GetRequires()[i] = found
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
tests/fixtures/expansion/c/build.yaml
vendored
Normal file
10
tests/fixtures/expansion/c/build.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo c > /c
|
||||||
|
- echo c > /cd
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: ">=1.0"
|
3
tests/fixtures/expansion/c/definition.yaml
vendored
Normal file
3
tests/fixtures/expansion/c/definition.yaml
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "c"
|
||||||
|
version: "1.0"
|
9
tests/fixtures/expansion/cat/b/build.yaml
vendored
Normal file
9
tests/fixtures/expansion/cat/b/build.yaml
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
- chmod +x generate.sh
|
||||||
|
steps:
|
||||||
|
- echo artifact5 > /test5
|
||||||
|
- echo artifact6 > /test6
|
||||||
|
- ./generate.sh
|
3
tests/fixtures/expansion/cat/b/definition.yaml
vendored
Normal file
3
tests/fixtures/expansion/cat/b/definition.yaml
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: "1.0"
|
1
tests/fixtures/expansion/cat/b/generate.sh
vendored
Normal file
1
tests/fixtures/expansion/cat/b/generate.sh
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
echo generated > /artifact42
|
11
tests/fixtures/expansion/cat/cat2/a/build.yaml
vendored
Normal file
11
tests/fixtures/expansion/cat/cat2/a/build.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo artifact3 > /test3
|
||||||
|
- echo artifact4 > /test4
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: "1.0"
|
8
tests/fixtures/expansion/cat/cat2/a/definition.yaml
vendored
Normal file
8
tests/fixtures/expansion/cat/cat2/a/definition.yaml
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: "1.1"
|
||||||
|
requires:
|
||||||
|
- category: "test2"
|
||||||
|
name: "b"
|
||||||
|
version: "1.0"
|
||||||
|
|
Reference in New Issue
Block a user