diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a552de86d3..d73670fc90 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -157,6 +157,33 @@ jobs: name: ruff path: target/debug/ruff + cargo-test-linux-release: + name: "cargo test (linux, release)" + runs-on: depot-ubuntu-22.04-16 + needs: determine_changes + if: ${{ needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main' }} + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - name: "Install Rust toolchain" + run: rustup show + - name: "Install mold" + uses: rui314/setup-mold@v1 + - name: "Install cargo nextest" + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - name: "Install cargo insta" + uses: taiki-e/install-action@v2 + with: + tool: cargo-insta + - uses: Swatinem/rust-cache@v2 + - name: "Run tests" + shell: bash + env: + NEXTEST_PROFILE: "ci" + run: cargo insta test --release --all-features --unreferenced reject --test-runner nextest + cargo-test-windows: name: "cargo test (windows)" runs-on: windows-latest-xlarge @@ -212,7 +239,6 @@ jobs: cargo-build-release: name: "cargo build (release)" runs-on: macos-latest - needs: determine_changes if: ${{ github.ref == 'refs/heads/main' }} timeout-minutes: 20 steps: diff --git a/crates/red_knot_python_semantic/src/types/infer.rs b/crates/red_knot_python_semantic/src/types/infer.rs index dbf6c0bbef..32104b0f07 100644 --- a/crates/red_knot_python_semantic/src/types/infer.rs +++ b/crates/red_knot_python_semantic/src/types/infer.rs @@ -5985,7 +5985,11 @@ mod tests { "src/a.py", &["foo", ""], "x", - "@Todo(async iterables/iterators)", + if cfg!(debug_assertions) { + "@Todo(async iterables/iterators)" + } else { + "@Todo" + }, ); Ok(()) @@ -6015,7 +6019,11 @@ mod tests { "src/a.py", &["foo", ""], "x", - "@Todo(async iterables/iterators)", + if cfg!(debug_assertions) { + "@Todo(async iterables/iterators)" + } else { + "@Todo" + }, ); Ok(()) diff --git a/crates/red_knot_test/src/matcher.rs b/crates/red_knot_test/src/matcher.rs index 6d8b0488c4..5c8b7328ed 100644 --- a/crates/red_knot_test/src/matcher.rs +++ b/crates/red_knot_test/src/matcher.rs @@ -180,6 +180,16 @@ where } } +/// Discard `@Todo`-type metadata from expected types, which is not available +/// when running in release mode. +#[cfg(not(debug_assertions))] +fn discard_todo_metadata(ty: &str) -> std::borrow::Cow<'_, str> { + static TODO_METADATA_REGEX: std::sync::LazyLock = + std::sync::LazyLock::new(|| regex::Regex::new(r"@Todo\([^)]*\)").unwrap()); + + TODO_METADATA_REGEX.replace_all(ty, "@Todo") +} + struct Matcher { line_index: LineIndex, source: SourceText, @@ -276,6 +286,9 @@ impl Matcher { } } Assertion::Revealed(expected_type) => { + #[cfg(not(debug_assertions))] + let expected_type = discard_todo_metadata(&expected_type); + let mut matched_revealed_type = None; let mut matched_undefined_reveal = None; let expected_reveal_type_message = format!("Revealed type is `{expected_type}`");