wamr-ide: Add vscode extension tests (#2292)

This PR adds tests for #2219 by changing the `compilation_on_android_ubuntu.yml` workflow.
The first run will take about two hours, since LLDB is built from scratch. Later, the build is
cached and the whole job should not take more than three minutes.

Core of the PR is an integration test that boots up vscode and lets it debug a test WASM file.
This commit is contained in:
Ben Riegel
2023-06-20 08:33:01 +01:00
committed by GitHub
parent 85981b77b8
commit 72fc872afe
15 changed files with 511 additions and 22 deletions

View File

@ -102,7 +102,7 @@ export async function checkIfDockerImagesExist(
): Promise<boolean> {
try {
/* the tag of images is equal to extension's version */
const imageTag = getWAMRExtensionVersion(context);
const imageTag = getWAMRExtensionVersion(context.extensionPath);
await execShell(
`docker image inspect wasm-debug-server:${imageTag} wasm-toolchain:${imageTag}`
);
@ -115,7 +115,7 @@ export async function checkIfDockerImagesExist(
function getDockerImagesDownloadUrl(
context: vscode.ExtensionContext
): string[] {
const wamrVersion = getWAMRExtensionVersion(context);
const wamrVersion = getWAMRExtensionVersion(context.extensionPath);
const wamrReleaseUrl = `https://github.com/bytecodealliance/wasm-micro-runtime/releases/download/WAMR`;
return [

View File

@ -36,14 +36,14 @@ function getLLDBUnzipFilePath(destinationFolder: string, filename: string) {
}
export function getWAMRExtensionVersion(
context: vscode.ExtensionContext
extensionPath: string
): string {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require(path.join(context.extensionPath, 'package.json')).version;
return require(path.join(extensionPath, 'package.json')).version;
}
function getLLDBDownloadUrl(context: vscode.ExtensionContext): string {
const wamrVersion = getWAMRExtensionVersion(context);
function getLLDBDownloadUrl(extensionPath: string): string {
const wamrVersion = getWAMRExtensionVersion(extensionPath);
const lldbOsUrlSuffix = LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP[os.platform()];
if (!lldbOsUrlSuffix) {
@ -53,8 +53,7 @@ function getLLDBDownloadUrl(context: vscode.ExtensionContext): string {
return `https://github.com/bytecodealliance/wasm-micro-runtime/releases/download/WAMR-${wamrVersion}/wamr-lldb-${wamrVersion}-${lldbOsUrlSuffix}.zip`;
}
export function isLLDBInstalled(context: vscode.ExtensionContext): boolean {
const extensionPath = context.extensionPath;
export function isLLDBInstalled(extensionPath: string): boolean {
const lldbOSDir = os.platform();
const lldbBinaryPath = path.join(
extensionPath,
@ -67,9 +66,8 @@ export function isLLDBInstalled(context: vscode.ExtensionContext): boolean {
}
export async function promptInstallLLDB(
context: vscode.ExtensionContext
extensionPath: string
): Promise<SelectionOfPrompt> {
const extensionPath = context.extensionPath;
const response = await vscode.window.showWarningMessage(
'No LLDB instance found. Setup now?',
@ -81,7 +79,15 @@ export async function promptInstallLLDB(
return response;
}
const downloadUrl = getLLDBDownloadUrl(context);
await downloadLldb(extensionPath);
return SelectionOfPrompt.setUp;
}
export async function downloadLldb(
extensionPath: string
): Promise<void> {
const downloadUrl = getLLDBDownloadUrl(extensionPath);
const destinationDir = os.platform();
if (!downloadUrl) {
@ -115,5 +121,4 @@ export async function promptInstallLLDB(
// Remove the bundle.zip
fs.unlinkSync(lldbZipPath);
return SelectionOfPrompt.setUp;
}