Skip to content

Commit

Permalink
rpm: Fix use of inccorrect field for runtime constraints
Browse files Browse the repository at this point in the history
When building the rpm spec we were using the wrong set of constraints
for runtime dependencies.
This was likely just a bad copy/paste.

Added tests for this.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Jun 18, 2024
1 parent b417234 commit 4ec16e0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/rpm/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (w *specWrapper) Requires() fmt.Stringer {

runtimeKeys := dalec.SortMapKeys(deps.Runtime)
for _, name := range runtimeKeys {
constraints := deps.Build[name]
constraints := deps.Runtime[name]
// satisifes is only for build deps, not runtime deps
// TODO: consider if it makes sense to support sources satisfying runtime deps
writeDep(b, "Requires", name, constraints)
Expand Down
48 changes: 48 additions & 0 deletions frontend/rpm/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,51 @@ func TestTemplate_Artifacts(t *testing.T) {
assert.Equal(t, want, got)
})
}

func TestTemplate_Requires(t *testing.T) {
t.Parallel()

spec := &dalec.Spec{
Dependencies: &dalec.PackageDependencies{
// note: I've prefixed these packages with a/b/c for sorting purposes
// Since the underlying code will sort packages this just makes it
// simpler to read for tests.
Build: map[string][]string{
"a-lib-no-constraints": {},
"b-lib-one-constraints": {
"< 2.0",
},
"c-lib-multiple-constraints": {
"< 2.0",
">= 1.0",
},
},
Runtime: map[string][]string{
"a-no-constraints": {},
"b-one-constraints": {
"< 2.0",
},
"c-multiple-constraints": {
"< 2.0",
">= 1.0",
},
},
},
}

w := &specWrapper{Spec: spec}

got := w.Requires().String()
want := `BuildRequires: a-lib-no-constraints
BuildRequires: b-lib-one-constraints < 2.0
BuildRequires: c-lib-multiple-constraints < 2.0
BuildRequires: c-lib-multiple-constraints >= 1.0
Requires: a-no-constraints
Requires: b-one-constraints < 2.0
Requires: c-multiple-constraints < 2.0
Requires: c-multiple-constraints >= 1.0
`

assert.Equal(t, want, got)
}

0 comments on commit 4ec16e0

Please sign in to comment.