cmd: share package builds across test directories
This commit is contained in:
@@ -106,8 +106,8 @@ fn pkgusage() void = {
|
||||
let s: str = strings.concat(
|
||||
"usage: wwtest package [-c] [-list] [-j N] [-I DIR] [-w DIR] [-run|-filter GLOB] [-timeout-ms=N] [DIR | DIR/...] [-- GLOB ...]\n",
|
||||
" *_test.ww is the sole test-source form; @test elsewhere is rejected\n",
|
||||
" -c retains the compiled package binaries; -j N runs up to N directory builds or test binaries at once\n",
|
||||
" -w DIR keys a persistent shared build workdir per package directory\n");
|
||||
" -c retains the compiled package binaries; -j N runs up to N build or test processes at once\n",
|
||||
" -w DIR keys one persistent shared build workdir for the test request\n");
|
||||
pkgput(os.STDERR_FILENO, s);
|
||||
};
|
||||
|
||||
@@ -530,8 +530,8 @@ fn pkgsetplanpaths(p: *pkgplan, groups: []pkggroup, root: str, index: i32,
|
||||
if (!pkgmakedir(p.root)) { return false; };
|
||||
p.workdir = "";
|
||||
if (workroot.len != 0) {
|
||||
// The first byte-sorted product name is stable metadata in the
|
||||
// injective directory key; every product in this plan shares the dir.
|
||||
// The request root and first byte-sorted product name make one stable
|
||||
// escaped key for the command-scoped driver workdir.
|
||||
p.workdir = strings.concat(workroot, "/",
|
||||
pkgworkkey(p.dir, groups[p.start].pkg));
|
||||
match (os.mkdirs(p.workdir, 448)) {
|
||||
@@ -600,7 +600,7 @@ fn pkgreportcommand(kind: str, g: *pkggroup, r: *exec.result) void = {
|
||||
fn pkgstartbuild(p: *pkgplan, groups: []pkggroup, builder: str, includes: []str,
|
||||
h: *exec.process) void = {
|
||||
let ba: []str = alloc([],
|
||||
(8 + (p.end - p.start) * 5 + includes.len * 2): u64)!;
|
||||
(8 + (p.end - p.start) * 6 + includes.len * 2): u64)!;
|
||||
append(ba, builder);
|
||||
append(ba, "test");
|
||||
append(ba, "-c");
|
||||
@@ -611,6 +611,7 @@ fn pkgstartbuild(p: *pkgplan, groups: []pkggroup, builder: str, includes: []str,
|
||||
if (g.external) { append(ba, "external"); }
|
||||
else { append(ba, "same"); };
|
||||
append(ba, g.pkg);
|
||||
append(ba, g.dir);
|
||||
append(ba, g.bin);
|
||||
append(ba, g.buildok);
|
||||
i += 1;
|
||||
@@ -976,20 +977,13 @@ export fn packagecommand(args: []str) int = {
|
||||
"wwtest package: cannot use -o with multiple packages");
|
||||
return 2;
|
||||
};
|
||||
let plans: []pkgplan = alloc([], groups.len: u64)!;
|
||||
i = 0;
|
||||
for (i < groups.len) {
|
||||
let p: pkgplan;
|
||||
p.dir = groups[i].dir;
|
||||
p.start = i;
|
||||
for (i < groups.len
|
||||
&& strings.compare(groups[i].dir, p.dir) == 0) {
|
||||
i += 1;
|
||||
};
|
||||
p.end = i;
|
||||
p.state = PKGQUEUED;
|
||||
append(plans, p);
|
||||
};
|
||||
let plans: []pkgplan = alloc([], 1u64)!;
|
||||
let plan: pkgplan;
|
||||
plan.dir = discoverroot;
|
||||
plan.start = 0;
|
||||
plan.end = groups.len;
|
||||
plan.state = PKGQUEUED;
|
||||
append(plans, plan);
|
||||
|
||||
let borrowed: str = temp.dir();
|
||||
let tmproot: str = strings.dup(borrowed);
|
||||
@@ -1009,9 +1003,9 @@ export fn packagecommand(args: []str) int = {
|
||||
i += 1;
|
||||
};
|
||||
|
||||
// Build one shared package plan per directory. As soon as a plan completes,
|
||||
// its successful products may run under the same global -j bound while
|
||||
// other directory builds remain active. Emission stays ordered below.
|
||||
// Build the complete request in one command-owned package universe. Once
|
||||
// the union build completes, successful products run under the same global
|
||||
// -j bound. Emission stays in byte-sorted group order below.
|
||||
let handles: []exec.process = alloc([], plans.len: u64)!;
|
||||
i = 0;
|
||||
for (i < plans.len) {
|
||||
|
||||
Reference in New Issue
Block a user