Skip to content

Commit

Permalink
re-apply 6fde964 (fix(tester): make human rule trace writer blocking,…
Browse files Browse the repository at this point in the history
… 2025-01-08)

PR #569 accidentally reverted this change, causing ACCEPT=true failures
on my Mac and some CI failures.
  • Loading branch information
niklasdewally committed Jan 20, 2025
1 parent 9befb7f commit 7e14ca6
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions conjure_oxide/tests/generated_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn integration_test(path: &str, essence_base: &str, extension: &str) -> Result<(
// run tests in sequence not parallel when verbose logging, to ensure the logs are ordered
// correctly

let (subscriber, _guards) = create_scoped_subscriber(path, essence_base);
let subscriber = create_scoped_subscriber(path, essence_base);

// set the subscriber as default
tracing::subscriber::with_default(subscriber, || {
Expand Down Expand Up @@ -392,20 +392,17 @@ fn assert_constants_leq_one(parent_expr: &Expression, exprs: &[Expression]) {
pub fn create_scoped_subscriber(
path: &str,
test_name: &str,
) -> (
impl tracing::Subscriber + Send + Sync,
Vec<tracing_appender::non_blocking::WorkerGuard>,
) {
let (target1_layer, guard1) = create_file_layer_json(path, test_name);
let (target2_layer, guard2) = create_file_layer_human(path, test_name);
let layered = target1_layer.and_then(target2_layer);
) -> (impl tracing::Subscriber + Send + Sync) {
//let (target1_layer, guard1) = create_file_layer_json(path, test_name);
let target2_layer = create_file_layer_human(path, test_name);
let layered = target2_layer;

let subscriber = Arc::new(tracing_subscriber::registry().with(layered))
as Arc<dyn tracing::Subscriber + Send + Sync>;
// setting this subscriber as the default
let _default = tracing::subscriber::set_default(subscriber.clone());

(subscriber, vec![guard1, guard2])
subscriber
}

fn create_file_layer_json(
Expand All @@ -428,24 +425,19 @@ fn create_file_layer_json(
(layer1, guard1)
}

fn create_file_layer_human(
path: &str,
test_name: &str,
) -> (impl Layer<Registry> + Send + Sync, WorkerGuard) {
fn create_file_layer_human(path: &str, test_name: &str) -> (impl Layer<Registry> + Send + Sync) {
let file = File::create(format!("{path}/{test_name}-generated-rule-trace-human.txt"))
.expect("Unable to create log file");

let (non_blocking, guard2) = tracing_appender::non_blocking(file);

let layer2 = fmt::layer()
.with_writer(non_blocking)
.with_writer(file)
.with_level(false)
.without_time()
.with_target(false)
.with_filter(EnvFilter::new("rule_engine_human=trace"))
.with_filter(FilterFn::new(|meta| meta.target() == "rule_engine_human"));

(layer2, guard2)
layer2
}

#[test]
Expand Down

0 comments on commit 7e14ca6

Please sign in to comment.