mesh-build-go: tests that a workspace is left with only its tree leave out the ask's own cache layer and slots, every such test at once (issue 1921, try speed S2, S10)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -345,14 +346,7 @@ func TestAStoreThatDoesNotStartEndsTheStepFailedAndLeavesNothing(t *testing.T) {
|
||||
if f.busDir != "" && !f.busDown {
|
||||
t.Errorf("the bus, started beside the store, was not stopped after the store failed")
|
||||
}
|
||||
var left []string
|
||||
entries, _ := os.ReadDir(filepath.Join(m.Work, "ws1"))
|
||||
for _, e := range entries {
|
||||
if e.Name() != "slots" { // the ask's bound on processes, gone with the workspace (issue 1921, S10)
|
||||
left = append(left, e.Name())
|
||||
}
|
||||
}
|
||||
if len(left) != 1 || left[0] != "tree" {
|
||||
if left := workspaceLeft(filepath.Join(m.Work, "ws1")); len(left) != 1 || left[0] != "tree" {
|
||||
t.Errorf("the workspace holds %v, want only its tree", left)
|
||||
}
|
||||
}
|
||||
@@ -534,3 +528,16 @@ func TestTheIntegrationLevelRunsOnlyTheTestsItsTagsAdd(t *testing.T) {
|
||||
t.Errorf("a tree with no tagged test started the store or ran go:\n%s", g.lines())
|
||||
}
|
||||
}
|
||||
|
||||
// workspaceLeft is what a workspace holds besides the directories its ask keeps there (askDirs: its cache layer and its
|
||||
// bound on processes, gone with the workspace; issue 1921, S2 and S10).
|
||||
func workspaceLeft(dir string) []string {
|
||||
var left []string
|
||||
entries, _ := os.ReadDir(dir)
|
||||
for _, e := range entries {
|
||||
if !slices.Contains(askDirs, e.Name()) {
|
||||
left = append(left, e.Name())
|
||||
}
|
||||
}
|
||||
return left
|
||||
}
|
||||
|
||||
@@ -16,6 +16,13 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// slotsDir is the directory in a workspace's root holding its slots.
|
||||
const slotsDir = "slots"
|
||||
|
||||
// askDirs are the directories an ask keeps in its workspace's root beside its tree, gone with the workspace: its cache
|
||||
// layer and its bound on processes.
|
||||
var askDirs = []string{cacheLayerDir, slotsDir}
|
||||
|
||||
// numCPU is the node's processor count.
|
||||
func numCPU() int { return runtime.NumCPU() }
|
||||
|
||||
@@ -31,7 +38,7 @@ var slotTurns atomic.Uint32
|
||||
|
||||
// slots is the bound of the workspace's processes, m.parallel() slots.
|
||||
func (m *Module) slots(workspace string) slotPool {
|
||||
return slotPool{dir: filepath.Join(m.Work, workspace, "slots"), n: m.parallel(), next: &slotTurns}
|
||||
return slotPool{dir: filepath.Join(m.Work, workspace, slotsDir), n: m.parallel(), next: &slotTurns}
|
||||
}
|
||||
|
||||
// acquire takes a slot of the pool, waiting for one when every slot is taken, and answers what frees it. A free slot is
|
||||
|
||||
@@ -161,9 +161,8 @@ func TestIntegrationLevelRunsAgainstARealStoreAndBusAndLeavesNothing(t *testing.
|
||||
if !res.Passed || res.Tests != 1 || res.Setup <= 0 || res.Setup > IntegrationSetup.Seconds() {
|
||||
t.Errorf("result = %+v", res)
|
||||
}
|
||||
entries, _ := os.ReadDir(filepath.Join(work, "ws1"))
|
||||
if len(entries) != 1 || entries[0].Name() != "tree" {
|
||||
t.Errorf("the workspace holds %v, want only its tree: the run directory is gone", entries)
|
||||
if left := workspaceLeft(filepath.Join(work, "ws1")); len(left) != 1 || left[0] != "tree" {
|
||||
t.Errorf("the workspace holds %v besides the ask's own directories, want only its tree: the run directory is gone", left)
|
||||
}
|
||||
for deadline := time.Now().Add(5 * time.Second); len(processesNamed(work)) > 0 && time.Now().Before(deadline); time.Sleep(100 * time.Millisecond) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user