Skip to content

Commit

Permalink
Gate test hierarchy based on whether we support locking at all
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Dec 18, 2023
1 parent dc73678 commit 3caea2a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 33 deletions.
2 changes: 1 addition & 1 deletion test-suite/Add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func doAdd(bt testUtils.BackendT, pkgs ...string) {
for _, tmpl := range standardTemplates {
template := bt.Backend.Name + "/" + tmpl + "/"
bt.Subtest(tmpl, func(bt testUtils.BackendT) {
if tmpl != "no-deps" {
if tmpl != "no-deps" && bt.Backend.QuirksIsReproducible() {
bt.Subtest("locked", func(bt testUtils.BackendT) {
bt.Subtest("each", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
Expand Down
4 changes: 3 additions & 1 deletion test-suite/Install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func doInstall(bt testUtils.BackendT) {
template := bt.Backend.Name + "/" + tmpl + "/"
bt.Subtest(tmpl, func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
if bt.Backend.QuirksIsReproducible() {
bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
}

bt.UpmInstall()

Expand Down
30 changes: 18 additions & 12 deletions test-suite/List_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package testSuite
import (
"testing"

"github.com/replit/upm/internal/api"
testUtils "github.com/replit/upm/test-suite/utils"
)

Expand Down Expand Up @@ -62,7 +63,7 @@ func doList(bt testUtils.BackendT, templatesToPackages map[string][]string) {

bt.Subtest(tmpl, func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
if tmpl != "no-deps" {
if tmpl != "no-deps" && bt.Backend.QuirksIsReproducible() {
bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
}

Expand All @@ -71,9 +72,12 @@ func doList(bt testUtils.BackendT, templatesToPackages map[string][]string) {
bt.Fail("Expected %v packages, got %v", len(expectPkgs), len(specs))
}

locks := bt.UpmListLockFile()
if len(locks) < len(expectPkgs) {
bt.Fail("Expected %v packages, got %v", len(expectPkgs), len(locks))
var locks []api.PkgInfo
if bt.Backend.QuirksIsReproducible() {
locks = bt.UpmListLockFile()
if len(locks) < len(expectPkgs) {
bt.Fail("Expected %v packages, got %v", len(expectPkgs), len(locks))
}
}

for _, pkg := range expectPkgs {
Expand All @@ -89,16 +93,18 @@ func doList(bt testUtils.BackendT, templatesToPackages map[string][]string) {
bt.Fail("package %v not found in spec list", pkg)
}

found = false
for _, lock := range locks {
if pkg == lock.Name {
found = true
break
if bt.Backend.QuirksIsReproducible() {
found = false
for _, lock := range locks {
if pkg == lock.Name {
found = true
break
}
}
}

if !found {
bt.Fail("package %v not found in lock list", pkg)
if !found {
bt.Fail("package %v not found in lock list", pkg)
}
}
}
})
Expand Down
24 changes: 13 additions & 11 deletions test-suite/Remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,22 @@ func doRemove(bt testUtils.BackendT, templatesToPkgsToRemove map[string][]string

if tmpl != "no-deps" {
bt.Subtest(tmpl, func(bt testUtils.BackendT) {
bt.Subtest("locked", func(bt testUtils.BackendT) {
bt.Subtest("each", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
bt.Subtest("each", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
if bt.Backend.QuirksIsReproducible() {
bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
for _, pkg := range pkgsToRemove {
bt.UpmRemove(pkg)
}
})
}
for _, pkg := range pkgsToRemove {
bt.UpmRemove(pkg)
}
})

bt.Subtest("all", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
bt.Subtest("all", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
if bt.Backend.QuirksIsReproducible() {
bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
bt.UpmRemove(pkgsToRemove...)
})
}
bt.UpmRemove(pkgsToRemove...)
})
})
}
Expand Down
17 changes: 12 additions & 5 deletions test-suite/WhichLanguage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ func TestWhichLanguage(t *testing.T) {
template := bt.Backend.Name + "/one-dep/"

bt.Subtest(bt.Backend.Name, func(bt testUtils.BackendT) {
bt.Subtest("locked", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
bt.UpmWhichLanguage()
})
if bt.Backend.QuirksIsReproducible() {
bt.Subtest("locked", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
bt.UpmWhichLanguage()
})
} else {
bt.Subtest("no lockfile", func(bt testUtils.BackendT) {
bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
bt.UpmWhichLanguage()
})
}

if defaults[bt.Backend.Name] {
bt.Subtest("default", func(bt testUtils.BackendT) {
Expand Down
8 changes: 5 additions & 3 deletions test-suite/utils/upm.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ func (bt *BackendT) UpmRemove(pkgs ...string) {
}

for _, pkg := range pkgs {
for _, dep := range afterLockDeps {
if dep.Name == pkg {
bt.Fail("expected %s not in lock file after remove", pkg)
if bt.Backend.QuirksIsReproducible() {
for _, dep := range afterLockDeps {
if dep.Name == pkg {
bt.Fail("expected %s not in lock file after remove", pkg)
}
}
}

Expand Down

0 comments on commit 3caea2a

Please sign in to comment.