2021-05-05 16:02:34 +00:00
|
|
|
import * as fs from "fs"
|
|
|
|
import * as os from "os"
|
|
|
|
import * as path from "path"
|
|
|
|
|
2021-02-23 22:58:54 +00:00
|
|
|
export const loggerModule = {
|
|
|
|
field: jest.fn(),
|
|
|
|
level: 2,
|
|
|
|
logger: {
|
|
|
|
debug: jest.fn(),
|
|
|
|
error: jest.fn(),
|
|
|
|
info: jest.fn(),
|
|
|
|
trace: jest.fn(),
|
|
|
|
warn: jest.fn(),
|
|
|
|
},
|
|
|
|
}
|
2021-05-05 16:02:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a uniquely named temporary directory.
|
|
|
|
*
|
|
|
|
* These directories are placed under a single temporary code-server directory.
|
|
|
|
*/
|
|
|
|
export async function tmpdir(testName: string): Promise<string> {
|
|
|
|
const dir = path.join(os.tmpdir(), "code-server")
|
|
|
|
await fs.promises.mkdir(dir, { recursive: true })
|
|
|
|
|
|
|
|
return await fs.promises.mkdtemp(path.join(dir, `test-${testName}-`), { encoding: "utf8" })
|
|
|
|
}
|