mesh-build-node-narrowed-packages: a package narrowed out of a step's workspace is no module of it
A step of one TypeScript package of a module with several (mesh-contracts' root: ts-meshbroker beside ts-meshrecovery, pipeline main.3 of 2026-11-20) fetches a workspace narrowed to that package's path. The fetch and the lint and test levels read every package artifact of the manifest, and one whose path the narrowing left out fell back to the module's directory, which holds no lock: every TypeScript step of mesh-contracts ended "could not run: the package in . has no package-lock.json". Such a package is now left out of the fetch's install and of the levels' targets; an unnarrowed tree is read as before. Builds: design 47 H H-A-136 (a step's workspace holds the artifact's paths; nothing else is fetched), ADR 0499 clause 4
This commit is contained in:
@@ -91,3 +91,54 @@ func TestAFolderModulesPackageIsBuiltAndTestedInItsPath(t *testing.T) {
|
||||
t.Errorf("unit level = %+v, ran tests in %v, want both package paths", r, tests)
|
||||
}
|
||||
}
|
||||
|
||||
// A step of one package of a root module with several (mesh-contracts' ts-meshbroker beside ts-meshrecovery, pipeline
|
||||
// main.3 of 2026-11-20) fetches a workspace narrowed to that package's path (ADR 0499 clause 4; design 47 H, H-A-136:
|
||||
// nothing else is fetched). The other packages' paths are not in it: they are no module of this build, never the
|
||||
// module's directory, which holds no lock ("the package in . has no package-lock.json").
|
||||
func TestANarrowedFetchOfOneFolderPackageLeavesTheOthersOut(t *testing.T) {
|
||||
m, f := fetchMachine(t, folderFiles(""), nil)
|
||||
args := map[string]any{"repository": "novox/mesh-contracts", "commit": commitSHA, "dir": ".", "paths": []any{"ts/seats/a"}}
|
||||
out, err := m.fetch(context.Background(), args)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := out.(FetchResult)
|
||||
if strings.Join(r.Modules, ",") != "ts/seats/a" || strings.Join(r.Installed, ",") != "ts/seats/a" {
|
||||
t.Errorf("modules %v, installed %v; want only the named package ts/seats/a", r.Modules, r.Installed)
|
||||
}
|
||||
if n := len(npmCalls(f)); n != 1 {
|
||||
t.Errorf("%d npm commands, want the one install of the named package", n)
|
||||
}
|
||||
}
|
||||
|
||||
// The lint and test levels of that narrowed workspace run in the named package's path alone: a package whose path was
|
||||
// left out is no target, and the module's directory is not tested whole in its place (H-A-136).
|
||||
func TestANarrowedWorkspaceTestsOnlyItsPackage(t *testing.T) {
|
||||
work := t.TempDir()
|
||||
files := folderFiles("")
|
||||
for p := range files {
|
||||
if strings.HasPrefix(p, "ts/seats/b/") {
|
||||
delete(files, p)
|
||||
}
|
||||
}
|
||||
for p, body := range files {
|
||||
write(t, filepath.Join(work, filepath.FromSlash(p)), body, 0o644)
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
narrowed bool
|
||||
want string
|
||||
}{{true, "ts/seats/a"}, {false, "."}} {
|
||||
got, err := testTargets(work, ".", tc.narrowed)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var where []string
|
||||
for _, g := range got {
|
||||
where = append(where, g.where)
|
||||
}
|
||||
if strings.Join(where, ",") != tc.want {
|
||||
t.Errorf("narrowed %v: targets %v, want %s", tc.narrowed, where, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user