diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..5b3f606 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,30 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install latest stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: rustfmt, clippy + - name: Build + run: cargo build + - name: Fmt + run: cargo fmt --check + - name: Run tests + run: cargo test --examples diff --git a/examples/readme/main.rs b/examples/readme/main.rs index d3358b8..2e985c9 100644 --- a/examples/readme/main.rs +++ b/examples/readme/main.rs @@ -65,4 +65,3 @@ mod tests { test_each_file! { in "./examples/readme/duplicate_names/" => empty} } } - \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 7918d99..cfd1431 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,11 +209,16 @@ fn generate_from_tree( file.push("."); file.push(extension); let file: PathBuf = file.into(); - + // Canonicalize the file path let input = match file.canonicalize() { Ok(path) => path, - Err(e) => return Err(format!("Failed to read expected file {}.{extension}: {e}", file.display())), + Err(e) => { + return Err(format!( + "Failed to read expected file {}.{extension}: {e}", + file.display() + )) + } }; let input = input.to_str().unwrap();