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
24 changes: 23 additions & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "technique"
version = "0.7.0"
version = "0.7.1"
edition = "2024"
description = "A domain specific language for procedures."
authors = [ "Andrew Cowie" ]
Expand All @@ -16,7 +16,7 @@ lsp-types = "0.97"
owo-colors = "4"
regex = "1.11.1"
serde_json = "1.0"
time = "0.3"
time = { version = "0.3", features = [ "local-offset", "parsing" ] }

tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = [ "env-filter" ] }
Expand Down
44 changes: 36 additions & 8 deletions src/runner/checks/state.rs → src/engraving/checks/record.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::path::{Path, PathBuf};

use crate::runner::runner::RunnerError;
use crate::runner::state::{
InvokeTarget, Record, RecordError, RunId, State, Store, Supplied, fail_reason, format_record,
parse_record,
use crate::engraving::{
InvokeTarget, Record, RecordError, RunId, State, Store, StoreError, Supplied, display_path,
fail_reason, format_record, parse_record,
};
use crate::value::Value;

Expand Down Expand Up @@ -43,7 +42,7 @@ fn run_id_parse() {
fn run_id_parse_rejects_non_decimal() {
for text in ["", "abc", "-1"] {
match RunId::parse(text) {
Err(RunnerError::InvalidRunId(got)) => assert_eq!(got, text),
Err(StoreError::InvalidRunId(got)) => assert_eq!(got, text),
other => panic!("expected InvalidRunId for {:?}, got {:?}", text, other),
}
}
Expand Down Expand Up @@ -281,7 +280,7 @@ fn open_missing_run_returns_no_such_run() {
.clone(),
);
match store.open(RunId(42)) {
Err(RunnerError::NoSuchRun(run_id)) => assert_eq!(run_id, RunId(42)),
Err(StoreError::NoSuchRun(run_id)) => assert_eq!(run_id, RunId(42)),
other => panic!("expected NoSuchRun, got {:?}", other),
}
}
Expand Down Expand Up @@ -710,7 +709,7 @@ fn open_missing_start_record() {
.clone(),
);
match store.open(RunId(1)) {
Err(RunnerError::StartMissing(run_id)) => assert_eq!(run_id, RunId(1)),
Err(StoreError::StartMissing(run_id)) => assert_eq!(run_id, RunId(1)),
other => panic!("expected StartMissing, got {:?}", other),
}

Expand All @@ -726,7 +725,36 @@ fn open_missing_start_record() {
.clone(),
);
match store.open(RunId(1)) {
Err(RunnerError::StartMissing(run_id)) => assert_eq!(run_id, RunId(1)),
Err(StoreError::StartMissing(run_id)) => assert_eq!(run_id, RunId(1)),
other => panic!("expected StartMissing, got {:?}", other),
}
}

#[test]
fn display_trims_entry_head() {
// Within a section the entry head is dropped, the numeral anchors instead.
assert_eq!(
display_path("/connectivity_check:/VI/check_aws_health:/7"),
"VI/check_aws_health:/7"
);

// A flat entry with no section keeps its name; only the leading slash goes.
assert_eq!(
display_path("/connectivity_check:/1"),
"connectivity_check:/1"
);
assert_eq!(
display_path("/activate_crisis_management:/-1"),
"activate_crisis_management:/-1"
);

// An ` <invocation>` annotation on the numeral is kept; the head still drops.
assert_eq!(
display_path("/connectivity_check:/VII <service_endpoint>"),
"VII <service_endpoint>"
);

// An anonymous technique has no head to drop; the leading slash still goes.
assert_eq!(display_path("/I/1"), "I/1");
assert_eq!(display_path("/I"), "I");
}
29 changes: 29 additions & 0 deletions src/engraving/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! The PFFTT record format, and the local on-disk store these records are
//! written to.

use std::io;
use std::path::PathBuf;

mod record;
mod store;

/// Errors raised interacting with the store or PFFTT files therein.
#[derive(Debug)]
pub enum StoreError {
NoSuchRun(RunId),
StartMissing(RunId),
InvalidRunId(String),
MalformedRecord { run_id: RunId, error: RecordError },
Io { path: PathBuf, error: io::Error },
}

pub use record::{
InvokeTarget, Record, RecordError, RunId, State, Supplied, display_path, parse_records,
};
pub use store::{Appender, Store};

pub(crate) use record::{fail_reason, format_record, format_supplied, serialize_value};
pub(crate) use store::{construct_state_path, parse_run_uri};

#[cfg(test)]
pub(crate) use record::parse_record;
Loading