diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e67a25f..53e569c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,7 +52,7 @@ jobs: ~/.cache/ghidra-cli/projects ~/Library/Caches/ghidra-cli/projects ~/AppData/Local/ghidra-cli/projects - key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }} + key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }} - name: Build run: cargo build --verbose @@ -78,6 +78,7 @@ jobs: run: | cargo run -- import tests/fixtures/sample_binary --project ci-test --program sample_binary || true cargo run -- analyze --project ci-test --program sample_binary || true + cargo run -- stop --project ci-test || true shell: bash timeout-minutes: 20 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79f5b7d..471dcec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,7 +90,7 @@ jobs: ~/.cache/ghidra-cli/projects ~/Library/Caches/ghidra-cli/projects ~/AppData/Local/ghidra-cli/projects - key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }} + key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }} - name: Build run: cargo build --verbose @@ -116,6 +116,7 @@ jobs: run: | cargo run -- import tests/fixtures/sample_binary --project ci-test --program sample_binary || true cargo run -- analyze --project ci-test --program sample_binary || true + cargo run -- stop --project ci-test || true shell: bash timeout-minutes: 20 @@ -164,7 +165,7 @@ jobs: ~/.cache/ghidra-cli/projects ~/Library/Caches/ghidra-cli/projects ~/AppData/Local/ghidra-cli/projects - key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }} + key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }} - name: Build run: cargo build --verbose @@ -237,7 +238,7 @@ jobs: ~/.cache/ghidra-cli/projects ~/Library/Caches/ghidra-cli/projects ~/AppData/Local/ghidra-cli/projects - key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }} + key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }} - name: Build run: cargo build --verbose @@ -310,7 +311,7 @@ jobs: ~/.cache/ghidra-cli/projects ~/Library/Caches/ghidra-cli/projects ~/AppData/Local/ghidra-cli/projects - key: ghidra-projects-${{ matrix.os }}-v2-${{ hashFiles('tests/fixtures/sample_binary.rs') }} + key: ghidra-projects-${{ matrix.os }}-v3-${{ hashFiles('tests/fixtures/sample_binary.rs') }} - name: Build run: cargo build --verbose diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 88f2884..36bd5ab 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -57,13 +57,21 @@ pub fn ensure_test_project(project: &str, program: &str) { let gpr_file = projects_dir.join(format!("{}.gpr", project)); let rep_dir = projects_dir.join(format!("{}.rep", project)); - if gpr_file.exists() && rep_dir.exists() && rep_dir.is_dir() { + // Check that .rep has actual content (not just an empty directory). + // If the bridge wasn't stopped before caching, .rep may exist but be empty + // because Ghidra hadn't flushed the project database to disk. + let rep_has_content = rep_dir.is_dir() + && std::fs::read_dir(&rep_dir) + .map(|mut entries| entries.next().is_some()) + .unwrap_or(false); + + if gpr_file.exists() && rep_has_content { eprintln!("=== Using cached test project: {:?} ===", gpr_file); return; } - if gpr_file.exists() { - eprintln!("=== Project .gpr exists but .rep missing, re-importing ==="); + if gpr_file.exists() && !rep_has_content { + eprintln!("=== Project .gpr exists but .rep missing or empty, re-importing ==="); } eprintln!("=== Setting up test project (import + analyze) ===");