From 5fa47d574a5dac8394baaeb1862958949c60ca97 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Thu, 28 May 2026 23:16:59 +0200 Subject: [PATCH] tests: keep trace even on failure --- docs/contributing.md | 19 +++++++++++++++++++ test/common.nix | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/docs/contributing.md b/docs/contributing.md index 7bcf992..8a00a12 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -61,6 +61,25 @@ If the test includes playwright tests, you can see the playwright trace with: $ nix run .#playwright -- show-trace $(nix eval .#checks.x86_64-linux.vm_grocy_basic --raw)/trace/0.zip ``` +If the test fails, you won't have the output directory available. +Instead, run the test with `--keep-failed` and at the end you will see a line saying + +``` +Keeping build directory '/nix/var/nix/builds/nix-31776-4270051001/build' +``` + +Copy the path and run: + +```bash +sudo cp -r /nix/var/nix/builds/nix-31776-4270051001/build/shared-xchg/trace trace && sudo chown -R $USER: trace +``` + +Now, open that file with playwright: + +```bash +nix run .#playwright -- show-trace trace/0.zip +``` + ### Debug Tests {#contributing-debug-tests} Run the test in driver interactive mode: diff --git a/test/common.nix b/test/common.nix index 08b6b7e..7372113 100644 --- a/test/common.nix +++ b/test/common.nix @@ -152,6 +152,10 @@ let code, logs = server.execute("login_playwright") print(logs) try: + server.succeed(""" + mkdir -p /tmp/shared/ + cp -r trace /tmp/shared/ + """) server.copy_from_vm("trace") except: print("No trace found on server") @@ -163,6 +167,10 @@ let code, logs = client.execute("login_playwright") print(logs) try: + client.succeed(""" + mkdir -p /tmp/shared/ + cp -r trace /tmp/shared/ + """) client.copy_from_vm("trace") except: print("No trace found on client")