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
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,13 @@ jobs:
run: cargo build --release

cross-platform:
name: Cross-platform compile (${{ matrix.os }})
name: Cross-platform compile + test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
# Guards the cfg(target_os) gating so a macOS-only change can't silently
# break the Windows/Linux build (GTM §9 "提前搭 CI 矩阵"). Compile + link
# only (--debug --no-bundle); real installers are the on-demand
# break the Windows/Linux build (GTM §9 "提前搭 CI 矩阵"), and runs the Rust
# suite there so platform-specific logic is tested, not just compiled.
# Compile + link via --debug --no-bundle; real installers are the on-demand
# cross-platform-bundle workflow.
strategy:
fail-fast: false
Expand Down Expand Up @@ -224,3 +225,10 @@ jobs:

- name: tauri build (compile + link only)
run: pnpm tauri build --debug --no-bundle

# Run the Rust suite on Win/Linux too, so platform-specific logic
# (argv file-open, the Linux token-file fallback) is tested where it
# actually runs — not just compiled.
- name: Cargo test
working-directory: src-tauri
run: cargo test
27 changes: 27 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ fn paths_from_argv(argv: &[String]) -> Vec<String> {
.collect()
}

#[cfg(all(test, any(target_os = "windows", target_os = "linux")))]
mod argv_tests {
use super::paths_from_argv;

#[test]
fn keeps_existing_markdown_only_and_skips_argv0() {
let dir = std::env::temp_dir().join(format!("markup-argv-{}", std::process::id()));
let _ = std::fs::create_dir_all(&dir);
let md = dir.join("note.md");
std::fs::write(&md, b"# hi").unwrap();
let txt = dir.join("note.txt");
std::fs::write(&txt, b"nope").unwrap();
let md_str = md.to_string_lossy().into_owned();

let argv = vec![
md_str.clone(), // argv[0] — skipped even though real .md
md_str.clone(), // kept
txt.to_string_lossy().into_owned(), // not markdown — skipped
dir.join("missing.md").to_string_lossy().into_owned(), // doesn't exist — skipped
];
// Exactly one entry: argv[0] dropped by skip(1), only the existing .md kept.
assert_eq!(paths_from_argv(&argv), vec![md_str]);

let _ = std::fs::remove_dir_all(&dir);
}
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let _ = tracing_subscriber::fmt()
Expand Down
Loading