Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule information during integration testing #393

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e4d7772
printing out rules to the console
Soph1514 Oct 30, 2024
fb56220
Merge branch 'conjure-cp:main' into tracing
Soph1514 Oct 30, 2024
a2d0f77
added a function to write the rules into a file for a specific test
Soph1514 Oct 30, 2024
46f7c04
Merge remote-tracking branch 'refs/remotes/origin/tracing' into tracing
Soph1514 Oct 30, 2024
822309a
throwing a bug! if there are more than 1 rule that can be applied to …
Soph1514 Oct 31, 2024
3a68906
removing bug! from choose_rewrite to put in an separate pr
Soph1514 Oct 31, 2024
b75b24c
implemented bug! when multiple rules can be applied to an expression
Soph1514 Nov 1, 2024
7682231
Activated the trace from apply_all_rules
Soph1514 Nov 3, 2024
555c69f
Merge branch 'tracing'
Soph1514 Nov 3, 2024
951d928
git struggles
Soph1514 Nov 3, 2024
fff3b94
removed spam name from log
a-nosnitram Nov 3, 2024
b02b5eb
removing changes from rule_checking branch from tracing branch
Soph1514 Nov 4, 2024
a9e5cd7
Merge branch 'main' into tracing
Soph1514 Nov 4, 2024
766dbff
function to trace rules that were applied an an expression
Soph1514 Nov 4, 2024
b7ce7d5
Merge branch 'tracing' of https://github.com/Soph1514/conjure-oxide i…
Soph1514 Nov 4, 2024
4631c13
two versions of rule trace files: expected and the generated
Soph1514 Nov 5, 2024
14f7215
json logging format
a-nosnitram Nov 13, 2024
3af5ead
deleted the TXT logs
a-nosnitram Nov 13, 2024
166d25c
added expected rule trace
a-nosnitram Nov 13, 2024
8e6c7c7
removed application from log
a-nosnitram Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions conjure_oxide/src/utils/testing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::collections::{HashMap, HashSet};
use std::fmt::Debug;
use std::fs;
use std::fs::File;
use std::hash::Hash;
use std::io::Write;
Expand Down Expand Up @@ -183,3 +184,14 @@ pub fn read_minion_solutions_json(

Ok(expected_solutions)
}

pub fn read_rule_trace(
path: &str,
test_name: &str,
prefix: &str,
) -> Result<String, std::io::Error> {
let file_path = format!("{path}/{test_name}.{prefix}-rule-trace.txt");
let contents = fs::read_to_string(file_path)?;

Ok(contents)
}
15 changes: 11 additions & 4 deletions conjure_oxide/tests/generated_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use conjure_oxide::utils::conjure::{
};
use conjure_oxide::utils::testing::save_stats_json;
use conjure_oxide::utils::testing::{
read_minion_solutions_json, read_model_json, save_minion_solutions_json, save_model_json,
read_minion_solutions_json, read_model_json, read_rule_trace, save_minion_solutions_json,
save_model_json,
};
use conjure_oxide::SolverFamily;
use serde::Deserialize;
Expand Down Expand Up @@ -170,6 +171,12 @@ fn integration_test_inner(
x => println!("Unrecognised extra assert: {}", x),
};
}
//checking if the rules applied deviate from the expected list and order
let expected_rule_trace = read_rule_trace(path, essence_base, "expected")?;
let generated_rule_trace = read_rule_trace(path, essence_base, "generated")?;

//the assertion does not work yet -> TODO create a json representation of the rules
//assert_eq!(expected_rule_trace, generated_rule_trace);

let expected_model = read_model_json(path, essence_base, "expected", "rewrite")?;
if verbose {
Expand Down Expand Up @@ -322,16 +329,16 @@ where
}
}

///Creates a thread specific subsriber with a target "rul_engine" that writes trace messages to a test-specific file
///Creates a thread specific subsriber with a target "rule_engine" that writes trace messages to a test-specific file
pub fn create_scoped_subscriber(
path: &str,
test_name: &str,
) -> (
impl tracing::Subscriber + Send + Sync,
tracing_appender::non_blocking::WorkerGuard,
) {
let file =
File::create(format!("{path}/{test_name}-rules.txt")).expect("Unable to create log file");
let file = File::create(format!("{path}/{test_name}.generated-rule-trace.txt"))
.expect("Unable to create log file");
let writer = BufWriter::new(file);
let (non_blocking, guard) = tracing_appender::non_blocking(writer);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x55fb910e6020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:76", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:76, fields: {message}, callsite: Identifier(0x55fb910e6020), kind: Kind(EVENT) }, parent: Current }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x557b0aba4020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:77", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:77, fields: {message}, callsite: Identifier(0x557b0aba4020), kind: Kind(EVENT) }, parent: Current }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callsite: ... might cause issues on different computers?

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x55fb910e6020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:76", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:76, fields: {message}, callsite: Identifier(0x55fb910e6020), kind: Kind(EVENT) }, parent: Current }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x555aa437c020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:77", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:77, fields: {message}, callsite: Identifier(0x555aa437c020), kind: Kind(EVENT) }, parent: Current }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x55fb910e6020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:76", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:76, fields: {message}, callsite: Identifier(0x55fb910e6020), kind: Kind(EVENT) }, parent: Current }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x55cdcd2f2020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:77", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:77, fields: {message}, callsite: Identifier(0x55cdcd2f2020), kind: Kind(EVENT) }, parent: Current }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x55fb910e6020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:76", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:76, fields: {message}, callsite: Identifier(0x55fb910e6020), kind: Kind(EVENT) }, parent: Current }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event { fields: ValueSet { message: trace test, callsite: Identifier(0x555aa437c020) }, metadata: Metadata { name: "event conjure_oxide/tests/generated_tests.rs:77", target: "rule_engine", level: Level(Trace), module_path: "generated_tests", location: conjure_oxide/tests/generated_tests.rs:77, fields: {message}, callsite: Identifier(0x555aa437c020), kind: Kind(EVENT) }, parent: Current }
Loading