2021-05-06 00:02:34 +08:00
|
|
|
import * as fs from "fs"
|
|
|
|
import * as os from "os"
|
|
|
|
import * as path from "path"
|
|
|
|
|
2021-02-24 06:58:54 +08: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-06 00:02:34 +08: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> {
|
2021-05-06 00:03:04 +08:00
|
|
|
const dir = path.join(os.tmpdir(), "code-server/tests")
|
2021-05-06 00:02:34 +08:00
|
|
|
await fs.promises.mkdir(dir, { recursive: true })
|
|
|
|
|
2021-05-06 00:03:04 +08:00
|
|
|
return await fs.promises.mkdtemp(path.join(dir, `${testName}-`), { encoding: "utf8" })
|
2021-05-06 00:02:34 +08:00
|
|
|
}
|