~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH hare] hare/build: Print arguments of failed command

Details
Message ID
<20231001145400.8235-1-contact+sr.ht@hacktivis.me>
DKIM signature
missing
Download raw message
Patch: +7 -2
From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>

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

diff --git a/cmd/hare/build/queue.ha b/cmd/hare/build/queue.ha
index 973f9350..51309459 100644
--- a/cmd/hare/build/queue.ha
+++ b/cmd/hare/build/queue.ha
@@ -175,10 +175,12 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
	defer io::close(output)!;
	exec::addfile(&cmd, os::stdout_file, output);
	exec::addfile(&cmd, os::stderr_file, output);
	let args = strings::join(" ", args...);
	static append(jobs, job {
		pid = exec::start(&cmd)?,
		task = t,
		lock = lock,
		args = args,
	});
	return true;
};
@@ -222,10 +224,12 @@ 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::fatalf("Failed {} job ({}), command: {} {}",
			ctx.mods[t.idx].name, exec::exitstr(e), ctx.cmds[t.kind], j.args);
	};

	free(j.args);
	cleanup_task(ctx, t)?;
	free_task(t);
	io::close(j.lock)?;
diff --git a/cmd/hare/build/types.ha b/cmd/hare/build/types.ha
index 43470df5..433d0437 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] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CVX6UEUJOLC4.1PLPZJ534K63Q@cirno2>
In-Reply-To
<20231001145400.8235-1-contact+sr.ht@hacktivis.me> (view parent)
DKIM signature
missing
Download raw message
hare/patches: SUCCESS in 1m29s

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

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

✓ #1066534 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1066534
✓ #1066535 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1066535
Details
Message ID
<CVX8GSMUVDSD.3Q8ITO4059TKR@disroot.org>
In-Reply-To
<20231001145400.8235-1-contact+sr.ht@hacktivis.me> (view parent)
DKIM signature
missing
Download raw message
On Sun Oct 1, 2023 at 17:54 MSK, Haelwenn (lanodan) Monnier wrote:
> diff --git a/cmd/hare/build/queue.ha b/cmd/hare/build/queue.ha
> index 973f9350..51309459 100644
> --- a/cmd/hare/build/queue.ha
> +++ b/cmd/hare/build/queue.ha
> @@ -175,10 +175,12 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
>  	defer io::close(output)!;
>  	exec::addfile(&cmd, os::stdout_file, output);
>  	exec::addfile(&cmd, os::stderr_file, output);
> +	let args = strings::join(" ", args...);

This should use shlex::quote like case output::VVERBOSE above in this function.

memio::dynamic can be used to write it into a string, or alternatively, store
the args slice in the task and quote only when reporting the error.

> +	free(j.args);

This should be moved to free_task since there are different codepaths where a
task is freed, which would leak args.
Reply to thread Export thread (mbox)