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
27 changes: 18 additions & 9 deletions actions/setup/js/create_pull_request.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@ const { getBundlePathForBranch, getBundlePathForBranchInRepo } = require("./gene
// The privileged handler derives patch/bundle paths from `branch` (and `repo`)
// via resolveTransportPaths, so tests must write transport files at the
// canonical derived location and let the handler discover them.
//
// `/tmp/gh-aw` is a process-global path shared by every test file. Vitest runs
// test files in parallel processes, so a cleanup that globbed the whole
// directory would delete another file's in-flight transport files mid-test.
// Track only the paths this file created and delete just those.
const createdTransportPaths = new Set();
function canonicalPatchPath(branch, repo) {
fs.mkdirSync("/tmp/gh-aw", { recursive: true });
return repo ? getPatchPathForBranchInRepo(branch, repo) : getPatchPathForBranch(branch);
const p = repo ? getPatchPathForBranchInRepo(branch, repo) : getPatchPathForBranch(branch);
createdTransportPaths.add(p);
return p;
}
function canonicalBundlePath(branch, repo) {
fs.mkdirSync("/tmp/gh-aw", { recursive: true });
return repo ? getBundlePathForBranchInRepo(branch, repo) : getBundlePathForBranch(branch);
const p = repo ? getBundlePathForBranchInRepo(branch, repo) : getBundlePathForBranch(branch);
createdTransportPaths.add(p);
return p;
}
function cleanupCanonicalTransports() {
try {
for (const f of fs.readdirSync("/tmp/gh-aw")) {
if (/^aw-.*\.(patch|bundle)$/.test(f)) {
fs.rmSync(`/tmp/gh-aw/${f}`, { force: true });
}
}
} catch {}
for (const p of createdTransportPaths) {
try {
fs.rmSync(p, { force: true });
} catch {}
Comment thread
dsyme marked this conversation as resolved.
}
createdTransportPaths.clear();
}

beforeEach(() => {
Expand Down
6 changes: 6 additions & 0 deletions actions/setup/js/handle_noop_message.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ describe("handle_noop_message", () => {
// Create temp directory for test files
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "handle-noop-test-"));

// getPromptPath() throws unless GH_AW_PROMPTS_DIR or RUNNER_TEMP is set.
// On CI RUNNER_TEMP is ambient, but it is not set in local dev, so set the
// prompts dir explicitly to make the suite environment-independent. The
// actual path is irrelevant because fs.readFileSync is mocked below.
process.env.GH_AW_PROMPTS_DIR = tempDir;

// Mock fs.readFileSync to return template content
originalReadFileSync = fs.readFileSync;
fs.readFileSync = vi.fn((filePath, encoding) => {
Expand Down
27 changes: 18 additions & 9 deletions actions/setup/js/push_to_pull_request_branch.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,31 @@ const { getBundlePathForBranch, getBundlePathForBranchInRepo } = require("./gene
// The privileged handler derives patch/bundle paths from `branch` (and `repo`)
// via resolveTransportPaths, so tests must write transport files at the
// canonical derived location and let the handler discover them.
//
// `/tmp/gh-aw` is a process-global path shared by every test file. Vitest runs
// test files in parallel processes, so a cleanup that globbed the whole
// directory would delete another file's in-flight transport files mid-test.
// Track only the paths this file created and delete just those.
const createdTransportPaths = new Set();
function canonicalPatchPath(branch, repo) {
fs.mkdirSync("/tmp/gh-aw", { recursive: true });
return repo ? getPatchPathForBranchInRepo(branch, repo) : getPatchPathForBranch(branch);
const p = repo ? getPatchPathForBranchInRepo(branch, repo) : getPatchPathForBranch(branch);
createdTransportPaths.add(p);
return p;
}
function canonicalBundlePath(branch, repo) {
fs.mkdirSync("/tmp/gh-aw", { recursive: true });
return repo ? getBundlePathForBranchInRepo(branch, repo) : getBundlePathForBranch(branch);
const p = repo ? getBundlePathForBranchInRepo(branch, repo) : getBundlePathForBranch(branch);
createdTransportPaths.add(p);
return p;
}
function cleanupCanonicalTransports() {
try {
for (const f of fs.readdirSync("/tmp/gh-aw")) {
if (/^aw-.*\.(patch|bundle)$/.test(f)) {
fs.rmSync(`/tmp/gh-aw/${f}`, { force: true });
}
}
} catch {}
for (const p of createdTransportPaths) {
try {
fs.rmSync(p, { force: true });
} catch {}
}
createdTransportPaths.clear();
}

beforeEach(() => {
Comment thread
dsyme marked this conversation as resolved.
Expand Down
Loading