Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent terminal width expectations between built_by_uv_editable-2 and help tests #9336

Open
mgorny opened this issue Nov 21, 2024 · 3 comments
Labels
testing Internal testing of behavior

Comments

@mgorny
Copy link
Contributor

mgorny commented Nov 21, 2024

Hit it with 0.5.4 and a513301.

There's a bunch of help tests in uv that assume a 100 character wide terminal. To make them pass in the past, I've started using COLUMNS=100 to run the test suite. However, the most recent release introduced built_by_uv_editable-2 that actually assumes a 80-character wide terminal. Hence, whichever COLUMNS value I use, some tests fail.

$ COLUMNS=80 cargo test --test it --no-default-features
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.23s
     Running tests/it/main.rs (target/debug/deps/it-a93b0d5fb81fa362)

running 108 tests
[…]
   53    61 │           Allow insecure connections to a host [env: UV_INSECURE_HOST=]
┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
   57    65 │           Change to the given directory prior to running the command
   58    66 │       --project <PROJECT>
   59    67 │           Run the command within the given project directory
   60    68 │       --config-file <CONFIG_FILE>
   61       │-          The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
         69 │+          The path to a `uv.toml` file to use for configuration [env:
         70 │+          UV_CONFIG_FILE=]
   62    71 │       --no-config
   63       │-          Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) [env: UV_NO_CONFIG=]
         72 │+          Avoid discovering configuration files (`pyproject.toml`, `uv.toml`)
         73 │+          [env: UV_NO_CONFIG=]
   64    74 │   -h, --help
   65    75 │           Display the concise help for this command
   66    76 │   -V, --version
   67    77 │           Display the uv version
────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'help::help_with_no_pager' panicked at /home/mgorny/.cargo/registry/src/index.crates.io-6f17d22bba15001f/insta-1.41.1/src/runtime.rs:680:13:
snapshot assertion for 'help_with_no_pager' failed in line 999


failures:
    help::help
    help::help_flag
    help::help_flag_subcommand
    help::help_flag_subsubcommand
    help::help_short_flag
    help::help_subcommand
    help::help_subsubcommand
    help::help_with_global_option
    help::help_with_no_pager

test result: FAILED. 99 passed; 9 failed; 0 ignored; 0 measured; 0 filtered out; finished in 22.53s

error: test failed, to rerun pass `-p uv --test it`
$ COLUMNS=100 cargo test --test it --no-default-features -F python
   Compiling uv v0.5.4 (/home/mgorny/git/uv/crates/uv)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 42.46s
     Running tests/it/main.rs (target/debug/deps/it-bed166d36b75cf3e)

running 147 tests
[…]
failures:

---- build_backend::built_by_uv_editable stdout ----

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Unfiltered output ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
----- stdout -----
built_by_uv-0.1.0-py3-none-any.whl

----- stderr -----

────────────────────────────────────────────────────────────────────────────────


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Unfiltered output ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
----- stdout -----
..                                                                                           [100%]
2 passed in 0.01s

----- stderr -----

────────────────────────────────────────────────────────────────────────────────

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: built_by_uv_editable-2
Source: crates/uv/tests/it/build_backend.rs:189
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Expression: snapshot
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    0     0 │ success: true
    1     1 │ exit_code: 0
    2     2 │ ----- stdout -----
    3       │-..                                                                       [100%]
          3 │+..                                                                                           [100%]
    4     4 │ 2 passed in [TIME]
    5     5 │ 
    6     6 │ ----- stderr -----
────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'build_backend::built_by_uv_editable' panicked at /home/mgorny/.cargo/registry/src/index.crates.io-6f17d22bba15001f/insta-1.41.1/src/runtime.rs:680:13:
snapshot assertion for 'built_by_uv_editable-2' failed in line 189
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    build_backend::built_by_uv_editable

test result: FAILED. 146 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 32.34s

error: test failed, to rerun pass `-p uv --test it`

My guess would be that uv uses terminal width since it's "outer", while pytest defaults to 80 since it's run with piped stdout. The former implies we need to use COLUMNS if we don't have exactly the same terminal width as CI, but COLUMNS leaks into pytest and modifies its output.

@charliermarsh
Copy link
Member

Sorry about that. We'll figure out something else.

@charliermarsh charliermarsh added the testing Internal testing of behavior label Nov 21, 2024
@charliermarsh
Copy link
Member

\cc @konstin in case you have ideas

@konstin
Copy link
Member

konstin commented Nov 21, 2024

We're capturing pytest's behavior here, not uv's. We can set COLUMNS for the pytest invocations, but it's probably better to filter out that line entirely and only keep the 2 passed in line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Internal testing of behavior
Projects
None yet
Development

No branches or pull requests

3 participants