~sircmpwn/hare-dev

hare: hare/build: Print arguments of failed command v2 REJECTED

Haelwenn (lanodan) Monnier: 1
 hare/build: Print arguments of failed command

 2 files changed, 11 insertions(+), 3 deletions(-)
#1067206 alpine.yml success
#1067207 freebsd.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/45296/mbox | git am -3
Learn more about email & git

[PATCH hare v2] hare/build: Print arguments of failed command Export this patch

From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>

---
 cmd/hare/build/queue.ha | 13 ++++++++++---
 cmd/hare/build/types.ha |  1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/cmd/hare/build/queue.ha b/cmd/hare/build/queue.ha
index 973f9350..82731164 100644
--- a/cmd/hare/build/queue.ha
+++ b/cmd/hare/build/queue.ha
@@ -125,7 +125,6 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
	io::trunc(lock, 0)?;

	let args = get_args(ctx, tmp, flags, t);
	defer strings::freeall(args);

	path::set(&buf, out)?;
	write_args(ctx, path::push_ext(&buf, "txt")?, args, t)?;
@@ -179,6 +178,7 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
		pid = exec::start(&cmd)?,
		task = t,
		lock = lock,
		args = args,
	});
	return true;
};
@@ -199,6 +199,7 @@ fn await_task(ctx: *context, jobs: *[]job) (size | void | error) = {
	assert(i < len(jobs), "Unknown PID returned from waitany");
	let j = jobs[i];
	let t = j.task;
	defer strings::freeall(j.args);
	static delete(jobs[i]);

	let out = get_cache(ctx, t.idx, t.kind)?;
@@ -222,8 +223,14 @@ fn await_task(ctx: *context, jobs: *[]job) (size | void | error) = {
		if (ctx.mode == output::DEFAULT) {
			fmt::errorln()?;
		};
		fmt::fatal(ctx.mods[t.idx].name, ctx.cmds[t.kind],
			exec::exitstr(e));

		fmt::errorf("Failed {} job ({}), command: {} ",
			ctx.mods[t.idx].name, exec::exitstr(e), ctx.cmds[t.kind])?;
		for (let i = 0z; i < len(j.args); i += 1) {
			fmt::error(" ")?;
			shlex::quote(os::stderr, j.args[i])?;
		};
		fmt::fatal();
	};

	cleanup_task(ctx, t)?;
diff --git a/cmd/hare/build/types.ha b/cmd/hare/build/types.ha
index 43470df5..2748ed67 100644
--- a/cmd/hare/build/types.ha
+++ b/cmd/hare/build/types.ha
@@ -51,6 +51,7 @@ export type job = struct {
	// fd to be closed once the job has finished, in order to release the
	// [[io::lock]] on it
	lock: io::file,
	args: []str,
};

export type output = enum {
-- 
2.41.0
hare/patches: SUCCESS in 1m39s

[hare/build: Print arguments of failed command][0] v2 from [Haelwenn (lanodan) Monnier][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/45296
[1]: mailto:contact+sr.ht@hacktivis.me

✓ #1067207 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1067207
✓ #1067206 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1067206
-1, you can use -vv (optionally with -j1) if you want to get the command
line for the thing that failed