mirror of
https://github.com/coder/code-server.git
synced 2024-11-30 11:46:20 +03:00
c4c480a068
* Implement last opened functionality Fixes https://github.com/cdr/code-server/issues/4619 * Fix test temp dirs not being cleaned up * Mock logger everywhere This suppresses all the error and debug output we generate which makes it hard to actually find which test has failed. It also gives us a standard way to test logging for the few places we do that. * Use separate data directories for unit test instances Exactly as we do for the e2e tests. * Add integration tests for vscode route * Make settings use --user-data-dir Without this test instances step on each other feet and they also clobber your own non-test settings. * Make redirects consistent They will preserve the trailing slash if there is one. * Remove compilation check If you do a regular non-watch build there are no compilation stats so this bricks VS Code in CI when running the unit tests. I am not sure how best to fix this for the case where you have a build that has not been packaged yet so I just removed it for now and added a message to check if VS Code is compiling when in dev mode. * Update code-server update endpoint name
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { promises as fs } from "fs"
|
|
import * as path from "path"
|
|
import { parse, parseConfigFile, setDefaults } from "../../src/node/cli"
|
|
import { runCodeServer } from "../../src/node/main"
|
|
import { workspaceDir } from "./constants"
|
|
import { tmpdir } from "./helpers"
|
|
import * as httpserver from "./httpserver"
|
|
|
|
export async function setup(argv: string[], configFile?: string): Promise<httpserver.HttpServer> {
|
|
// This will be used as the data directory to ensure instances do not bleed
|
|
// into each other.
|
|
const dir = await tmpdir(workspaceDir)
|
|
|
|
// VS Code complains if the logs dir is missing which spams the output.
|
|
// TODO: Does that mean we are not creating it when we should be?
|
|
await fs.mkdir(path.join(dir, "logs"))
|
|
|
|
const cliArgs = parse([
|
|
`--config=${path.join(dir, "config.yaml")}`,
|
|
`--user-data-dir=${dir}`,
|
|
"--bind-addr=localhost:0",
|
|
"--log=warn",
|
|
...argv,
|
|
])
|
|
const configArgs = parseConfigFile(configFile || "", "test/integration.ts")
|
|
const args = await setDefaults(cliArgs, configArgs)
|
|
|
|
const server = await runCodeServer(args)
|
|
|
|
return new httpserver.HttpServer(server)
|
|
}
|