blob: 9f0627da05cf8e2461c9f37f30eac4f7bdee4c57 [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as path from 'path';
import * as process from 'process';
import { runTests, SilentReporter } from '@vscode/test-electron';
/**
* download vscode as necessary & run tests
*
* (needs to be a separate function because commonjs can't do top-level await)
*/
async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
// NB(sollyross): this must resolve to the directory containing package.json.
// Since our tsconfig's rootDir is ${repo_root}, this file will end up
// (when built) in ./out/src/test/, this means that's
// ../../..
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
const workspaceDir = path.resolve(extensionDevelopmentPath, 'testdata/workspace');
// Download VS Code, unzip it and run the integration test
let settings = {
extensionDevelopmentPath,
extensionTestsPath,
// NB(sollyross): keep this pinned so that infra runs are as reproducible
// as we can make them. Due to VSCode licensing issues, we can't upload
// VSCode binary distributions to CIPD, and VSCode OSS is technically
// different than binary VSCode, so we've got an exception to download
// from an external source -- see https://fxbug.dev/98159
version: '1.66.2',
// Use a silent reporter so that we don't spam CI logs
reporter: process.env.ON_CI ? new SilentReporter() : undefined,
launchArgs: [workspaceDir],
};
await runTests(settings);
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}
void /* cause cjs prevents top-level await */ main();