-
Notifications
You must be signed in to change notification settings - Fork 6k
refactor: move integration tests to Jest #5275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d76d700
76b4e3c
7e19b73
a956a41
f149e14
ada0fd3
880ac2a
566d29a
7c96c97
86d29eb
acdb3a2
af300c6
4c0b5d9
395283b
f76acab
da4f1f2
233c226
eca5e2f
5df0fda
08bb492
ca6b445
529ed08
0ffc0e5
73f043a
a0eb6bc
f3c78ca
ee7d294
51b9196
79f6060
025b785
53e82a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ jobs: | |
run: ./install.sh | ||
|
||
- name: Test code-server | ||
run: yarn test:standalone-release code-server | ||
run: CODE_SERVER_PATH="code-server" yarn test:integration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we install code-server in these steps, we need to tell the integration tests to look at |
||
|
||
alpine: | ||
name: Test installer on Alpine | ||
|
@@ -66,4 +66,4 @@ jobs: | |
run: ./install.sh | ||
|
||
- name: Test code-server | ||
run: yarn test:standalone-release code-server | ||
run: CODE_SERVER_PATH="code-server" yarn test:integration |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
help() { | ||
jsjoeio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo >&2 " You can build the standalone release with 'yarn release:standalone'" | ||
echo >&2 " Or you can pass in a custom path." | ||
echo >&2 " CODE_SERVER_PATH='/var/tmp/coder/code-server/bin/code-server' yarn test:integration" | ||
} | ||
|
||
# Make sure a code-server release works. You can pass in the path otherwise it | ||
# will look for release-standalone in the current directory. | ||
# | ||
# This is to make sure we don't have Node version errors or any other | ||
# compilation-related errors. | ||
main() { | ||
cd "$(dirname "$0")/../.." | ||
|
||
source ./ci/lib.sh | ||
|
||
local path="$RELEASE_PATH-standalone/bin/code-server" | ||
if [[ ! ${CODE_SERVER_PATH-} ]]; then | ||
echo "Set CODE_SERVER_PATH to test another build of code-server" | ||
else | ||
path="$CODE_SERVER_PATH" | ||
fi | ||
|
||
echo "Running tests with code-server binary: '$path'" | ||
|
||
if [[ ! -f $path ]]; then | ||
echo >&2 "No code-server build detected" | ||
echo >&2 "Looked in $path" | ||
help | ||
exit 1 | ||
fi | ||
|
||
CODE_SERVER_PATH="$path" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --coverage=false --testRegex "./test/integration" --testPathIgnorePatterns "./test/integration/fixtures" | ||
} | ||
|
||
main "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { stat } from "fs/promises" | ||
import path from "path" | ||
import { clean, tmpdir } from "../utils/helpers" | ||
import { runCodeServerCommand } from "../utils/runCodeServerCommand" | ||
|
||
describe("--install-extension", () => { | ||
const testName = "installExtension" | ||
let tempDir: string | ||
let setupFlags: string[] | ||
|
||
beforeEach(async () => { | ||
await clean(testName) | ||
tempDir = await tmpdir(testName) | ||
setupFlags = ["--extensions-dir", tempDir] | ||
}) | ||
it("should install an extension", async () => { | ||
const extName = `wesbos.theme-cobalt2-2.1.6` | ||
const vsixFileName = "wesbos.theme-cobalt2-2.1.6.vsix" | ||
const extensionFixture = path.resolve(`./test/integration/fixtures/${vsixFileName}`) | ||
await runCodeServerCommand([...setupFlags, "--install-extension", extensionFixture]) | ||
const pathToExtFolder = path.join(tempDir, extName) | ||
const statInfo = await stat(pathToExtFolder) | ||
expect(statInfo.isDirectory()).toBe(true) | ||
}, 20000) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { rename } from "fs/promises" | ||
import path from "path" | ||
import extract from "extract-zip" | ||
import { clean, tmpdir } from "../utils/helpers" | ||
import { runCodeServerCommand } from "../utils/runCodeServerCommand" | ||
|
||
describe("--list-extensions", () => { | ||
const testName = "listExtensions" | ||
const extName = `wesbos.theme-cobalt2` | ||
const extVersion = "2.1.6" | ||
const vsixFileName = `${extName}-${extVersion}.vsix` | ||
let tempDir: string | ||
let setupFlags: string[] | ||
|
||
beforeEach(async () => { | ||
await clean(testName) | ||
tempDir = await tmpdir(testName) | ||
setupFlags = ["--extensions-dir", tempDir] | ||
const extensionFixture = path.resolve(`./test/integration/fixtures/${vsixFileName}`) | ||
// Make folder because this is where we'll move the extension | ||
const pathToUnpackedExtension = path.join(tempDir, `${extName}-${extVersion}`) | ||
const tempPathToUnpackedExtension = path.join(tempDir, `${extName}-temp`) | ||
await extract(extensionFixture, { dir: tempPathToUnpackedExtension }) | ||
await rename(path.join(tempPathToUnpackedExtension, "extension", pathToUnpackedExtension)) | ||
}) | ||
it("should list installed extensions", async () => { | ||
const { stdout } = await runCodeServerCommand([...setupFlags, "--list-extensions"]) | ||
expect(stdout).toMatch(extName) | ||
}, 20000) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { exec } from "child_process" | ||
import path from "path" | ||
import { promisify } from "util" | ||
|
||
/** | ||
* | ||
* A helper function for integration tests to run code-server commands. | ||
*/ | ||
export async function runCodeServerCommand(argv: string[]): Promise<{ stdout: string; stderr: string }> { | ||
const CODE_SERVER_COMMAND = process.env.CODE_SERVER_PATH || path.resolve("../../release-standalone/bin/code-server") | ||
const { stdout, stderr } = await promisify(exec)(`${CODE_SERVER_COMMAND} ${argv.join(" ")}`) | ||
Check warningCode scanning / CodeQL Shell command built from environment values
This shell command depends on an uncontrolled [absolute path](1).
This shell command depends on an uncontrolled [absolute path](2).
|
||
|
||
return { stdout, stderr } | ||
} |
Uh oh!
There was an error while loading. Please reload this page.