Merge branch 'fix/447-builder-names-dir' into prep/delivery
This commit is contained in:
@@ -374,7 +374,7 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string,
|
||||
if s.Digest == nil {
|
||||
// A module with no digest (Node) tests each module directory of the tree, those whose tests changed first.
|
||||
for _, priority := range []bool{true, false} {
|
||||
for _, dir := range f.Modules {
|
||||
for _, dir := range modulesOf(f.Modules, job.Fetch.Dir) {
|
||||
if changesTestIn(f.Changed, dir) != priority {
|
||||
continue
|
||||
}
|
||||
@@ -424,6 +424,23 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string,
|
||||
return all, nil
|
||||
}
|
||||
|
||||
// modulesOf are the module directories a fetch answered that a step for the module in dir tests: that directory's and
|
||||
// those under it, never another module's of the repository (design 47 G, A-447c); all of them when the ask names no
|
||||
// directory, or the root.
|
||||
func modulesOf(modules []string, dir string) []string {
|
||||
dir = strings.Trim(path.Clean(dir), "/")
|
||||
if dir == "" || dir == "." {
|
||||
return modules
|
||||
}
|
||||
var out []string
|
||||
for _, m := range modules {
|
||||
if m == dir || strings.HasPrefix(m, dir+"/") {
|
||||
out = append(out, m)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// release removes an ask's workspace, saying a failure: the module's sweep removes it later.
|
||||
func (s AskSteps) release(workspace string) {
|
||||
if workspace == "" || s.Release == nil {
|
||||
|
||||
@@ -296,6 +296,16 @@ func TestRunAskChecksNodeModulesAndConflicts(t *testing.T) {
|
||||
if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"a","workspace":"/w"}]` {
|
||||
t.Fatalf("calls %v", r.calls)
|
||||
}
|
||||
// A check asked for the module in a directory tests that directory's modules alone (A-447c).
|
||||
r = &recorder{fetch: map[string]any{"workspace": "/w", "modules": []string{"a", "b", "b/c"}}, tests: map[string]bool{"b": true, "b/c": true}}
|
||||
s = r.steps()
|
||||
s.Digest = nil
|
||||
if _, err := RunAsk(context.Background(), s, ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit, Dir: "b"}})); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"b/c","workspace":"/w"}]` {
|
||||
t.Fatalf("a check for the module b: calls %v", r.calls)
|
||||
}
|
||||
r = &recorder{fetch: map[string]any{"workspace": "/w", "conflicts": []string{"go.mod"}}}
|
||||
out, err := RunAsk(context.Background(), r.steps(), ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit}}))
|
||||
if err != nil || len(r.calls) != 1 || len(out.(sdkstep.CheckAnswer).Levels) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user