diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ac235e..24a2584 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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 diff --git a/src/domain/activity.rs b/src/domain/activity.rs index 67f99d8..3cab008 100644 --- a/src/domain/activity.rs +++ b/src/domain/activity.rs @@ -51,7 +51,7 @@ impl LifeLapse { /// when the LifeLapse is empty. pub fn extend>(&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!( @@ -59,9 +59,9 @@ impl LifeLapse { "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; @@ -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); } diff --git a/src/parse.rs b/src/parse.rs index fe2f5fb..5219c12 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -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, - start_time: Timestamp, -) { +pub fn sort_and_filter_life_lapses(all_life_lapses: &mut Vec, start_time: Timestamp) { all_life_lapses.sort_by_key(|ll| ll.start()); *all_life_lapses = all_life_lapses @@ -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, diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index a4554b5..bcd3fe2 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -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, " (all past summaries)"); @@ -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]