diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5b2877083b..239094a0fb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,19 +104,18 @@ jobs: env: RUST_BACKTRACE: full name: Run rust tests - needs: lalrpop runs-on: ${{ matrix.os }} strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] fail-fast: false steps: + # for windows, always checkout files with their original lf line endings + - run: git config --global core.autocrlf false; git config --global core.eol lf - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable - name: Set up the Windows environment shell: bash @@ -153,15 +152,12 @@ jobs: exotic_targets: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Ensure compilation on various targets - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable with: @@ -217,7 +213,6 @@ jobs: snippets_cpython: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} - needs: lalrpop env: RUST_BACKTRACE: full name: Run snippets and cpython tests @@ -227,12 +222,11 @@ jobs: os: [macos-latest, ubuntu-latest, windows-latest] fail-fast: false steps: + - run: git config --global core.autocrlf false; git config --global core.eol lf - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable - uses: actions/setup-python@v2 @@ -281,51 +275,14 @@ jobs: run: | mkdir site-packages target/release/rustpython --install-pip ensurepip --user - - lalrpop: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} - name: Generate parser with lalrpop - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} - - name: Check if cached generated parser exists - id: generated_parser - uses: andstor/file-existence-action@v1 - with: - files: "compiler/parser/python.rs" - - if: runner.os == 'Windows' - name: Force python.lalrpop to be lf # actions@checkout ignore .gitattributes - run: | - set file compiler/parser/python.lalrpop; ((Get-Content $file) -join "`n") + "`n" | Set-Content -NoNewline $file - - name: Install lalrpop - if: steps.generated_parser.outputs.files_exists == 'false' - uses: baptiste0928/cargo-install@v1 - with: - crate: lalrpop - version: "0.19.8" - - name: Run lalrpop - if: steps.generated_parser.outputs.files_exists == 'false' - run: lalrpop compiler/parser/python.lalrpop - lint: name: Check Rust code with rustfmt and clippy - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy @@ -355,15 +312,12 @@ jobs: miri: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Run tests under miri - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@master with: toolchain: nightly @@ -377,15 +331,12 @@ jobs: wasm: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Check the WASM package and demo - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v1 - name: install wasm-pack @@ -426,15 +377,12 @@ jobs: wasm-wasi: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} name: Run snippets and cpython tests on wasm-wasi - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable with: target: wasm32-wasi diff --git a/.github/workflows/cron-ci.yaml b/.github/workflows/cron-ci.yaml index 453f4b8f64..5c6aa97e6d 100644 --- a/.github/workflows/cron-ci.yaml +++ b/.github/workflows/cron-ci.yaml @@ -11,15 +11,12 @@ env: jobs: codecov: name: Collect code coverage data - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable with: components: llvm-tools-preview @@ -62,15 +59,12 @@ jobs: testdata: name: Collect regression test data - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable - name: build rustpython run: cargo build --release --verbose @@ -97,15 +91,12 @@ jobs: whatsleft: name: Collect what is left data - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable - name: build rustpython run: cargo build --release --verbose @@ -135,15 +126,12 @@ jobs: benchmark: name: Collect benchmark data - needs: lalrpop runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} + - uses: actions/cache@v3 + with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" } + - run: cargo install lalrpop@0.19.8 - uses: dtolnay/rust-toolchain@stable - uses: actions/setup-python@v2 with: @@ -183,35 +171,3 @@ jobs: if git -c user.name="Github Actions" -c user.email="actions@github.com" commit -m "Update benchmark results"; then git push fi - - lalrpop: - name: Generate parser with lalrpop - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: Cache generated parser - uses: actions/cache@v2 - with: - path: compiler/parser/python.rs - key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }} - - name: Check if cached generated parser exists - id: generated_parser - uses: andstor/file-existence-action@v1 - with: - files: "compiler/parser/python.rs" - - if: runner.os == 'Windows' - name: Force python.lalrpop to be lf # actions@checkout ignore .gitattributes - run: | - set file compiler/parser/python.lalrpop; ((Get-Content $file) -join "`n") + "`n" | Set-Content -NoNewline $file - - name: Install lalrpop - if: steps.generated_parser.outputs.files_exists == 'false' - uses: baptiste0928/cargo-install@v1 - with: - crate: lalrpop - version: "0.19.8" - - name: Run lalrpop - if: steps.generated_parser.outputs.files_exists == 'false' - run: lalrpop compiler/parser/python.lalrpop diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py index 68da83dda2..f3dce104b8 100644 --- a/Lib/test/test_difflib.py +++ b/Lib/test/test_difflib.py @@ -244,10 +244,6 @@ def test_html_diff(self): with open(findfile('test_difflib_expect.html')) as fp: self.assertEqual(actual, fp.read()) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_html_diff = unittest.expectedFailure(test_html_diff) - def test_recursion_limit(self): # Check if the problem described in patch #1413711 exists. limit = sys.getrecursionlimit() diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index f06a120d3c..c1a9d6f43c 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -100,10 +100,6 @@ def test_issue1267(self): self.assertEqual(fp.readline(), '"""Tokenization help for Python programs.\n') - # TODO: RUSTPYTHON - if sys.platform == 'win32': - test_issue1267 = unittest.expectedFailure(test_issue1267) - def test_issue3594(self): temp_mod_name = 'test_imp_helper' sys.path.insert(0, '.') diff --git a/compiler/parser/build.rs b/compiler/parser/build.rs index 81c28f43be..7483dc084b 100644 --- a/compiler/parser/build.rs +++ b/compiler/parser/build.rs @@ -78,16 +78,30 @@ fn try_lalrpop(source: &str, target: &str) -> anyhow::Result<()> { }; #[cfg(feature = "lalrpop")] - lalrpop::process_root().unwrap_or_else(|e| { - println!("cargo:warning={_message}"); - panic!("running lalrpop failed. {e:?}"); - }); + { + lalrpop::process_root().unwrap_or_else(|e| { + println!("cargo:warning={_message}"); + panic!("running lalrpop failed. {e:?}"); + }); + Ok(()) + } #[cfg(not(feature = "lalrpop"))] { - println!("cargo:warning=try: cargo build --manifest-path=compiler/parser/Cargo.toml --features=lalrpop"); + match std::process::Command::new("lalrpop").arg(source).status() { + Ok(status) => { + if status.success() { + Ok(()) + } else { + Err(anyhow::anyhow!("running lalrpop failed: {status}")) + } + } + Err(_) => panic!( + "lalrpop not installed. try: cargo build \ + --manifest-path=compiler/parser/Cargo.toml --features=lalrpop" + ), + } } - Ok(()) } fn sha_equal(expected_sha3_str: &str, actual_sha3: &[u8; 32]) -> bool { diff --git a/compiler/parser/python.lalrpop b/compiler/parser/python.lalrpop index 224450e073..44d988206d 100644 --- a/compiler/parser/python.lalrpop +++ b/compiler/parser/python.lalrpop @@ -51,7 +51,7 @@ SimpleStatement: ast::Suite = { let mut statements = vec![s1]; statements.extend(s2.into_iter().map(|e| e.1)); statements - } + }, }; SmallStatement: ast::Stmt = { @@ -138,7 +138,7 @@ ExpressionStatement: ast::Stmt = { }; AssignSuffix: ast::Expr = { - "=" => e + "=" => e, }; TestListOrYieldExpr: ast::Expr = {