Skip to content

Commit

Permalink
fix: Ensure stack does not overflow on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
James-LG committed Feb 11, 2024
1 parent 7056a7a commit 1d3735f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ env:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

stack_overflow_tests:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust Nightly
run: rustup toolchain install nightly
- name: Build
run: cargo build
- name: Run tests
run: cargo test --test run_stack_overflow_tests -- --include-ignored --test-threads=1
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "skyscraper"
version = "0.6.0"
version = "0.6.1-beta.0"
authors = ["James La Novara-Gsell <james.lanovara.gsell@gmail.com>"]
edition = "2021"
description = "XPath for HTML web scraping"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ pub fn range_expr(input: &str) -> Res<&str, RangeExpr> {
(
next_input,
RangeExpr {
expr: res.0,
to_expr: res.1.map(|res| res.1),
expr: Box::new(res.0),
to_expr: res.1.map(|res| Box::new(res.1)),
},
)
})
}

#[derive(PartialEq, Debug, Clone)]
pub struct RangeExpr {
pub expr: AdditiveExpr,
pub to_expr: Option<AdditiveExpr>,
pub expr: Box<AdditiveExpr>,
pub to_expr: Option<Box<AdditiveExpr>>,
}

impl Display for RangeExpr {
Expand Down
2 changes: 1 addition & 1 deletion tests/stack_overflow_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The structs in this library are large enough that the recursive parsing of XPath
This has only ever been reproduced on Windows 10 and only when building a binary in debug mode.
Notably, this cannot be reproduced using an actual test, thus this mini project was created.

This project is run automatically during a `cargo test` of the main project by way of `run_stack_overflow_tests.rs`.
This project is tested by the main project by way of `tests/run_stack_overflow_tests.rs`.

A typical failure of this tests appears as follows:

Expand Down

0 comments on commit 1d3735f

Please sign in to comment.