Skip to content
Open
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
18 changes: 15 additions & 3 deletions src/cmds/dotnet/dotnet_trx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ fn parse_trx_content(content: &str) -> Option<TestSummary> {
#[cfg(test)]
mod tests {
use super::*;
//use std::io::Write;
//use std::{fs::File, time::Duration};
use std::time::Duration;

#[test]
Expand Down Expand Up @@ -565,13 +567,23 @@ mod tests {
let trx_old = r#"<?xml version="1.0" encoding="utf-8"?>
<TestRun><ResultSummary><Counters total="2" executed="2" passed="2" failed="0" /></ResultSummary></TestRun>"#;
std::fs::write(trx_dir.join("old.trx"), trx_old).expect("write old trx");
std::thread::sleep(Duration::from_millis(5));
let since = SystemTime::now();
std::thread::sleep(Duration::from_millis(5));
// File::create(trx_dir.join("old.trx"))
// .and_then(|mut f| f.write_all(trx_old.as_ref()).and_then(|_| f.sync_all()))
// .expect("write old trx");

//let since = SystemTime::now();
std::thread::sleep(Duration::from_millis(10));

let since = SystemTime::now()
.checked_sub(Duration::from_millis(10))
.expect("threshold overflow");

let trx_new = r#"<?xml version="1.0" encoding="utf-8"?>
<TestRun><ResultSummary><Counters total="3" executed="3" passed="2" failed="1" /></ResultSummary></TestRun>"#;
std::fs::write(trx_dir.join("new.trx"), trx_new).expect("write new trx");
// File::create(trx_dir.join("new.trx"))
// .and_then(|mut f| f.write_all(trx_new.as_ref()).and_then(|_| f.sync_all()))
// .expect("write new trx");

let summary = parse_trx_files_in_dir_since(&trx_dir, Some(since)).expect("merged summary");
assert_eq!(summary.total, 3);
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ pub const HOOKS_JSON: &str = "hooks.json";
pub const PRE_TOOL_USE_KEY: &str = "PreToolUse";
pub const BEFORE_TOOL_KEY: &str = "BeforeTool";

#[allow(dead_code)]
pub const OPENCODE_PLUGIN_PATH: &str = ".config/opencode/plugins/rtk.ts";
#[allow(dead_code)]
pub const CURSOR_DIR: &str = ".cursor";
pub const CODEX_DIR: &str = ".codex";
#[allow(dead_code)]
pub const GEMINI_DIR: &str = ".gemini";
38 changes: 19 additions & 19 deletions src/hooks/hook_check.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Detects whether RTK hooks are installed and warns if they are outdated.

use super::constants::{
CLAUDE_DIR, CODEX_DIR, CURSOR_DIR, GEMINI_DIR, GEMINI_HOOK_FILE, HOOKS_SUBDIR,
OPENCODE_PLUGIN_PATH, REWRITE_HOOK_FILE,
};
use super::constants::{CLAUDE_DIR, HOOKS_SUBDIR, REWRITE_HOOK_FILE};
use crate::core::constants::RTK_DATA_DIR;
use std::path::PathBuf;

Expand Down Expand Up @@ -93,21 +90,6 @@ pub fn parse_hook_version(content: &str) -> u8 {
0 // No version tag = version 0 (outdated)
}

#[cfg(test)]
fn other_integration_installed(home: &std::path::Path) -> bool {
let paths = [
home.join(OPENCODE_PLUGIN_PATH),
home.join(CURSOR_DIR)
.join(HOOKS_SUBDIR)
.join(REWRITE_HOOK_FILE),
home.join(CODEX_DIR).join("AGENTS.md"),
home.join(GEMINI_DIR)
.join(HOOKS_SUBDIR)
.join(GEMINI_HOOK_FILE),
];
paths.iter().any(|p| p.exists())
}

fn hook_installed_path() -> Option<PathBuf> {
let home = dirs::home_dir()?;
let path = home
Expand All @@ -128,8 +110,26 @@ fn warn_marker_path() -> Option<PathBuf> {

#[cfg(test)]
mod tests {
use crate::hooks::constants::{
CODEX_DIR, CURSOR_DIR, GEMINI_DIR, GEMINI_HOOK_FILE, OPENCODE_PLUGIN_PATH,
};

use super::*;

fn other_integration_installed(home: &std::path::Path) -> bool {
let paths = [
home.join(OPENCODE_PLUGIN_PATH),
home.join(CURSOR_DIR)
.join(HOOKS_SUBDIR)
.join(REWRITE_HOOK_FILE),
home.join(CODEX_DIR).join("AGENTS.md"),
home.join(GEMINI_DIR)
.join(HOOKS_SUBDIR)
.join(GEMINI_HOOK_FILE),
];
paths.iter().any(|p| p.exists())
}

#[test]
fn test_parse_hook_version_present() {
let content = "#!/usr/bin/env bash\n# rtk-hook-version: 2\n# some comment\n";
Expand Down
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2068,8 +2068,14 @@ fn run_cli() -> Result<i32> {
libc::raise(sig);
}
unsafe {
libc::signal(libc::SIGINT, handle_signal as libc::sighandler_t);
libc::signal(libc::SIGTERM, handle_signal as libc::sighandler_t);
libc::signal(
libc::SIGINT,
handle_signal as *const () as libc::sighandler_t,
);
libc::signal(
libc::SIGTERM,
handle_signal as *const () as libc::sighandler_t,
);
}
}

Expand Down
Loading