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
10 changes: 6 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install libdbus
run: sudo apt-get install -y libdbus-1-dev
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev pkg-config
- name: Build
run: cargo build --verbose
- name: Run Clippy
run: cargo clippy -- -D warnings
- name: Check formatting
run: cargo fmt -- --check
- name: Run tests
run: cargo test --verbose
run: export TZ='Europe/Paris' && cargo test --verbose
8 changes: 4 additions & 4 deletions src/domain/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ impl LifeLapse {
/// when the LifeLapse is empty.
pub fn extend<I: IntoIterator<Item = TimedLifeChunk>>(&mut self, iter: I) {
let new_tokens: Vec<_> = iter.into_iter().collect();

// Validate invariant: first token must match start time if this is empty
if self.tokens.is_empty() && !new_tokens.is_empty() {
assert_eq!(
self.start, new_tokens[0].start,
"First token start time must match LifeLapse start time"
);
}

self.tokens.extend(new_tokens);

// Recalculate end time to maintain invariant
let d = self.total_duration();
self.end = self.start + d;
Expand All @@ -80,7 +80,7 @@ impl LifeLapse {
"First token start time must match LifeLapse start time"
);
}

self.end = self.end + item.life_chunk.duration;
self.tokens.push(item);
}
Expand Down
7 changes: 2 additions & 5 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ pub fn get_all_life_lapses(
(start_time, all_life_lapses)
}

pub fn sort_and_filter_life_lapses(
all_life_lapses: &mut Vec<LifeLapse>,
start_time: Timestamp,
) {
pub fn sort_and_filter_life_lapses(all_life_lapses: &mut Vec<LifeLapse>, start_time: Timestamp) {
all_life_lapses.sort_by_key(|ll| ll.start());

*all_life_lapses = all_life_lapses
Expand Down Expand Up @@ -210,7 +207,7 @@ pub(crate) fn get_life_chunk(line: &str) -> LifeChunk {
// XXX: what to do if description is empty (categories self-explaining). Could have None instead.
let user_provided_quadrant = quadrant.is_some();
let qu = quadrant.unwrap_or_default();

LifeChunk::new(
description.to_string(),
duration,
Expand Down
10 changes: 4 additions & 6 deletions tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ fn cli_with_separate_summary_and_plan_files() {
assert!(plan_path.exists(), "Plan file should be created");

let summary_content = fs::read_to_string(&summary_path).unwrap();

// Replace dynamic date with placeholder
let re = Regex::new(r"\d{4}-\d{2}-\d{2}\+\d{2}:\d{2} \(all past summaries\)").unwrap();
let normalized = re.replace(&summary_content, "<DATE> (all past summaries)");
Expand Down Expand Up @@ -332,11 +332,9 @@ fn cli_with_nonexistent_config_fails() {
let mut cmd = assert_cmd::Command::from_std(Command::new(env!("CARGO_BIN_EXE_tiro")));
cmd.arg("--config").arg("/nonexistent/config.toml");

cmd.assert()
.failure()
.stderr(predicate::str::contains(
"Cannot proceed without valid configuration path",
));
cmd.assert().failure().stderr(predicate::str::contains(
"Cannot proceed without valid configuration path",
));
}

#[test]
Expand Down