Merge pull request #80 from github/symlinks_test
Make the temporary directory in tests a symlink
This commit is contained in:
commit
04adf2bf60
3 changed files with 11 additions and 3 deletions
6
lib/util.js
generated
6
lib/util.js
generated
|
|
@ -349,7 +349,11 @@ exports.getToolNames = getToolNames;
|
||||||
// Mostly intended for use within tests.
|
// Mostly intended for use within tests.
|
||||||
async function withTmpDir(body) {
|
async function withTmpDir(body) {
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codeql-action-'));
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codeql-action-'));
|
||||||
const result = await body(tmpDir);
|
const realSubdir = path.join(tmpDir, 'real');
|
||||||
|
fs.mkdirSync(realSubdir);
|
||||||
|
const symlinkSubdir = path.join(tmpDir, 'symlink');
|
||||||
|
fs.symlinkSync(realSubdir, symlinkSubdir, 'dir');
|
||||||
|
const result = await body(symlinkSubdir);
|
||||||
fs.rmdirSync(tmpDir, { recursive: true });
|
fs.rmdirSync(tmpDir, { recursive: true });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -389,7 +389,11 @@ export function getToolNames(sarifContents: string): string[] {
|
||||||
// Mostly intended for use within tests.
|
// Mostly intended for use within tests.
|
||||||
export async function withTmpDir<T>(body: (tmpDir: string) => Promise<T>): Promise<T> {
|
export async function withTmpDir<T>(body: (tmpDir: string) => Promise<T>): Promise<T> {
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codeql-action-'));
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codeql-action-'));
|
||||||
const result = await body(tmpDir);
|
const realSubdir = path.join(tmpDir, 'real');
|
||||||
|
fs.mkdirSync(realSubdir);
|
||||||
|
const symlinkSubdir = path.join(tmpDir, 'symlink');
|
||||||
|
fs.symlinkSync(realSubdir, symlinkSubdir, 'dir');
|
||||||
|
const result = await body(symlinkSubdir);
|
||||||
fs.rmdirSync(tmpDir, { recursive: true });
|
fs.rmdirSync(tmpDir, { recursive: true });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue