Skip to content

Commit

Permalink
Run clippy in binding tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anand Krishnamoorthi <[email protected]>
  • Loading branch information
anakrish committed May 25, 2024
1 parent 862dbc8 commit 4f8c75f
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test-ffi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: bindings/c-cpp

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Test FFI
run: |
cargo build -r
cargo clippy --all-targets --no-deps -- -Dwarnings
working-directory: ./bindings/ffi
4 changes: 3 additions & 1 deletion .github/workflows/test-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
- uses: dtolnay/rust-toolchain@stable

- name: Building binding
run: cargo build --release --manifest-path bindings/java/Cargo.toml
run: |
cargo clippy --all-targets --no-deps -- -Dwarnings
cargo build --release --manifest-path bindings/java/Cargo.toml
- name: Build jar
run: mvn package
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:
run: |
pip3 install dist/regorus-*.whl
cd bindings/python
cargo clippy --all-targets --no-deps -- -Dwarnings
python3 test.py
1 change: 1 addition & 0 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
- name: Run ruby tests
run: |
cd bindings/ruby
cargo clippy --all-targets --no-deps -- -Dwarnings
bundle exec rake
1 change: 1 addition & 0 deletions .github/workflows/test-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- name: Test wasm binding
run: |
cd bindings/wasm
cargo clippy --all-targets --no-deps -- -Dwarnings
wasm-pack build --target nodejs --release
wasm-pack test --release --node
node test.js
2 changes: 1 addition & 1 deletion bindings/ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub extern "C" fn regorus_engine_clone(engine: *mut RegorusEngine) -> *mut Regor

#[no_mangle]
pub extern "C" fn regorus_engine_drop(engine: *mut RegorusEngine) {
if let Ok(ref mut e) = to_ref(&engine) {
if let Ok(e) = to_ref(&engine) {
unsafe {
let _ = Box::from_raw(e);
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl Engine {
serde_json::to_string_pretty(&report).map_err(|e| anyhow!("{e}"))
}

// Get coverage report as pretty printable string.
/// Get coverage report as pretty printable string.
///
pub fn get_coverage_report_pretty(&self) -> Result<String> {
self.engine.get_coverage_report()?.to_string_pretty()
Expand Down
13 changes: 8 additions & 5 deletions bindings/ruby/ext/regorusrb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Engine {
}

fn add_data_from_json_file(&self, path: String) -> Result<(), Error> {
let json_data = regorus::Value::from_json_file(&path).map_err(|e| {
let json_data = regorus::Value::from_json_file(path).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to parse JSON data file: {}", e),
Expand Down Expand Up @@ -112,7 +112,7 @@ impl Engine {
}

fn add_input_from_json_file(&self, path: String) -> Result<(), Error> {
let json_data = regorus::Value::from_json_file(&path).map_err(|e| {
let json_data = regorus::Value::from_json_file(path).map_err(|e| {
Error::new(
runtime_error(),
format!("Failed to parse JSON input file: {}", e),
Expand Down Expand Up @@ -193,7 +193,8 @@ impl Engine {
}

fn set_enable_coverage(&self, enable: bool) -> Result<(), Error> {
Ok(self.engine.borrow_mut().set_enable_coverage(enable))
self.engine.borrow_mut().set_enable_coverage(enable);
Ok(())
}

fn get_coverage_report_as_json(&self) -> Result<String, Error> {
Expand Down Expand Up @@ -237,12 +238,14 @@ impl Engine {
}

fn clear_coverage_data(&self) -> Result<(), Error> {
Ok(self.engine.borrow_mut().clear_coverage_data())
self.engine.borrow_mut().clear_coverage_data();
Ok(())
}

// Print statements can be gathered async instead of printing to stderr
fn set_gather_prints(&self, enable: bool) -> Result<(), Error> {
Ok(self.engine.borrow_mut().set_gather_prints(enable))
self.engine.borrow_mut().set_gather_prints(enable);
Ok(())
}

fn take_prints(&self) -> Result<Vec<String>, Error> {
Expand Down

0 comments on commit 4f8c75f

Please sign in to comment.