diff --git a/.github/workflows/apidocs-drift.yml b/.github/workflows/apidocs-drift.yml index c750974f4..690fef7b8 100644 --- a/.github/workflows/apidocs-drift.yml +++ b/.github/workflows/apidocs-drift.yml @@ -75,7 +75,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: diff --git a/.github/workflows/bash-oracle.yml b/.github/workflows/bash-oracle.yml index 62fd0ea63..39bac1316 100644 --- a/.github/workflows/bash-oracle.yml +++ b/.github/workflows/bash-oracle.yml @@ -38,7 +38,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 diff --git a/.github/workflows/builtins-drift.yml b/.github/workflows/builtins-drift.yml index d5b740fdc..933f38eca 100644 --- a/.github/workflows/builtins-drift.yml +++ b/.github/workflows/builtins-drift.yml @@ -41,7 +41,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 diff --git a/.github/workflows/c-api-binaries.yml b/.github/workflows/c-api-binaries.yml index 6ae8538e9..0106e4dcc 100644 --- a/.github/workflows/c-api-binaries.yml +++ b/.github/workflows/c-api-binaries.yml @@ -104,7 +104,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: ${{ matrix.target }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f25a064a..8896bc9c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,40 @@ env: JQ_VERSION: 1.8.1 jobs: + msrv: + name: Rust 1.96 consumer (${{ matrix.os }}, ${{ matrix.profile }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + profile: [lean, default, all] + include: + - os: ubuntu-latest + profile: wasm + - os: ubuntu-latest + profile: wasi + - os: ubuntu-latest + profile: browser + - os: ubuntu-latest + profile: component + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: "3.12" + - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + with: + targets: wasm32-unknown-unknown, wasm32-wasip2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 + with: + shared-key: msrv-1.96-${{ matrix.os }}-${{ matrix.profile }} + workspaces: . -> target/consumer-1.96.0 + - name: Check independently resolved consumer + run: python3 scripts/check-msrv-consumer.py --profile ${{ matrix.profile }} + lint: name: Lint runs-on: ubuntu-latest @@ -28,7 +62,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: components: rustfmt, clippy @@ -89,7 +123,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: wasm32-unknown-unknown, wasm32-wasip2 @@ -127,7 +161,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: wasm32-unknown-unknown @@ -158,7 +192,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: wasm32-unknown-unknown @@ -210,7 +244,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # Install the prebuilt cargo-audit binary rather than letting # rustsec/audit-check compile it from source. The source build resolves @@ -277,7 +311,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -410,20 +444,20 @@ jobs: matrix: include: - os: ubuntu-latest - rust: "1.96.0" + rust: "1.100.0" - os: macos-latest - rust: "1.96.0" + rust: "1.100.0" - os: windows-2025 - rust: "1.96.0" + rust: "1.100.0" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Install Rust toolchain - # 1.96.0 comes from rust-toolchain.toml (the matrix pins the same); + # 1.100.0 comes from rust-toolchain.toml (the matrix pins the same); # the action no longer accepts a `toolchain:` input. - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -447,7 +481,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: @@ -482,7 +516,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: @@ -512,7 +546,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -666,7 +700,7 @@ jobs: persist-credentials: false - name: Install Rust stable (default toolchain) - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # The action no longer accepts a `toolchain:` input (it installs # the rust-toolchain.toml toolchain), so install the pinned nightly @@ -704,12 +738,13 @@ jobs: check: name: Check if: always() - needs: [lint, audit, test, cpython-platforms, windows-containment, test-windows, examples, fuzz-check, wasm, wasm-component, wasm-web] + needs: [msrv, lint, audit, test, cpython-platforms, windows-containment, test-windows, examples, fuzz-check, wasm, wasm-component, wasm-web] runs-on: ubuntu-latest steps: - name: Verify all jobs passed run: | - if [[ "${{ needs.lint.result }}" != "success" ]] || \ + if [[ "${{ needs.msrv.result }}" != "success" ]] || \ + [[ "${{ needs.lint.result }}" != "success" ]] || \ [[ "${{ needs.audit.result }}" != "success" ]] || \ [[ "${{ needs.test.result }}" != "success" ]] || \ [[ "${{ needs.cpython-platforms.result }}" != "success" ]] || \ diff --git a/.github/workflows/cli-binaries.yml b/.github/workflows/cli-binaries.yml index 724b1c965..61b7d7fa7 100644 --- a/.github/workflows/cli-binaries.yml +++ b/.github/workflows/cli-binaries.yml @@ -96,7 +96,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: ${{ matrix.target }} diff --git a/.github/workflows/coreutils-args-drift.yml b/.github/workflows/coreutils-args-drift.yml index 3e480fbb4..a56a07727 100644 --- a/.github/workflows/coreutils-args-drift.yml +++ b/.github/workflows/coreutils-args-drift.yml @@ -71,7 +71,7 @@ jobs: fetch-depth: 0 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: components: rustfmt diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 71924c2a5..daf46dc1b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -35,7 +35,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: components: llvm-tools-preview @@ -93,7 +93,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: components: llvm-tools-preview @@ -144,7 +144,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: components: llvm-tools-preview diff --git a/.github/workflows/debian-oracle.yml b/.github/workflows/debian-oracle.yml index f056fedc9..ac16f3131 100644 --- a/.github/workflows/debian-oracle.yml +++ b/.github/workflows/debian-oracle.yml @@ -42,7 +42,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 51f8ce3de..2a042ab00 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -34,7 +34,7 @@ jobs: persist-credentials: false - name: Install Rust stable (default toolchain) - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # The action no longer accepts a `toolchain:` input (it installs # the rust-toolchain.toml toolchain), so install the pinned nightly diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index 2e6d2c56f..4353c0ab1 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -42,7 +42,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -111,7 +111,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -276,7 +276,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + - uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c5428a3b9..7c64b082d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -26,7 +26,7 @@ jobs: persist-credentials: false - name: Install Rust stable (default toolchain) - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # The action no longer accepts a `toolchain:` input (it installs # the rust-toolchain.toml toolchain), so install the pinned nightly @@ -64,7 +64,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # Prebuilt binary rather than a source build: cargo-audit's own # dependencies resolve unlocked, and an MSRV bump in one of them past our @@ -98,7 +98,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -151,7 +151,7 @@ jobs: uses: ./.github/actions/free-disk-space - name: Install Rust stable (default toolchain) - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # The action no longer accepts a `toolchain:` input (it installs # the rust-toolchain.toml toolchain), so install the pinned nightly @@ -221,7 +221,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: @@ -247,7 +247,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: diff --git a/.github/workflows/publish-js.yml b/.github/workflows/publish-js.yml index 8745aa583..e2c434c91 100644 --- a/.github/workflows/publish-js.yml +++ b/.github/workflows/publish-js.yml @@ -110,7 +110,7 @@ jobs: cache-dependency-path: crates/bashkit-js/pnpm-lock.yaml - name: Install Rust - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index 1358c9e3a..4d63a2e8d 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -152,7 +152,7 @@ jobs: # its LLVM matches Emscripten 4.0.9's binaryen. pyodide-build manages its # own matching emsdk via the cross-build env (no setup-emsdk needed). - name: Install Rust stable (default toolchain) - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # The action no longer accepts a `toolchain:` input (it installs # the rust-toolchain.toml toolchain), so install the pinned nightly diff --git a/.github/workflows/publish-wasm.yml b/.github/workflows/publish-wasm.yml index aa176d2ed..fc4eadf53 100644 --- a/.github/workflows/publish-wasm.yml +++ b/.github/workflows/publish-wasm.yml @@ -63,7 +63,7 @@ jobs: persist-credentials: false - name: Install Rust - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 with: targets: wasm32-unknown-unknown diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0476b6943..77e464a95 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -107,7 +107,7 @@ jobs: fi - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - name: Verify bashkit-cpython-wasm package without credentials run: | @@ -163,7 +163,7 @@ jobs: fi - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - name: Verify bashkit-monty-types package without credentials run: cargo publish --dry-run -p bashkit-monty-types @@ -202,7 +202,7 @@ jobs: fi - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - name: Wait for crates.io index update run: sleep 30 @@ -246,7 +246,7 @@ jobs: echo "Publish source verified on origin/main: $SOURCE_SHA" - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - name: Verify version matches tag env: @@ -292,7 +292,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - name: Wait for crates.io index update run: sleep 30 @@ -326,7 +326,7 @@ jobs: persist-credentials: false - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - name: Wait for crates.io index update run: sleep 30 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index da8d21080..bb3325b6b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -100,7 +100,7 @@ jobs: path: crates/bashkit-python/dist - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -147,7 +147,7 @@ jobs: - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: python-version: "3.12" - - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + - uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - name: Build and install native wheel run: | @@ -183,7 +183,7 @@ jobs: - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 @@ -286,7 +286,7 @@ jobs: # binaryen, which is what avoids the wasm-opt target-feature skew that # older Emscripten (3.1.x) hit. See knowledge/runtimes/emscripten-wheels.md. - name: Install Rust stable (default toolchain) - uses: dtolnay/rust-toolchain@d86e0fa8f147d6539442c26a61ebba8becc19489 # 1.96.0 + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 # The action no longer accepts a `toolchain:` input (it installs # the rust-toolchain.toml toolchain), so install the pinned nightly diff --git a/AGENTS.md b/AGENTS.md index cc5eca532..fb1cf07f5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -160,6 +160,9 @@ criteria live in `knowledge/operations/testing.md`. - Stable Rust, version pinned in `rust-toolchain.toml` (bump deliberately; match the new version in `dtolnay/rust-toolchain@` refs across `.github/workflows/*` so CI can't be broken by a same-day rustc release) +- Consumer compatibility is checked independently on Rust 1.96.0 via + `scripts/check-msrv-consumer.py`; do not raise the consumer floor just because + the development toolchain changes. Keep compiler-specific target caches separate. - `cargo fmt` and `cargo clippy -- -D warnings` - License checks: `cargo deny check` (see `deny.toml`) diff --git a/crates/bashkit-wasm/src/lib.rs b/crates/bashkit-wasm/src/lib.rs index 63b65b062..f894ff41f 100644 --- a/crates/bashkit-wasm/src/lib.rs +++ b/crates/bashkit-wasm/src/lib.rs @@ -65,13 +65,15 @@ pub fn __start() { // --------------------------------------------------------------------------- /// Result of a bash execution, mirrored from the Rust `ExecResult`. -#[wasm_bindgen(getter_with_clone)] +#[wasm_bindgen] pub struct ExecResult { + #[wasm_bindgen(getter_with_clone)] pub stdout: String, - #[wasm_bindgen(js_name = stdoutBytes)] + #[wasm_bindgen(getter_with_clone, js_name = stdoutBytes)] pub stdout_bytes: Vec, + #[wasm_bindgen(getter_with_clone)] pub stderr: String, - #[wasm_bindgen(js_name = stderrBytes)] + #[wasm_bindgen(getter_with_clone, js_name = stderrBytes)] pub stderr_bytes: Vec, #[wasm_bindgen(js_name = exitCode)] pub exit_code: i32, diff --git a/crates/bashkit/src/builtins/arg_parser.rs b/crates/bashkit/src/builtins/arg_parser.rs index f7e432641..a0e5773d0 100644 --- a/crates/bashkit/src/builtins/arg_parser.rs +++ b/crates/bashkit/src/builtins/arg_parser.rs @@ -153,10 +153,7 @@ impl<'a> ArgParser<'a> { /// Try to consume a flag with a value, silently returning None if /// the flag matches but no value is available (for lenient parsers). pub fn flag_value_opt(&mut self, name: &str) -> Option<&'a str> { - let arg = match self.args.get(self.pos) { - Some(a) => a.as_str(), - None => return None, - }; + let arg = self.args.get(self.pos)?.as_str(); if arg == name { self.pos += 1; diff --git a/crates/bashkit/src/builtins/column.rs b/crates/bashkit/src/builtins/column.rs index e2a85dce4..77c03dfb5 100644 --- a/crates/bashkit/src/builtins/column.rs +++ b/crates/bashkit/src/builtins/column.rs @@ -188,7 +188,7 @@ impl Builtin for Column { let text = match read_text_file(&*ctx.fs, &path, "column").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; input.push_str(&text); } diff --git a/crates/bashkit/src/builtins/comm.rs b/crates/bashkit/src/builtins/comm.rs index 4def9d62b..a7fc47683 100644 --- a/crates/bashkit/src/builtins/comm.rs +++ b/crates/bashkit/src/builtins/comm.rs @@ -125,7 +125,7 @@ impl Builtin for Comm { }; match read_text_file(&*ctx.fs, &path, "comm").await { Ok(text) => text, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), } }; inputs.push(records(&text, sep)); diff --git a/crates/bashkit/src/builtins/cpython/wasi.rs b/crates/bashkit/src/builtins/cpython/wasi.rs index 43e6df45d..c6eeb89ee 100644 --- a/crates/bashkit/src/builtins/cpython/wasi.rs +++ b/crates/bashkit/src/builtins/cpython/wasi.rs @@ -484,7 +484,9 @@ fn read_iovs( } let raw = read_bytes(caller, iovs, i32::try_from(count * 8).map_err(|_| EINVAL)?)?; Ok(raw - .chunks_exact(8) + .as_chunks::<8>() + .0 + .iter() .map(|c| { let ptr = i32::from_le_bytes([c[0], c[1], c[2], c[3]]); let len = u32::from_le_bytes([c[4], c[5], c[6], c[7]]); @@ -1600,7 +1602,7 @@ async fn poll_oneoff( let raw = read_bytes(c, subs, i32::try_from(n * 48).map_err(|_| EINVAL)?)?; let mut ready = Vec::new(); let mut sleep: Option<(Duration, u64)> = None; - for sub in raw.chunks_exact(48) { + for sub in raw.as_chunks::<48>().0.iter() { let userdata = u64::from_le_bytes(sub[0..8].try_into().map_err(|_| EINVAL)?); match sub[8] { EVENTTYPE_CLOCK => { diff --git a/crates/bashkit/src/builtins/csv.rs b/crates/bashkit/src/builtins/csv.rs index 67e70ee0e..480ee0301 100644 --- a/crates/bashkit/src/builtins/csv.rs +++ b/crates/bashkit/src/builtins/csv.rs @@ -118,16 +118,16 @@ fn resolve_column(col: &str, headers: &Option>) -> Option { async fn read_input<'a>( ctx: &Context<'a>, file_arg: Option<&str>, -) -> std::result::Result { +) -> std::result::Result> { if let Some(path_str) = file_arg { let path = resolve_path(ctx.cwd, path_str); - read_text_file(ctx.fs.as_ref(), &path, "csv") + Ok(read_text_file(ctx.fs.as_ref(), &path, "csv") .await - .map_err(|_| ExecResult::err(format!("csv: cannot read '{}'\n", path_str), 1)) + .map_err(|_| ExecResult::err(format!("csv: cannot read '{}'\n", path_str), 1))?) } else if let Some(stdin) = ctx.stdin { Ok(stdin.to_string()) } else { - Err(ExecResult::err("csv: no input\n".to_string(), 1)) + Err(Box::new(ExecResult::err("csv: no input\n".to_string(), 1))) } } @@ -192,7 +192,7 @@ impl Builtin for Csv { let file_arg = rest.first().map(|s| s.as_str()); let content = match read_input(&ctx, file_arg).await { Ok(c) => c, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let table = parse_csv(&content, delim, has_header); if let Some(hdrs) = &table.headers { @@ -214,7 +214,7 @@ impl Builtin for Csv { let file_arg = rest.first().map(|s| s.as_str()); let content = match read_input(&ctx, file_arg).await { Ok(c) => c, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let table = parse_csv(&content, delim, has_header); Ok(ExecResult::ok(format!("{}\n", table.rows.len()))) @@ -230,7 +230,7 @@ impl Builtin for Csv { let file_arg = rest.get(1).map(|s| s.as_str()); let content = match read_input(&ctx, file_arg).await { Ok(c) => c, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let table = parse_csv(&content, delim, has_header); @@ -279,7 +279,7 @@ impl Builtin for Csv { let content = match read_input(&ctx, file_arg).await { Ok(c) => c, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let table = parse_csv(&content, delim, has_header); @@ -330,7 +330,7 @@ impl Builtin for Csv { let content = match read_input(&ctx, file_arg).await { Ok(c) => c, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let table = parse_csv(&content, delim, has_header); diff --git a/crates/bashkit/src/builtins/cuttr.rs b/crates/bashkit/src/builtins/cuttr.rs index 8362aa949..83988246b 100644 --- a/crates/bashkit/src/builtins/cuttr.rs +++ b/crates/bashkit/src/builtins/cuttr.rs @@ -189,7 +189,7 @@ impl Builtin for Cut { let text = match read_text_file(&*ctx.fs, &path, "cut").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; process_input(&text, &mut output); } diff --git a/crates/bashkit/src/builtins/diff.rs b/crates/bashkit/src/builtins/diff.rs index e21a7a6c4..4be1acb20 100644 --- a/crates/bashkit/src/builtins/diff.rs +++ b/crates/bashkit/src/builtins/diff.rs @@ -353,7 +353,7 @@ impl Builtin for Diff { }; match read_text_file(&*ctx.fs, &path, "diff").await { Ok(text) => text.lines().map(|l| l.to_string()).collect(), - Err(e) => return Ok(e), + Err(e) => return Ok(*e), } }; @@ -370,7 +370,7 @@ impl Builtin for Diff { }; match read_text_file(&*ctx.fs, &path, "diff").await { Ok(text) => text.lines().map(|l| l.to_string()).collect(), - Err(e) => return Ok(e), + Err(e) => return Ok(*e), } }; diff --git a/crates/bashkit/src/builtins/dotenv.rs b/crates/bashkit/src/builtins/dotenv.rs index f0b51423e..df9e763cb 100644 --- a/crates/bashkit/src/builtins/dotenv.rs +++ b/crates/bashkit/src/builtins/dotenv.rs @@ -114,7 +114,7 @@ impl Builtin for Dotenv { let path = resolve_path(ctx.cwd, file); let content = match read_text_file(&*ctx.fs, &path, "dotenv").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let pairs = parse_dotenv(&content); diff --git a/crates/bashkit/src/builtins/expand.rs b/crates/bashkit/src/builtins/expand.rs index 191e1e07f..b04678270 100644 --- a/crates/bashkit/src/builtins/expand.rs +++ b/crates/bashkit/src/builtins/expand.rs @@ -150,7 +150,7 @@ fn split_obsolete_tabs(args: &[String]) -> (Vec, Vec) { async fn read_inputs( ctx: &Context<'_>, files: &[String], -) -> std::result::Result { +) -> std::result::Result> { if files.is_empty() { return Ok(ctx.stdin.map(ToString::to_string).unwrap_or_default()); } @@ -163,7 +163,7 @@ async fn read_inputs( let path = resolve_path(ctx.cwd, file); match read_text_file(ctx.fs.as_ref(), &path, H::NAME).await { Ok(text) => buf.push_str(&text), - Err(_) => return Err(H::err_path(file, "No such file or directory", 1)), + Err(_) => return Err(Box::new(H::err_path(file, "No such file or directory", 1))), } } Ok(buf) @@ -229,7 +229,7 @@ impl Builtin for Expand { let input = match read_inputs::(&ctx, &files).await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let too_big = || Self::err(format!("output exceeds byte limit ({MAX_OUTPUT_BYTES})"), 1); @@ -341,7 +341,7 @@ impl Builtin for Unexpand { let input = match read_inputs::(&ctx, &files).await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let mut output = String::with_capacity(input.len()); diff --git a/crates/bashkit/src/builtins/hextools.rs b/crates/bashkit/src/builtins/hextools.rs index 6cfc9f83c..11ae229ba 100644 --- a/crates/bashkit/src/builtins/hextools.rs +++ b/crates/bashkit/src/builtins/hextools.rs @@ -516,7 +516,7 @@ impl Builtin for Od { let data = match collect_input("od", ctx.stdin, &files, ctx.cwd, &ctx.fs).await { Ok(data) => data, - Err(failure) => return Ok(failure), + Err(failure) => return Ok(*failure), }; let budget = ctx .execution_budget() @@ -734,7 +734,7 @@ impl Builtin for Xxd { let data = match collect_input("xxd", ctx.stdin, &files, ctx.cwd, &ctx.fs).await { Ok(data) => data, - Err(failure) => return Ok(failure), + Err(failure) => return Ok(*failure), }; if opts.reverse { @@ -895,7 +895,7 @@ impl Builtin for Hexdump { let data = match collect_input("hexdump", ctx.stdin, &files, ctx.cwd, &ctx.fs).await { Ok(data) => data, - Err(failure) => return Ok(failure), + Err(failure) => return Ok(*failure), }; let output = hexdump_dump(&data, &opts); @@ -921,7 +921,7 @@ async fn collect_input( files: &[String], cwd: &std::path::Path, fs: &std::sync::Arc, -) -> std::result::Result, ExecResult> { +) -> std::result::Result, Box> { let mut data = Vec::new(); if files.is_empty() { diff --git a/crates/bashkit/src/builtins/iconv.rs b/crates/bashkit/src/builtins/iconv.rs index 830120bd9..d9b00dba3 100644 --- a/crates/bashkit/src/builtins/iconv.rs +++ b/crates/bashkit/src/builtins/iconv.rs @@ -205,7 +205,9 @@ fn decode_from(input: &[u8], encoding: &str) -> std::result::Result = data - .chunks_exact(2) + .as_chunks::<2>() + .0 + .iter() .map(|c| { if big_endian { u16::from_be_bytes([c[0], c[1]]) @@ -221,7 +223,9 @@ fn decode_from(input: &[u8], encoding: &str) -> std::result::Result = input - .chunks_exact(2) + .as_chunks::<2>() + .0 + .iter() .map(|c| u16::from_be_bytes([c[0], c[1]])) .collect(); String::from_utf16(&units).map_err(|e| format!("iconv: invalid UTF-16BE input: {e}\n")) diff --git a/crates/bashkit/src/builtins/jq/mod.rs b/crates/bashkit/src/builtins/jq/mod.rs index 517feef81..61933ccf3 100644 --- a/crates/bashkit/src/builtins/jq/mod.rs +++ b/crates/bashkit/src/builtins/jq/mod.rs @@ -176,7 +176,7 @@ async fn run_jq(ctx: Context<'_>, parsed: JqArgs<'_>) -> Result { } let text = match read_text_file(&*ctx.fs, &path, "jq").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; ctx.consume_budget_input(text.len())?; match file_binding_bytes.checked_add(text.len()) { diff --git a/crates/bashkit/src/builtins/json.rs b/crates/bashkit/src/builtins/json.rs index a4bf47a2d..1540c8987 100644 --- a/crates/bashkit/src/builtins/json.rs +++ b/crates/bashkit/src/builtins/json.rs @@ -120,24 +120,28 @@ fn format_value(v: &Value) -> String { async fn read_json_input( ctx: &Context<'_>, file_arg: Option<&str>, -) -> std::result::Result { +) -> std::result::Result> { if let Some(file) = file_arg { let path = resolve_path(ctx.cwd, file); match ctx.fs.read_file(&path).await { - Ok(bytes) => String::from_utf8(bytes) - .map_err(|e| ExecResult::err(format!("json: invalid UTF-8 in {file}: {e}\n"), 1)), + Ok(bytes) => Ok(String::from_utf8(bytes).map_err(|e| { + ExecResult::err(format!("json: invalid UTF-8 in {file}: {e}\n"), 1) + })?), Err(e) => { let reason = crate::error::io_error_reason(&e); - Err(ExecResult::err(format!("json: {file}: {reason}\n"), 1)) + Err(Box::new(ExecResult::err( + format!("json: {file}: {reason}\n"), + 1, + ))) } } } else if let Some(stdin) = ctx.stdin { Ok(stdin.to_string()) } else { - Err(ExecResult::err( + Err(Box::new(ExecResult::err( "json: no input (provide file or pipe stdin)\n".to_string(), 1, - )) + ))) } } @@ -166,7 +170,7 @@ impl Builtin for Json { let file_arg = rest.get(1).map(|s| s.as_str()); let input = match read_json_input(&ctx, file_arg).await { Ok(s) => s, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let value: Value = match serde_json::from_str(input.trim()) { Ok(v) => v, @@ -193,7 +197,7 @@ impl Builtin for Json { let file_arg = rest.get(2).map(|s| s.as_str()); let input = match read_json_input(&ctx, file_arg).await { Ok(s) => s, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let mut value: Value = match serde_json::from_str(input.trim()) { Ok(v) => v, @@ -216,7 +220,7 @@ impl Builtin for Json { let file_arg = rest.first().map(|s| s.as_str()); let input = match read_json_input(&ctx, file_arg).await { Ok(s) => s, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let value: Value = match serde_json::from_str(input.trim()) { Ok(v) => v, @@ -241,7 +245,7 @@ impl Builtin for Json { let file_arg = rest.first().map(|s| s.as_str()); let input = match read_json_input(&ctx, file_arg).await { Ok(s) => s, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let value: Value = match serde_json::from_str(input.trim()) { Ok(v) => v, @@ -264,7 +268,7 @@ impl Builtin for Json { let file_arg = rest.first().map(|s| s.as_str()); let input = match read_json_input(&ctx, file_arg).await { Ok(s) => s, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let value: Value = match serde_json::from_str(input.trim()) { Ok(v) => v, @@ -284,7 +288,7 @@ impl Builtin for Json { let file_arg = rest.first().map(|s| s.as_str()); let input = match read_json_input(&ctx, file_arg).await { Ok(s) => s, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; let value: Value = match serde_json::from_str(input.trim()) { Ok(v) => v, diff --git a/crates/bashkit/src/builtins/mod.rs b/crates/bashkit/src/builtins/mod.rs index 5c8c60403..c2dace0f8 100644 --- a/crates/bashkit/src/builtins/mod.rs +++ b/crates/bashkit/src/builtins/mod.rs @@ -334,11 +334,13 @@ use crate::error::Result; use crate::fs::FileSystem; use crate::interpreter::ExecResult; +// Keep diagnostic-only failures off the success-path stack: ExecResult carries +// complete shell output and control state, not just an error message. pub(crate) async fn read_text_file( fs: &dyn FileSystem, path: &Path, cmd_name: &str, -) -> std::result::Result { +) -> std::result::Result> { let content = read_stream_file(fs, path, cmd_name).await?; Ok(content.to_string()) @@ -348,8 +350,9 @@ pub(crate) async fn read_stream_file( fs: &dyn FileSystem, path: &Path, cmd_name: &str, -) -> std::result::Result { - fs.read_file(path) +) -> std::result::Result> { + Ok(fs + .read_file(path) .await .map(crate::StreamData::from) .map_err(|e| { @@ -363,7 +366,7 @@ pub(crate) async fn read_stream_file( ), 1, ) - }) + })?) } /// Check args for `--help` and optionally `--version`. diff --git a/crates/bashkit/src/builtins/nl.rs b/crates/bashkit/src/builtins/nl.rs index 2b035840e..dd09e12c1 100644 --- a/crates/bashkit/src/builtins/nl.rs +++ b/crates/bashkit/src/builtins/nl.rs @@ -312,7 +312,7 @@ impl Builtin for Nl { }; let text = match read_text_file(&*ctx.fs, &path, "nl").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; number_lines(&text, &opts, &mut state, &mut output); } diff --git a/crates/bashkit/src/builtins/numfmt.rs b/crates/bashkit/src/builtins/numfmt.rs index 1f6769101..cffaf1b80 100644 --- a/crates/bashkit/src/builtins/numfmt.rs +++ b/crates/bashkit/src/builtins/numfmt.rs @@ -356,7 +356,7 @@ fn parse_options(args: &[String]) -> std::result::Result<(Options, Vec), } opts.field = args[i] .parse() - .map_err(|_| format!("numfmt: invalid field value: '{}'\n", &args[i]))?; + .map_err(|_| format!("numfmt: invalid field value: '{}'\n", args[i]))?; if opts.field == 0 { return Err("numfmt: invalid field value: '0'\n".to_string()); } diff --git a/crates/bashkit/src/builtins/paste.rs b/crates/bashkit/src/builtins/paste.rs index 4445f871a..b77c6862d 100644 --- a/crates/bashkit/src/builtins/paste.rs +++ b/crates/bashkit/src/builtins/paste.rs @@ -160,7 +160,7 @@ impl Builtin for Paste { }; let text = match read_text_file(&*ctx.fs, &path, "paste").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; inputs.sources.push(Source::Lines(records(&text, sep), 0)); } diff --git a/crates/bashkit/src/builtins/rg/mod.rs b/crates/bashkit/src/builtins/rg/mod.rs index 7ce1af466..bfc1118f7 100644 --- a/crates/bashkit/src/builtins/rg/mod.rs +++ b/crates/bashkit/src/builtins/rg/mod.rs @@ -2996,7 +2996,7 @@ async fn read_rg_text_file( cwd: &Path, display_path: &str, opts: &RgOptions, -) -> std::result::Result { +) -> std::result::Result> { let content = fs.read_file(path).await.map_err(|e| { let reason = crate::error::io_error_reason(&e); ExecResult::err(format!("rg: {display_path}: {reason}\n"), 1) @@ -3015,7 +3015,7 @@ async fn collect_rg_inputs( opts: &RgOptions, budget: &mut RgReadBudget, out: &mut RgSearch<'_>, -) -> std::result::Result<(), ExecResult> { +) -> std::result::Result<(), Box> { if opts.paths.is_empty() { if !opts.stdin_consumed_for_patterns && let Some(stdin) = ctx.stdin @@ -3174,7 +3174,7 @@ async fn load_rg_pattern_files( cwd: &Path, stdin: Option<&str>, opts: &mut RgOptions, -) -> std::result::Result<(), ExecResult> { +) -> std::result::Result<(), Box> { for pattern_file in opts.pattern_files.clone() { let content = if pattern_file == "-" { opts.stdin_consumed_for_patterns = true; @@ -3194,7 +3194,7 @@ async fn load_rg_ignore_files( fs: &dyn crate::fs::FileSystem, cwd: &Path, opts: &mut RgOptions, -) -> std::result::Result<(), ExecResult> { +) -> std::result::Result<(), Box> { if opts.no_ignore_files { return Ok(()); } @@ -3204,13 +3204,13 @@ async fn load_rg_ignore_files( let content = match read_rg_ignore_file(fs, &path, None).await { Ok(content) => content, Err(Error::Execution(message)) if message.starts_with("rg: ignore file") => { - return Err(ExecResult::err(format!("{message}\n"), 2)); + return Err(Box::new(ExecResult::err(format!("{message}\n"), 2))); } Err(err) => { - return Err(ExecResult::err( + return Err(Box::new(ExecResult::err( format!("rg: {}: {err}\n", path.display()), 1, - )); + ))); } }; let content = String::from_utf8_lossy(&content); @@ -5678,7 +5678,7 @@ impl Builtin for Rg { let output_limit = rg_output_limit(&ctx); load_rg_global_ignore_files(&*ctx.fs, ctx.env, &mut opts).await?; if let Err(result) = load_rg_ignore_files(&*ctx.fs, ctx.cwd, &mut opts).await { - return Ok(result); + return Ok(*result); } if opts.list_files { let files = collect_rg_file_list(&*ctx.fs, &opts, ctx.cwd).await; @@ -5724,7 +5724,7 @@ impl Builtin for Rg { ) .await { - return Ok(result); + return Ok(*result); } if opts.patterns.is_empty() { return Ok(ExecResult::with_code(String::new(), 1)); @@ -5774,7 +5774,7 @@ impl Builtin for Rg { done: None, }; if let Err(result) = collect_rg_inputs(ctx, &opts, &mut read_budget, &mut search).await { - return Ok(result); + return Ok(*result); } if let Some(result) = search.done { return Ok(result); diff --git a/crates/bashkit/src/builtins/shuf.rs b/crates/bashkit/src/builtins/shuf.rs index efb489aca..c3d54bd2d 100644 --- a/crates/bashkit/src/builtins/shuf.rs +++ b/crates/bashkit/src/builtins/shuf.rs @@ -101,7 +101,7 @@ impl Builtin for Shuf { }; match read_text_file(&*ctx.fs, Path::new(&path), "shuf").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), } } }; diff --git a/crates/bashkit/src/builtins/sortuniq.rs b/crates/bashkit/src/builtins/sortuniq.rs index 352cbaf98..c1d03fc1c 100644 --- a/crates/bashkit/src/builtins/sortuniq.rs +++ b/crates/bashkit/src/builtins/sortuniq.rs @@ -995,7 +995,7 @@ impl Builtin for Sort { Ok(t) => t, Err(mut e) => { e.exit_code = 2; - return Ok(e); + return Ok(*e); } } }; @@ -1282,7 +1282,7 @@ impl Builtin for Uniq { }; match read_text_file(&*ctx.fs, &path, "uniq").await { Ok(text) => text, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), } } }; diff --git a/crates/bashkit/src/builtins/sqlite/dot_commands.rs b/crates/bashkit/src/builtins/sqlite/dot_commands.rs index 033cd9cd2..78abd1691 100644 --- a/crates/bashkit/src/builtins/sqlite/dot_commands.rs +++ b/crates/bashkit/src/builtins/sqlite/dot_commands.rs @@ -9,7 +9,7 @@ //! | `.quit`/`.exit` | End execution. | //! | `.tables` | List tables in the main schema. | //! | `.schema [t]` | Print CREATE TABLE statements (optional table filter). | -//! | `.headers on|off` | Toggle column headers. | +//! | `.headers on\|off` | Toggle column headers. | //! | `.mode ` | Switch output mode (list/csv/tabs/line/box/json/markdown/column). | //! | `.separator ` | Set the field separator for list/csv modes. | //! | `.nullvalue ` | Set the placeholder for NULL values. | diff --git a/crates/bashkit/src/builtins/template.rs b/crates/bashkit/src/builtins/template.rs index 05312d439..d6c896c6f 100644 --- a/crates/bashkit/src/builtins/template.rs +++ b/crates/bashkit/src/builtins/template.rs @@ -292,7 +292,7 @@ impl Builtin for Template { let path = resolve_path(ctx.cwd, data_path); let text = match read_text_file(&*ctx.fs, &path, "template").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; match serde_json::from_str::(&text) { Ok(v) => v, @@ -312,7 +312,7 @@ impl Builtin for Template { let path = resolve_path(ctx.cwd, tpl_path); match read_text_file(&*ctx.fs, &path, "template").await { Ok(t) => t, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), } } else if let Some(stdin) = ctx.stdin { stdin.to_string() diff --git a/crates/bashkit/src/builtins/textrev.rs b/crates/bashkit/src/builtins/textrev.rs index 949db9f19..0571b2379 100644 --- a/crates/bashkit/src/builtins/textrev.rs +++ b/crates/bashkit/src/builtins/textrev.rs @@ -15,14 +15,14 @@ use crate::fs::vfs_join; use crate::interpreter::ExecResult; /// Read input from files or stdin, returning the raw text. Used by `rev`. -async fn read_input(ctx: &Context<'_>) -> std::result::Result { +async fn read_input(ctx: &Context<'_>) -> std::result::Result> { let mut files: Vec<&str> = Vec::new(); for arg in ctx.args { if !arg.starts_with('-') { files.push(arg); } else if arg.len() > 1 && arg != "--" { // rev takes no options → reject unknown option-shaped tokens (exits 1). - return Err(super::invalid_option("rev", arg, 1)); + return Err(Box::new(super::invalid_option("rev", arg, 1))); } } @@ -116,7 +116,7 @@ impl Builtin for Tac { for file in &files { let raw = match read_tac_file(&ctx, file).await { Ok(r) => r, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; reverse_records(&raw, &sep, before, &mut out); } @@ -146,7 +146,10 @@ impl TacSep { } } -async fn read_tac_file(ctx: &Context<'_>, file: &str) -> std::result::Result { +async fn read_tac_file( + ctx: &Context<'_>, + file: &str, +) -> std::result::Result> { if file == "-" { return Ok(ctx.stdin.map(ToString::to_string).unwrap_or_default()); } @@ -188,7 +191,7 @@ impl Builtin for Rev { } let raw = match read_input(&ctx).await { Ok(r) => r, - Err(e) => return Ok(e), + Err(e) => return Ok(*e), }; if raw.is_empty() { diff --git a/crates/bashkit/src/builtins/wc.rs b/crates/bashkit/src/builtins/wc.rs index 536c042c6..7801558f1 100644 --- a/crates/bashkit/src/builtins/wc.rs +++ b/crates/bashkit/src/builtins/wc.rs @@ -156,7 +156,7 @@ impl Builtin for Wc { Ok(data) => { counted.push((count_data(data.as_bytes()), regular && *file != "-")) } - Err(e) => return Ok(e), + Err(e) => return Ok(*e), } } let width = number_width(&counted, flags.active_count()); diff --git a/crates/bashkit/src/builtins/yq.rs b/crates/bashkit/src/builtins/yq.rs index eb633fd20..862c0ec5c 100644 --- a/crates/bashkit/src/builtins/yq.rs +++ b/crates/bashkit/src/builtins/yq.rs @@ -105,7 +105,7 @@ impl Builtin for Yq { let path = resolve_path(ctx.cwd, file); let input = match read_text_file(ctx.fs.as_ref(), &path, "yq").await { Ok(input) => input, - Err(error) => return Ok(error), + Err(error) => return Ok(*error), }; ctx.consume_budget_input(input.len())?; match parse_documents(&input, args.input, Some(file)) { diff --git a/crates/bashkit/src/execution.rs b/crates/bashkit/src/execution.rs index 7d9307f2f..e610aa192 100644 --- a/crates/bashkit/src/execution.rs +++ b/crates/bashkit/src/execution.rs @@ -139,7 +139,7 @@ impl OutputFile { } let Ok(start) = self .written - .fetch_update(Ordering::Relaxed, Ordering::Relaxed, |w| { + .try_update(Ordering::Relaxed, Ordering::Relaxed, |w| { (w < self.max_bytes).then(|| w + chunk.len().min(self.max_bytes - w)) }) else { diff --git a/crates/bashkit/src/fs/overlay.rs b/crates/bashkit/src/fs/overlay.rs index 16affd6c0..fb4e33a82 100644 --- a/crates/bashkit/src/fs/overlay.rs +++ b/crates/bashkit/src/fs/overlay.rs @@ -2164,7 +2164,6 @@ mod tests { /// tests construct `OverlayFs` directly and never touch `Bash`, so /// they belong with the type they exercise. mod path_validation { - use super::super::*; use super::*; fn make_overlay() -> OverlayFs { diff --git a/crates/bashkit/src/interpreter/declare.rs b/crates/bashkit/src/interpreter/declare.rs index 75722fae0..d0932f0a9 100644 --- a/crates/bashkit/src/interpreter/declare.rs +++ b/crates/bashkit/src/interpreter/declare.rs @@ -295,10 +295,8 @@ pub(super) fn split_keyed_word(word: &Word) -> Option<(Word, Word, bool)> { let rest = &s[ci + 1..]; let (append, value_head) = if let Some(v) = rest.strip_prefix("+=") { (true, v) - } else if let Some(v) = rest.strip_prefix('=') { - (false, v) } else { - return None; + (false, rest.strip_prefix('=')?) }; let key_head = if pi == 0 { &s[1..ci] } else { &s[..ci] }; let mut key_parts = Vec::new(); diff --git a/crates/bashkit/src/interpreter/jobs.rs b/crates/bashkit/src/interpreter/jobs.rs index efdac057b..564ad28db 100644 --- a/crates/bashkit/src/interpreter/jobs.rs +++ b/crates/bashkit/src/interpreter/jobs.rs @@ -379,7 +379,7 @@ impl JobControl { /// or cancellation; nested pipelines and background jobs share this cap. pub(crate) fn try_claim_many(&self, max: usize, count: usize) -> Option { self.live - .fetch_update(AtomicOrdering::AcqRel, AtomicOrdering::Acquire, |n| { + .try_update(AtomicOrdering::AcqRel, AtomicOrdering::Acquire, |n| { n.checked_add(count).filter(|next| *next <= max) }) .ok() diff --git a/crates/bashkit/src/interpreter/mod.rs b/crates/bashkit/src/interpreter/mod.rs index 1d132c595..d4071e7fc 100644 --- a/crates/bashkit/src/interpreter/mod.rs +++ b/crates/bashkit/src/interpreter/mod.rs @@ -2479,7 +2479,7 @@ impl Interpreter { // Initialize default shell variables let mut variables = HashMap::new(); - variables.insert("HOME".to_string(), format!("/home/{}", &username_val)); + variables.insert("HOME".to_string(), format!("/home/{}", username_val)); variables.insert("USER".to_string(), username_val.clone()); variables.insert("UID".to_string(), "1000".to_string()); variables.insert("EUID".to_string(), "1000".to_string()); @@ -10760,7 +10760,7 @@ impl Interpreter { // file, so `./missing 2>/dev/null` reports nothing. let raw = match self.read_executable(name, &path).await { Ok(raw) => raw, - Err(failed) => return self.redirect_result(failed, redirects).await, + Err(failed) => return self.redirect_result(*failed, redirects).await, }; // A root-filesystem stub (`/usr/bin/env`) runs the builtin it names; // `/bin/bash` starts a child shell as `bash` does. @@ -10799,7 +10799,7 @@ impl Interpreter { &self, name: &str, path: &Path, - ) -> std::result::Result, ExecResult> { + ) -> std::result::Result, Box> { let missing = || { ExecResult::err( self.diag(format!("{name}: No such file or directory\n")), @@ -10809,25 +10809,25 @@ impl Interpreter { // A component past NAME_MAX fails before any lookup (execve's // ENAMETOOLONG), which bash reports as status 126. if path.components().any(|c| c.as_os_str().len() > 255) { - return Err(ExecResult::err( + return Err(Box::new(ExecResult::err( self.diag(format!("{name}: File name too long\n")), 126, - )); + ))); } let meta = self.fs.stat(path).await.map_err(|_| missing())?; if meta.file_type.is_dir() { - return Err(ExecResult::err( + return Err(Box::new(ExecResult::err( self.diag(format!("{name}: Is a directory\n")), 126, - )); + ))); } if meta.mode & 0o111 == 0 { - return Err(ExecResult::err( + return Err(Box::new(ExecResult::err( self.diag(format!("{name}: Permission denied\n")), 126, - )); + ))); } - self.fs.read_file(path).await.map_err(|_| missing()) + Ok(self.fs.read_file(path).await.map_err(|_| missing())?) } /// Search $PATH for an executable script and run it. @@ -10940,7 +10940,7 @@ impl Interpreter { let resolved = self.resolve_path(&found); let raw = match self.read_executable(&found, &resolved).await { Ok(raw) => raw, - Err(failed) => return self.redirect_result(failed, redirects).await.map(Some), + Err(failed) => return self.redirect_result(*failed, redirects).await.map(Some), }; // A root-filesystem stub (`/usr/bin/env`) runs the builtin it names; // `/bin/bash` starts a child shell as `bash` does. diff --git a/crates/bashkit/src/logging_impl.rs b/crates/bashkit/src/logging_impl.rs index e0ae829d8..23c5fb048 100644 --- a/crates/bashkit/src/logging_impl.rs +++ b/crates/bashkit/src/logging_impl.rs @@ -281,11 +281,7 @@ fn is_likely_secret(value: &str) -> bool { } // High entropy detection for longer strings (likely random secrets) - if trimmed.len() >= 32 && is_high_entropy(trimmed) { - return true; - } - - false + trimmed.len() >= 32 && is_high_entropy(trimmed) } /// Check if string looks like base64 diff --git a/crates/bashkit/src/snapshot/objects.rs b/crates/bashkit/src/snapshot/objects.rs index 161ccb35c..61ccab352 100644 --- a/crates/bashkit/src/snapshot/objects.rs +++ b/crates/bashkit/src/snapshot/objects.rs @@ -107,7 +107,7 @@ impl ObjectId { return Err(malformed("object id must be 64 hex characters")); } let mut out = [0u8; 32]; - for (byte, pair) in out.iter_mut().zip(bytes.chunks_exact(2)) { + for (byte, pair) in out.iter_mut().zip(bytes.as_chunks::<2>().0.iter()) { let (hi, lo) = (hex_nibble(pair[0])?, hex_nibble(pair[1])?); *byte = (hi << 4) | lo; } diff --git a/crates/bashkit/src/testing.rs b/crates/bashkit/src/testing.rs index a795793ca..cfca3e742 100644 --- a/crates/bashkit/src/testing.rs +++ b/crates/bashkit/src/testing.rs @@ -400,10 +400,7 @@ fn is_clap_error_chrome_line(line: &str) -> bool { } // `For more information, try '--help'.` / // `For more information, try ' --help'.` - if line.starts_with("For more information, try '") && line.ends_with("'.") { - return true; - } - false + line.starts_with("For more information, try '") && line.ends_with("'.") } /// Full fuzz-invariant check. Like [`assert_no_leak`] but tolerates diff --git a/crates/bashkit/tests/integration/partial_parse_tests.rs b/crates/bashkit/tests/integration/partial_parse_tests.rs index b5b9f4e09..16e1f10b0 100644 --- a/crates/bashkit/tests/integration/partial_parse_tests.rs +++ b/crates/bashkit/tests/integration/partial_parse_tests.rs @@ -125,7 +125,7 @@ async fn small_child_syntax_reports_match_bash() { j += 1; } if j > i + 5 { - out.splice(i + 5..j, [b'#']); + out.splice(i + 5..j, *b"#"); } } i += 1; diff --git a/crates/bashkit/tests/realfs_tests.rs b/crates/bashkit/tests/realfs_tests.rs index 981e4fe62..1ba26db50 100644 --- a/crates/bashkit/tests/realfs_tests.rs +++ b/crates/bashkit/tests/realfs_tests.rs @@ -1322,7 +1322,7 @@ async fn realfs_chmod_drops_special_bits() { use std::os::unix::fs::PermissionsExt; let dir = tempfile::tempdir().unwrap(); std::fs::write(dir.path().join("tool"), b"#!/bin/sh\n").unwrap(); - let mut bash = Bash::builder() + let mut bash = builder_allowing_host_paths(&[dir.path()]) .mount_real_readwrite_at(dir.path(), "/mnt/host") .build(); let r = bash @@ -1347,7 +1347,7 @@ async fn realfs_copy_drops_special_bits() { let src = dir.path().join("tool"); std::fs::write(&src, b"#!/bin/sh\n").unwrap(); std::fs::set_permissions(&src, std::fs::Permissions::from_mode(0o4755)).unwrap(); - let mut bash = Bash::builder() + let mut bash = builder_allowing_host_paths(&[dir.path()]) .mount_real_readwrite_at(dir.path(), "/mnt/host") .build(); let r = bash.exec("cp /mnt/host/tool /mnt/host/copy").await.unwrap(); @@ -1367,7 +1367,7 @@ async fn root_real_mount_keeps_filesystem_limits() { let dir = tempfile::tempdir().unwrap(); std::fs::write(dir.path().join("marker"), b"mounted\n").unwrap(); let limits = bashkit::FsLimits::new().max_file_size(1024); - let builder = Bash::builder().filesystem_limits(limits); + let builder = builder_allowing_host_paths(&[dir.path()]).filesystem_limits(limits); let mut bash = if readwrite { builder.mount_real_readwrite(dir.path()) } else { diff --git a/knowledge/operations/testing.md b/knowledge/operations/testing.md index 6c960e1bd..beaec0942 100644 --- a/knowledge/operations/testing.md +++ b/knowledge/operations/testing.md @@ -26,6 +26,41 @@ Multi-layer testing strategy: For current test counts and pass rates, see CI (`spec_tests::bash_spec_tests`). For run commands, see AGENTS.md "Local Dev" and `.github/workflows/ci.yml`. +## Rust toolchain and consumer compatibility + +Development and build workflows pin Rust 1.100.0. The toolchain pin does not +change the compiler selected by an application depending on Bashkit. Keep +compiler upgrades separate from dependency or runtime upgrades. + +The required `msrv` CI job resolves a fresh external consumer on Rust 1.96.0, +without borrowing this repository's Cargo.lock. It runs lean/default smoke +programs, checks all native features, and checks the supported browser/WASI +feature sets, including slim browser runtime features and custom-backend +non-JS compilation. These path consumers test checkout sources, not published +crate contents; publication validation remains in the release workflow. Run `python3 scripts/check-msrv-consumer.py --profile default` +locally; profiles are `lean`, `default`, `all`, `wasm`, `wasi`, `browser`, and `component`. +Fresh consumer resolution is a compatibility probe, not a supply-chain audit. +It may execute build scripts from newer registry versions outside the workspace +Cargo.lock audit set. Keep these jobs on disposable hosted runners, with read-only +repository permissions, no persisted checkout credentials, no project secrets, +and no publication artifacts. Workspace `cargo vet --locked` and release/package +checks retain their separate locked-dependency trust boundary. Do not promote a +consumer-generated lockfile or cache into a release build. + +The optional-runtime profile is compile-only to avoid linking all interpreters +at once. Runtime/packaging suites remain separate and run on the development +compiler; the consumer check is not a replacement for those suites. + +Internal file-reading helpers box shell-result errors to keep the large diagnostic +payload off their success paths; command boundaries unwrap the original result, +preserving exit status, output, and control state. Compiler upgrades must not +suppress lints or change shell behavior to pass the new compiler. + +Use distinct Cargo target directories for 1.96 and 1.100. Cargo 1.100 changes +intermediate-artifact layout; scripts must not depend on internal build/deps +paths. The consumer's own lockfile is used after fresh resolution, so this +check catches dependency-floor drift hidden by the workspace's locked graph. + ## Spec Test Framework ### Test File Format diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e35ac2f8f..d7654c4a7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] # Pinned to avoid same-day rustc releases breaking CI; bump deliberately # (also bump dtolnay/rust-toolchain@ refs in .github/workflows/*). -channel = "1.96.0" +channel = "1.100.0" components = ["rustfmt", "clippy"] diff --git a/scripts/check-msrv-consumer.py b/scripts/check-msrv-consumer.py new file mode 100644 index 000000000..8660cf844 --- /dev/null +++ b/scripts/check-msrv-consumer.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +"""Compile an independent Bashkit consumer without the repository lockfile. + +The development toolchain must not silently become the consumer minimum. +Resolve afresh, then use that consumer's lockfile for compilation/execution. +This is not a supply-chain audit: run without project secrets or write tokens. +Fresh registry dependencies may execute build scripts outside the workspace vet set. +""" +import argparse +import json +import os +from pathlib import Path +import subprocess +import tempfile +import tomllib + + +def manifest(repo, profile): + features = [] + defaults = profile not in ("lean", "browser", "component") + if profile == "all": + features = sorted(tomllib.loads((repo / "crates/bashkit/Cargo.toml").read_text())["features"]) + elif profile == "wasm": + features = ["jq", "terminal", "wasm_js"] + elif profile == "browser": + features = ["jq", "terminal", "wasm_js", "python", "typescript"] + elif profile == "component": + features = ["jq"] + elif profile == "wasi": + features = ["jq", "terminal"] + extra = 'getrandom03 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }\n' if profile == "browser" else "" + return f'''[package] +name = "bashkit-msrv-consumer" +version = "0.0.0" +edition = "2024" +rust-version = "1.96" +[dependencies] +bashkit = {{ path = {json.dumps(str(repo / 'crates/bashkit'))}, default-features = {str(defaults).lower()}, features = {json.dumps(features)} }} +tokio = {{ version = "1", features = ["rt", "macros"] }} +{extra}''' + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--toolchain", default="1.96.0") + parser.add_argument("--profile", choices=["lean", "default", "all", "wasm", "wasi", "browser", "component"], default="default") + args = parser.parse_args() + repo = Path(__file__).resolve().parents[1] + with tempfile.TemporaryDirectory(prefix="bashkit-consumer-") as tmp: + root = Path(tmp) + (root / "src").mkdir() + (root / "Cargo.toml").write_text(manifest(repo, args.profile)) + (root / "src/main.rs").write_text('''#[tokio::main(flavor = "current_thread")] +async fn main() { + let mut bash = bashkit::Bash::new(); + let result = bash.exec("printf '%s\\\\n' compatible").await.unwrap(); + assert_eq!(result.stdout, "compatible\\n"); + assert_eq!(result.exit_code, 0); +} +''') + env = os.environ.copy() + env["CARGO_TARGET_DIR"] = env.get("BASHKIT_CONSUMER_TARGET_DIR", str(repo / "target" / f"consumer-{args.toolchain}")) + cargo = ["cargo", f"+{args.toolchain}"] + subprocess.run(cargo + ["generate-lockfile"], cwd=root, env=env, check=True) + if args.profile in ("wasm", "wasi", "browser", "component"): + target = "wasm32-unknown-unknown" if args.profile != "wasi" else "wasm32-wasip2" + if args.profile in ("wasm", "browser"): + env["RUSTFLAGS"] = env.get("RUSTFLAGS", "") + ' --cfg getrandom_backend="wasm_js"' + elif args.profile == "component": + env["RUSTFLAGS"] = env.get("RUSTFLAGS", "") + ' --cfg getrandom_backend="custom"' + command = ["check", "--target", target] + elif args.profile == "all": + # Check optional runtime combinations without linking every interpreter. + command = ["check"] + else: + command = ["run"] + subprocess.run(cargo + command + ["--locked"], cwd=root, env=env, check=True) + + +if __name__ == "__main__": + main() diff --git a/scripts/tests/test_msrv_consumer.py b/scripts/tests/test_msrv_consumer.py new file mode 100644 index 000000000..945cb9ebd --- /dev/null +++ b/scripts/tests/test_msrv_consumer.py @@ -0,0 +1,77 @@ +"""Guard the independent consumer/MSRV test, not just the workspace build.""" +import importlib.util +from pathlib import Path +import tomllib +import unittest +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parents[2] +SPEC = importlib.util.spec_from_file_location("msrv", ROOT / "scripts/check-msrv-consumer.py") +MODULE = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(MODULE) + + +class MsrvConsumerTest(unittest.TestCase): + def test_feature_profiles(self): + for profile in ["lean", "default", "all", "wasm", "wasi", "browser", "component"]: + with self.subTest(profile=profile): + doc = tomllib.loads(MODULE.manifest(ROOT, profile)) + self.assertEqual(doc["package"]["rust-version"], "1.96") + dep = doc["dependencies"]["bashkit"] + self.assertEqual(dep["default-features"], profile not in ("lean", "browser", "component")) + self.assertEqual(Path(dep["path"]), ROOT / "crates/bashkit") + self.assertEqual("wasm_js" in dep["features"], profile in ("all", "wasm", "browser")) + features = tomllib.loads(MODULE.manifest(ROOT, "all"))["dependencies"]["bashkit"]["features"] + actual = tomllib.loads((ROOT / "crates/bashkit/Cargo.toml").read_text())["features"] + self.assertEqual(set(features), set(actual)) + + def test_profile_commands_and_randomness_backends(self): + for profile in ["lean", "default", "all", "wasm", "wasi", "browser", "component"]: + with self.subTest(profile=profile): + calls = [] + + def run(command, *, cwd, env, check): + calls.append((command, env.copy())) + + with patch("sys.argv", ["check-msrv-consumer.py", "--profile", profile]), patch.object(MODULE.subprocess, "run", side_effect=run): + MODULE.main() + command, env = calls[-1] + self.assertEqual(command[-1], "--locked") + if profile in ("lean", "default"): + self.assertIn("run", command) + else: + self.assertIn("check", command) + if profile in ("wasm", "browser", "component"): + self.assertIn("wasm32-unknown-unknown", command) + elif profile == "wasi": + self.assertIn("wasm32-wasip2", command) + else: + self.assertNotIn("--target", command) + if profile in ("wasm", "browser"): + self.assertIn('getrandom_backend="wasm_js"', env["RUSTFLAGS"]) + elif profile == "component": + self.assertIn('getrandom_backend="custom"', env["RUSTFLAGS"]) + + def test_resolution_is_outside_workspace_without_repository_lockfile(self): + calls = [] + + def run(command, *, cwd, env, check): + calls.append(command) + self.assertNotIn(ROOT, cwd.parents) + self.assertTrue(check) + self.assertTrue((cwd / "src/main.rs").is_file()) + if command[-1] == "generate-lockfile": + self.assertFalse((cwd / "Cargo.lock").exists()) + (cwd / "Cargo.lock").write_text("# independently generated") + else: + self.assertEqual(command[-1], "--locked") + self.assertTrue((cwd / "Cargo.lock").is_file()) + + with patch("sys.argv", ["check-msrv-consumer.py"]), patch.object(MODULE.subprocess, "run", side_effect=run): + MODULE.main() + self.assertEqual(calls[0], ["cargo", "+1.96.0", "generate-lockfile"]) + self.assertEqual(calls[1], ["cargo", "+1.96.0", "run", "--locked"]) + + +if __name__ == "__main__": + unittest.main()