Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/domain/checklist/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ mod check {
}

fn extract(source: &str) -> super::Document {
let path = Path::new("test.tq");
let path = Path::new("Test.tq");
let doc = parsing::parse(path, source).unwrap();
ChecklistAdapter.extract(&doc)
}
Expand Down
2 changes: 1 addition & 1 deletion src/domain/procedure/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ mod check {
}

fn extract(source: &str) -> super::Document {
let path = Path::new("test.tq");
let path = Path::new("Test.tq");
let doc = parsing::parse(path, source).unwrap();
ProcedureAdapter.extract(&doc)
}
Expand Down
2 changes: 1 addition & 1 deletion src/domain/recipe/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ mod check {
}

fn extract(source: &str) -> super::Document {
let path = Path::new("test.tq");
let path = Path::new("Test.tq");
let doc = parsing::parse(path, source).unwrap();
RecipeAdapter.extract(&doc)
}
Expand Down
17 changes: 10 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ fn main() {
};

match runner::start(filename, &program) {
Ok((id, Outcome::Quit)) => {
eprintln!("paused; resume with `technique resume {}`", id.render());
Ok((run_id, Outcome::Quit)) => {
eprintln!("paused; resume with `technique resume {}`", run_id.render());
std::process::exit(0);
}
Ok((_, _)) => std::process::exit(0),
Expand All @@ -580,15 +580,15 @@ fn main() {

debug!(id);

let id = match RunId::parse(id) {
Ok(id) => id,
let run_id = match RunId::parse(id) {
Ok(run_id) => run_id,
Err(error) => {
eprintln!("{}", problem::concise_runner_error(&error, &Terminal));
std::process::exit(1);
}
};

let filename = match runner::locate(id) {
let filename = match runner::locate(run_id) {
Ok(path) => path,
Err(error) => {
eprintln!("{}", problem::concise_runner_error(&error, &Terminal));
Expand Down Expand Up @@ -644,9 +644,12 @@ fn main() {
}
};

match runner::resume(id, &program) {
match runner::resume(run_id, &program) {
Ok(Outcome::Quit) => {
eprintln!("paused; continue with `technique resume {}`", id.render());
eprintln!(
"paused; continue with `technique resume {}`",
run_id.render()
);
std::process::exit(0);
}
Ok(_) => std::process::exit(0),
Expand Down
2 changes: 1 addition & 1 deletion src/parsing/checks/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::Path;

/// Helper function to check if parsing produces the expected error
fn expect_error(content: &str, expected: ParsingError) {
let result = parse_with_recovery(Path::new("test.tq"), content);
let result = parse_with_recovery(Path::new("Test.tq"), content);
match result {
Ok(_) => panic!(
"Expected parsing to fail, but it succeeded for input: {}",
Expand Down
2 changes: 1 addition & 1 deletion src/parsing/checks/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,7 @@ broken :
1. Step one
"#;

let result = parse_with_recovery(Path::new("test.tq"), content);
let result = parse_with_recovery(Path::new("Test.tq"), content);

// Check that we get an error about the invalid signature
match result {
Expand Down
14 changes: 7 additions & 7 deletions src/problem/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,21 +1055,21 @@ pub fn generate_translation_error<'i>(
/// is being evaluated by the runner.
pub fn generate_runner_error(error: &RunnerError, _renderer: &dyn Render) -> (String, String) {
match error {
RunnerError::NoSuchRun(id) => (
format!("No such run '{:06}'", id.0),
RunnerError::NoSuchRun(run_id) => (
format!("No such run '{:06}'", run_id.0),
"The directory for this run identifier was not found in the local state store.".to_string(),
),
RunnerError::StoreError { path, error } => (
format!("I/O error with local state store at {}", path.display()),
format!("{}", error),
),
RunnerError::MalformedRecord { run, .. } => (
format!("Malformed record for run '{:06}'", run.0),
RunnerError::MalformedRecord { run_id, .. } => (
format!("Malformed record for run '{:06}'", run_id.0),
"The PFFTT state file for this run could not be parsed.".to_string(),
),
RunnerError::ManifestMissing(id) => (
format!("Manifest missing in run '{:06}'", id.0),
"The state file is present but its first tablet (the manifest) is missing or malformed.".to_string(),
RunnerError::StartMissing(run_id) => (
format!("Start record missing in run '{:06}'", run_id.0),
"The state file is present but its first record (the Start event) is missing or malformed.".to_string(),
),
RunnerError::InvalidRunId(text) => (
format!("Invalid run identifier '{}'", text),
Expand Down
35 changes: 20 additions & 15 deletions src/runner/checks/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@ use crate::language::{Attribute, Identifier, Span};
use crate::runner::path::{PathSegment, QualifiedPath};

#[test]
fn empty_stack_renders_empty_string() {
fn empty_stack_renders_root() {
let stack = QualifiedPath::new();
assert_eq!(stack.render(), "");
assert_eq!(stack.render(), "/");
}

#[test]
fn single_section_renders_numeral() {
let mut stack = QualifiedPath::new();
stack.push(PathSegment::Section("I"));
assert_eq!(stack.render(), "I");
assert_eq!(stack.render(), "/I");
}

#[test]
fn section_then_step_joins_with_slash() {
let mut stack = QualifiedPath::new();
stack.push(PathSegment::Section("I"));
stack.push(PathSegment::DependentStep("2"));
assert_eq!(stack.render(), "I/2");
assert_eq!(stack.render(), "/I/2");
}

#[test]
fn dependent_substep_chain() {
let mut stack = QualifiedPath::new();
stack.push(PathSegment::DependentStep("2"));
stack.push(PathSegment::DependentStep("a"));
assert_eq!(stack.render(), "2/a");
assert_eq!(stack.render(), "/2/a");
}

#[test]
fn parallel_step_uses_dash_prefix() {
let mut stack = QualifiedPath::new();
stack.push(PathSegment::ParallelStep(3));
assert_eq!(stack.render(), "-3");
assert_eq!(stack.render(), "/-3");
}

#[test]
Expand All @@ -46,7 +46,7 @@ fn attribute_frame_composes_role_and_place() {
let mut stack = QualifiedPath::new();
stack.push(PathSegment::Attributes(&frame));
stack.push(PathSegment::DependentStep("a"));
assert_eq!(stack.render(), "@chef^kitchen/a");
assert_eq!(stack.render(), "/@chef^kitchen/a");
}

#[test]
Expand All @@ -61,7 +61,7 @@ fn nested_attribute_frames_each_contribute_a_segment() {
stack.push(PathSegment::Attributes(&outer));
stack.push(PathSegment::Attributes(&inner));
stack.push(PathSegment::DependentStep("a"));
assert_eq!(stack.render(), "2/@team/@chef^kitchen/a");
assert_eq!(stack.render(), "/2/@team/@chef^kitchen/a");
}

#[test]
Expand All @@ -72,7 +72,7 @@ fn reset_role() {
stack.push(PathSegment::DependentStep("1"));
stack.push(PathSegment::Attributes(&frame));
stack.push(PathSegment::DependentStep("a"));
assert_eq!(stack.render(), "1/a");
assert_eq!(stack.render(), "/1/a");

// A sibling Place attribute in the same frame still renders.
let frame = vec![
Expand All @@ -83,34 +83,39 @@ fn reset_role() {
stack.push(PathSegment::DependentStep("1"));
stack.push(PathSegment::Attributes(&frame));
stack.push(PathSegment::DependentStep("a"));
assert_eq!(stack.render(), "1/^kitchen/a");
assert_eq!(stack.render(), "/1/^kitchen/a");
}

#[test]
fn procedure_segment() {
// Single procedure: name becomes the prefix, joined to the rest with `:`.
// Procedure alone renders as `/name:`
let mut stack = QualifiedPath::new();
stack.push(PathSegment::Procedure("local_network"));
assert_eq!(stack.render(), "/local_network:");

// Procedure with a step: `/name:N`.
let mut stack = QualifiedPath::new();
stack.push(PathSegment::Procedure("make_coffee"));
stack.push(PathSegment::DependentStep("2"));
assert_eq!(stack.render(), "make_coffee:2");
assert_eq!(stack.render(), "/make_coffee:2");

// Nested procedure: the inner frame replaces the outer prefix entirely.
let mut stack = QualifiedPath::new();
stack.push(PathSegment::Procedure("outer"));
stack.push(PathSegment::DependentStep("1"));
stack.push(PathSegment::Procedure("inner"));
stack.push(PathSegment::DependentStep("2"));
assert_eq!(stack.render(), "inner:2");
assert_eq!(stack.render(), "/inner:2");
}

#[test]
fn full_qualified_example_from_objective() {
// 2/@barista/a/-1 — dependent step 2, role @barista, substep a, first parallel sub-substep
// /2/@barista/a/-1 — dependent step 2, role @barista, substep a, first parallel sub-substep
let frame = vec![Attribute::Role(Identifier::new("barista"), Span::default())];
let mut stack = QualifiedPath::new();
stack.push(PathSegment::DependentStep("2"));
stack.push(PathSegment::Attributes(&frame));
stack.push(PathSegment::DependentStep("a"));
stack.push(PathSegment::ParallelStep(1));
assert_eq!(stack.render(), "2/@barista/a/-1");
assert_eq!(stack.render(), "/2/@barista/a/-1");
}
Loading