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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rust:
name: Rust checks
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-D warnings"
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Check formatting
run: cargo fmt --check

- name: Clippy
run: cargo clippy --all-targets -- -D warnings

- name: Build
run: cargo build --all-targets

- name: Test
run: cargo test
15 changes: 9 additions & 6 deletions src/claude_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,15 @@ mod tests {
#[test]
fn stream_turn_iterator_with_mock_process() {
// Simulate stdout with assistant + result events
let child = Command::new("sh")
let mut child = Command::new("sh")
.arg("-c")
.arg(r#"echo '{"type":"system","subtype":"init"}'; echo '{"type":"assistant","message":{"content":[{"type":"text","text":"Hello"}]}}'; echo '{"type":"result","result":"Hello","subtype":"success"}';"#)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.unwrap();

let stdout = child.stdout.unwrap();
let stdout = child.stdout.take().unwrap();
let mut reader = BufReader::new(stdout);

// Skip system init
Expand All @@ -666,19 +666,20 @@ mod tests {
}

assert_eq!(collected, vec!["Hello"]);
let _ = child.wait();
}

#[test]
fn stream_turn_iterator_reports_error_events() {
let child = Command::new("sh")
let mut child = Command::new("sh")
.arg("-c")
.arg(r#"echo '{"type":"error","error":"something went wrong"}'"#)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.unwrap();

let stdout = child.stdout.unwrap();
let stdout = child.stdout.take().unwrap();
let mut reader = BufReader::new(stdout);

let mut iter = StreamTurnIterator {
Expand All @@ -694,19 +695,20 @@ mod tests {
matches!(item, Err(ProviderError::StreamError(ref msg)) if msg == "something went wrong"),
"expected StreamError, got: {item:?}"
);
let _ = child.wait();
}

#[test]
fn stream_turn_iterator_skips_non_json_lines() {
let child = Command::new("sh")
let mut child = Command::new("sh")
.arg("-c")
.arg(r#"echo 'not json'; echo '{"type":"assistant","message":{"content":[{"type":"text","text":"text"}]}}'; echo '{"type":"result","result":"text","subtype":"success"}';"#)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.unwrap();

let stdout = child.stdout.unwrap();
let stdout = child.stdout.take().unwrap();
let mut reader = BufReader::new(stdout);

let mut iter = StreamTurnIterator {
Expand All @@ -725,6 +727,7 @@ mod tests {
}

assert_eq!(texts, vec!["text"]);
let _ = child.wait();
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ mod tests {
instruction: instruction.to_string(),
source_file: PathBuf::from("tests/login.test.toml"),
result: StepResult::Verdict(StepVerdict::Ok),
transcript: format!("Checked.\nRESULT OK"),
transcript: "Checked.\nRESULT OK".to_string(),
log_events: vec![],
evidence_refs: vec![],
duration: Duration::from_millis(1500),
Expand Down
Loading