Skip to content

Commit

Permalink
chore: Lock tracing crates to the same version via cargo patch block
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Jun 11, 2024
1 parent 4a16b92 commit 19957df
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
env:
RUST_LOG: debug
RUST_BACKTRACE: 1
- name: Run mock_server_logs test
run: cargo test -p pact_ffi returns_mock_server_logs -- --nocapture --include-ignored
working-directory: rust
env:
RUST_LOG: debug
RUST_BACKTRACE: 1
- name: Build Components
run: cargo build
working-directory: rust
Expand Down
6 changes: 3 additions & 3 deletions compatibility-suite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lazy_static = "1.4.0"
maplit = "1.0.2"
pact_models = { version = "~1.2.0" }
pact_matching = { version = "1.2.3", path = "../rust/pact_matching" }
pact_mock_server = { version = "1.2.8" }
pact_mock_server = { version = "1.2.9" }
pact_verifier = { version = "1.2.1", path = "../rust/pact_verifier" }
pact_consumer = { version = "1.2.0", path = "../rust/pact_consumer" }
pretty_assertions = "1.4.0"
Expand All @@ -26,8 +26,8 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.108"
sxd-document = "0.3.2"
tokio = { version = "1.33.0", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "tracing-log", "fmt"] }
tracing = "=0.1.40"
tracing-subscriber = { version = "=0.3.18", features = ["env-filter", "tracing-log", "fmt"] }
uuid = { version = "1.5.0", features = ["v4"] }

[[test]]
Expand Down
28 changes: 17 additions & 11 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ resolver = "2"
[patch.crates-io]
# Waiting on the next release of Onig crate
onig = { git = "https://github.com/rust-onig/rust-onig", default-features = false, rev = "76bc1d29651bd17c7d5ecea9266bd2e0e83cb2e0" }
# This needs to be the same version across all the libs (i.e. Pact FFI and plugin driver)
tracing = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" }
tracing-core = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" }
tracing-subscriber = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" }

[profile.release]
strip = true
Expand Down
32 changes: 31 additions & 1 deletion rust/pact_ffi/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use bytes::Bytes;
use expectest::prelude::*;
use itertools::Itertools;
use libc::c_char;
use log::LevelFilter;
use maplit::*;
use pact_ffi::log::pactffi_log_to_buffer;
use pact_models::bodies::OptionalBody;
use pact_models::PactSpecification;
use pretty_assertions::assert_eq;
Expand All @@ -26,7 +28,8 @@ use pact_ffi::mock_server::{
pactffi_create_mock_server,
pactffi_create_mock_server_for_pact,
pactffi_mock_server_mismatches,
pactffi_write_pact_file
pactffi_write_pact_file,
pactffi_mock_server_logs,
};
#[allow(deprecated)]
use pact_ffi::mock_server::handles::{
Expand Down Expand Up @@ -1406,3 +1409,30 @@ fn matching_definition_expressions_matcher() {
}
};
}

// Run independently as this log settings are global, and other tests affect this one.
// cargo test -p pact_ffi returns_mock_server_logs -- --nocapture --include-ignored
#[ignore]
#[test]
fn returns_mock_server_logs() {
let pact_json = include_str!("post-pact.json");
let pact_json_c = CString::new(pact_json).expect("Could not construct C string from json");
let address = CString::new("127.0.0.1:0").unwrap();
#[allow(deprecated)]
let port = pactffi_create_mock_server(pact_json_c.as_ptr(), address.as_ptr(), false);
expect!(port).to(be_greater_than(0));
pactffi_log_to_buffer(LevelFilter::Debug.into());
let client = Client::default();
client.post(format!("http://127.0.0.1:{}/path", port).as_str())
.header(CONTENT_TYPE, "application/json")
.body(r#"{"foo":"no-very-bar"}"#)
.send().expect("Sent POST request to mock server");

let logs = unsafe {
CStr::from_ptr(pactffi_mock_server_logs(port)).to_string_lossy().into_owned()
};
println!("{}",logs);
assert_ne!(logs,"", "logs are empty");

pactffi_cleanup_mock_server(port);
}
4 changes: 2 additions & 2 deletions rust/pact_models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ semver = "1.0.17"
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.96"
sxd-document = { version = "0.3.2", optional = true }
tracing = "0.1.37" # This needs to be the same version across all the libs (i.e. Pact FFI and plugin driver)
tracing = "0.1.40" # This needs to be the same version across all the libs (i.e. Pact FFI and plugin driver)

[target.'cfg(not(target_family = "wasm"))'.dependencies]
fs2 = "0.4.3"
Expand All @@ -64,7 +64,7 @@ pretty_assertions = "1.3.0"
rstest = "0.19.0"
speculate = "0.1.2"
test-log = { version = "0.2.11", features = ["trace"] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "tracing-log", "fmt"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "tracing-log", "fmt"] }
trim-margin = "0.1.0"

[build-dependencies]
Expand Down

0 comments on commit 19957df

Please sign in to comment.