Skip to content

Kris/various nix fixes - #6344

Open
krisajenkins wants to merge 3 commits into
masterfrom
kris/various-nix-fixes
Open

krisajenkins wants to merge 3 commits into
masterfrom
kris/various-nix-fixes

Conversation

@krisajenkins

Copy link
Copy Markdown
Contributor

Description of Changes

Three changes specifically for the nix builds:

  • Updating the nix flake to Rust 1.97.1.
  • Pinning our required version of wasm-bindgen
  • Changing a couple of hard-coded paths in the unit tests, so they get cat and head from $PATH.

This makes the build and test suite more portable and repeatable.

API and ABI breaking changes

N/A

Rollback safety impact

N/A

Expected complexity level and risk

  1. Low risk.
  • The nix changes will only affect developers who use nix shells. Their workflow is currently broken and this just restores things.
  • The test changes become more portable, and if the change was wrong, we'd see it in the CI test run immediately.

Testing

Ran the full test suite from a nix shell.

rust-toolchain.toml now pins channel 1.97.1, and the Nix dev shell builds its toolchain from that file via rust-overlay, so the overlay lock should be fresh enough to carry it.

Bumped the rust-overlay input in flake.lock with `nix flake update rust-overlay`. Verified with `nix develop -c rustc --version`, which reports 1.97.1.
…bin/head.

The schema_extract tests build a throwaway inspector shell script and run it
through inspect_with. Two of them check that the inspector received the exact
module bytes with:

    [ "$(/bin/cat "$2")" = exact-artifact ] || exit 3

That works on a developer machine, so where does it fail? In a Nix build
sandbox, which has no /bin/cat. nixpkgs runs the test suite when it builds
spacetimedb, and the automatic 2.10.2 -> 2.12.0 update has been failing since
these tests landed:

    /build/.tmpQddzhq/inspector: line 3: /bin/cat: not found
    failures:
        schema_extract::tests::local_inspection_passes_exact_bytes_host_and_requires_success
        schema_extract::tests::synchronous_generate_adapter_uses_same_exact_byte_protocol_inside_a_runtime

So nixpkgs is stuck on 2.10.2 until someone patches around it.

A third test has the same hardcoded path, but it fails silently instead.
invalid_and_oversize_inspector_output_never_becomes_diagnostics runs
"exec /usr/bin/head -c 16777217 /dev/zero" to check that inspector output over
the 16 MiB limit is rejected. When /usr/bin/head is missing, exec fails, the
script exits non-zero, inspect_with returns an error, and the test passes
because all it checks is that some error came back. In that environment the
oversize path is never exercised at all.

Writing a bare `cat` would not help. configure_inspector_environment clears
the environment on Unix, so the inspector runs with no PATH and the shell
falls back to a default search path, which is just as empty in the sandbox.

The tests now resolve each tool from their own PATH (which the build
environment does populate) and write its absolute path into the script. The
oversize test also asserts on the specific error for each case, so a missing
tool or a script failing for the wrong reason can no longer pass.

- New `tool(name)` helper searches the test process PATH and panics with a
  clear message if the tool is missing.
- Both exact-bytes tests interpolate `{cat}` from `tool("cat")`.
- The oversize test uses `tool("head")` and checks for "exceeds output limit";
  the invalid-output case checks for "returned invalid schema data".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant