Remove custom editor tests (#152777)

These tests are not actively being run or maintained. Removing them for now
This commit is contained in:
Matt Bierner 2022-06-21 12:37:19 -07:00 committed by GitHub
parent fa53aa6fec
commit bbe7b54cf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 18 additions and 808 deletions

18
.vscode/launch.json vendored
View file

@ -201,24 +201,6 @@
"order": 5
}
},
{
"type": "extensionHost",
"request": "launch",
"name": "VS Code Custom Editor Tests",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/extensions/vscode-custom-editor-tests/test-workspace",
"--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode-custom-editor-tests",
"--extensionTestsPath=${workspaceFolder}/extensions/vscode-custom-editor-tests/out/test"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"presentation": {
"group": "5_tests",
"order": 6
}
},
{
"type": "pwa-chrome",
"request": "attach",

View file

@ -52,7 +52,6 @@ steps:
compile-extension:typescript-language-features \
compile-extension:vscode-api-tests \
compile-extension:vscode-colorize-tests \
compile-extension:vscode-custom-editor-tests \
compile-extension:vscode-notebook-tests \
compile-extension:vscode-test-resolver
displayName: Build integration tests

View file

@ -64,7 +64,6 @@ steps:
compile-extension:typescript-language-features \
compile-extension:vscode-api-tests \
compile-extension:vscode-colorize-tests \
compile-extension:vscode-custom-editor-tests \
compile-extension:vscode-notebook-tests \
compile-extension:vscode-test-resolver
displayName: Build integration tests

View file

@ -58,7 +58,6 @@ steps:
compile-extension:typescript-language-features `
compile-extension:vscode-api-tests `
compile-extension:vscode-colorize-tests `
compile-extension:vscode-custom-editor-tests `
compile-extension:vscode-notebook-tests `
compile-extension:vscode-test-resolver `
}

View file

@ -48,7 +48,6 @@ module.exports.unicodeFilter = [
'!extensions/typescript-language-features/test-workspace/**',
'!extensions/vscode-api-tests/testWorkspace/**',
'!extensions/vscode-api-tests/testWorkspace2/**',
'!extensions/vscode-custom-editor-tests/test-workspace/**',
'!extensions/**/dist/**',
'!extensions/**/out/**',
'!extensions/**/snippets/**',
@ -84,7 +83,6 @@ module.exports.indentationFilter = [
'!extensions/markdown-math/notebook-out/**',
'!extensions/vscode-api-tests/testWorkspace/**',
'!extensions/vscode-api-tests/testWorkspace2/**',
'!extensions/vscode-custom-editor-tests/test-workspace/**',
'!build/monaco/**',
'!build/win32/**',

View file

@ -66,7 +66,6 @@ const compilations = [
'typescript-language-features/tsconfig.json',
'vscode-api-tests/tsconfig.json',
'vscode-colorize-tests/tsconfig.json',
'vscode-custom-editor-tests/tsconfig.json',
'vscode-notebook-tests/tsconfig.json',
'vscode-test-resolver/tsconfig.json'
];

View file

@ -246,7 +246,6 @@ const excludedExtensions = [
'ms-vscode.node-debug',
'ms-vscode.node-debug2',
'vscode-notebook-tests',
'vscode-custom-editor-tests',
];
const marketplaceWebExtensionsExclude = new Set([
'ms-vscode.node-debug',

View file

@ -286,7 +286,6 @@ const excludedExtensions = [
'ms-vscode.node-debug',
'ms-vscode.node-debug2',
'vscode-notebook-tests',
'vscode-custom-editor-tests',
];
const marketplaceWebExtensionsExclude = new Set([

View file

@ -41,7 +41,6 @@ exports.dirs = [
'extensions/typescript-language-features',
'extensions/vscode-api-tests',
'extensions/vscode-colorize-tests',
'extensions/vscode-custom-editor-tests',
'extensions/vscode-notebook-tests',
'extensions/vscode-test-resolver',
'remote',

View file

@ -38,8 +38,10 @@ export function activate(context: vscode.ExtensionContext) {
const contributions = getMarkdownExtensionContributions(context);
context.subscriptions.push(contributions);
const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState);
const logger = new Logger();
context.subscriptions.push(logger);
const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState);
const commandManager = new CommandManager();
const engine = new MarkdownItEngine(contributions, githubSlugifier);
@ -56,7 +58,6 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(registerMarkdownCommands(commandManager, previewManager, telemetryReporter, cspArbiter, engine, tocProvider));
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
logger.updateConfiguration();
previewManager.updateConfiguration();
}));
}

View file

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { Disposable } from './util/dispose';
import { lazy } from './util/lazy';
enum Trace {
@ -25,17 +26,18 @@ namespace Trace {
}
}
function isString(value: any): value is string {
return Object.prototype.toString.call(value) === '[object String]';
}
export class Logger {
export class Logger extends Disposable {
private trace?: Trace;
private readonly outputChannel = lazy(() => vscode.window.createOutputChannel('Markdown'));
private readonly outputChannel = lazy(() => this._register(vscode.window.createOutputChannel('Markdown')));
constructor() {
super();
this._register(vscode.workspace.onDidChangeConfiguration(() => {
this.updateConfiguration();
}));
this.updateConfiguration();
}
@ -48,7 +50,6 @@ export class Logger {
}
}
private now(): string {
const now = new Date();
return String(now.getUTCHours()).padStart(2, '0')
@ -56,12 +57,12 @@ export class Logger {
+ ':' + String(now.getUTCSeconds()).padStart(2, '0') + '.' + now.getMilliseconds();
}
public updateConfiguration() {
private updateConfiguration(): void {
this.trace = this.readTrace();
}
private appendLine(value: string) {
return this.outputChannel.value.appendLine(value);
private appendLine(value: string): void {
this.outputChannel.value.appendLine(value);
}
private readTrace(): Trace {
@ -70,12 +71,12 @@ export class Logger {
private static data2String(data: any): string {
if (data instanceof Error) {
if (isString(data.stack)) {
if (typeof data.stack === 'string') {
return data.stack;
}
return (data as Error).message;
return data.message;
}
if (isString(data)) {
if (typeof data === 'string') {
return data;
}
return JSON.stringify(data, undefined, 2);

View file

@ -1,12 +0,0 @@
test/**
test-workspace/**
src/**
tsconfig.json
out/test/**
out/**
extension.webpack.config.js
extension-browser.webpack.config.js
cgmanifest.json
yarn.lock
preview-src/**
webpack.config.js

View file

@ -1,56 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
(function () {
// @ts-ignore
const vscode = acquireVsCodeApi();
const textArea = document.querySelector('textarea');
const initialState = vscode.getState();
if (initialState) {
textArea.value = initialState.value;
}
window.addEventListener('message', e => {
switch (e.data.type) {
case 'fakeInput':
{
const value = e.data.value;
textArea.value = value;
onInput();
break;
}
case 'setValue':
{
const value = e.data.value;
textArea.value = value;
vscode.setState({ value });
vscode.postMessage({
type: 'didChangeContent',
value: value
});
break;
}
}
});
const onInput = () => {
const value = textArea.value;
vscode.setState({ value });
vscode.postMessage({
type: 'edit',
value: value
});
vscode.postMessage({
type: 'didChangeContent',
value: value
});
};
textArea.addEventListener('input', onInput);
}());

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -1,45 +0,0 @@
{
"name": "vscode-custom-editor-tests",
"description": "Custom editor tests for VS Code",
"version": "0.0.1",
"publisher": "vscode",
"license": "MIT",
"private": true,
"activationEvents": [
"onCustomEditor:testWebviewEditor.abc"
],
"main": "./out/extension",
"engines": {
"vscode": "^1.48.0"
},
"icon": "media/icon.png",
"scripts": {
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:vscode-notebook-tests ./tsconfig.json"
},
"dependencies": {
"p-limit": "^3.0.2"
},
"devDependencies": {
"@types/mocha": "^9.1.1",
"@types/node": "16.x",
"@types/p-limit": "^2.2.0"
},
"contributes": {
"customEditors": [
{
"viewType": "testWebviewEditor.abc",
"displayName": "Test ABC editor",
"selector": [
{
"filenamePattern": "*.abc"
}
]
}
]
},
"repository": {
"type": "git",
"url": "https://github.com/microsoft/vscode.git"
}
}

View file

@ -1,174 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as pLimit from 'p-limit';
import * as path from 'path';
import * as vscode from 'vscode';
import { Disposable } from './dispose';
export namespace Testing {
export const abcEditorContentChangeCommand = '_abcEditor.contentChange';
export const abcEditorTypeCommand = '_abcEditor.type';
export interface CustomEditorContentChangeEvent {
readonly content: string;
readonly source: vscode.Uri;
}
}
export class AbcTextEditorProvider implements vscode.CustomTextEditorProvider {
public static readonly viewType = 'testWebviewEditor.abc';
private activeEditor?: AbcEditor;
public constructor(
private readonly context: vscode.ExtensionContext,
) { }
public register(): vscode.Disposable {
const provider = vscode.window.registerCustomEditorProvider(AbcTextEditorProvider.viewType, this);
const commands: vscode.Disposable[] = [];
commands.push(vscode.commands.registerCommand(Testing.abcEditorTypeCommand, (content: string) => {
this.activeEditor?.testing_fakeInput(content);
}));
return vscode.Disposable.from(provider, ...commands);
}
public async resolveCustomTextEditor(document: vscode.TextDocument, panel: vscode.WebviewPanel) {
const editor = new AbcEditor(document, this.context.extensionPath, panel);
this.activeEditor = editor;
panel.onDidChangeViewState(({ webviewPanel }) => {
if (this.activeEditor === editor && !webviewPanel.active) {
this.activeEditor = undefined;
}
if (webviewPanel.active) {
this.activeEditor = editor;
}
});
}
}
class AbcEditor extends Disposable {
public readonly _onDispose = this._register(new vscode.EventEmitter<void>());
public readonly onDispose = this._onDispose.event;
private readonly limit = pLimit(1);
private syncedVersion: number = -1;
private currentWorkspaceEdit?: Thenable<void>;
constructor(
private readonly document: vscode.TextDocument,
private readonly _extensionPath: string,
private readonly panel: vscode.WebviewPanel,
) {
super();
panel.webview.options = {
enableScripts: true,
};
panel.webview.html = this.html;
this._register(vscode.workspace.onDidChangeTextDocument(e => {
if (e.document === this.document) {
this.update();
}
}));
this._register(panel.webview.onDidReceiveMessage(message => {
switch (message.type) {
case 'edit':
this.doEdit(message.value);
break;
case 'didChangeContent':
vscode.commands.executeCommand(Testing.abcEditorContentChangeCommand, {
content: message.value,
source: document.uri,
} as Testing.CustomEditorContentChangeEvent);
break;
}
}));
this._register(panel.onDidDispose(() => { this.dispose(); }));
this.update();
}
public testing_fakeInput(value: string) {
this.panel.webview.postMessage({
type: 'fakeInput',
value: value,
});
}
private async doEdit(value: string) {
const edit = new vscode.WorkspaceEdit();
edit.replace(this.document.uri, this.document.validateRange(new vscode.Range(new vscode.Position(0, 0), new vscode.Position(999999, 999999))), value);
this.limit(() => {
this.currentWorkspaceEdit = vscode.workspace.applyEdit(edit).then(() => {
this.syncedVersion = this.document.version;
this.currentWorkspaceEdit = undefined;
});
return this.currentWorkspaceEdit;
});
}
public override dispose() {
if (this.isDisposed) {
return;
}
this._onDispose.fire();
super.dispose();
}
private get html() {
const contentRoot = path.join(this._extensionPath, 'customEditorMedia');
const scriptUri = vscode.Uri.file(path.join(contentRoot, 'textEditor.js'));
const nonce = getNonce();
return /* html */`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-${nonce}'; style-src 'unsafe-inline';">
<title>Document</title>
</head>
<body>
<textarea style="width: 300px; height: 300px;"></textarea>
<script nonce=${nonce} src="${this.panel.webview.asWebviewUri(scriptUri)}"></script>
</body>
</html>`;
}
public async update() {
await this.currentWorkspaceEdit;
if (this.isDisposed || this.syncedVersion >= this.document.version) {
return;
}
this.panel.webview.postMessage({
type: 'setValue',
value: this.document.getText(),
});
this.syncedVersion = this.document.version;
}
}
function getNonce() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 64; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}

View file

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export function disposeAll(disposables: vscode.Disposable[]) {
while (disposables.length) {
const item = disposables.pop();
if (item) {
item.dispose();
}
}
}
export abstract class Disposable {
private _isDisposed = false;
protected _disposables: vscode.Disposable[] = [];
public dispose(): any {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
disposeAll(this._disposables);
}
protected _register<T extends vscode.Disposable>(value: T): T {
if (this._isDisposed) {
value.dispose();
} else {
this._disposables.push(value);
}
return value;
}
protected get isDisposed() {
return this._isDisposed;
}
}

View file

@ -1,11 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { AbcTextEditorProvider } from './customTextEditor';
export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(new AbcTextEditorProvider(context).register());
}

View file

@ -1,316 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import * as assert from 'assert';
import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
import { Testing } from '../customTextEditor';
import { closeAllEditors, delay, disposeAll, randomFilePath } from './utils';
assert.ok(vscode.workspace.rootPath);
const testWorkspaceRoot = vscode.Uri.file(path.join(vscode.workspace.rootPath!, 'customEditors'));
const commands = Object.freeze({
open: 'vscode.open',
openWith: 'vscode.openWith',
save: 'workbench.action.files.save',
undo: 'undo',
});
async function writeRandomFile(options: { ext: string; contents: string }): Promise<vscode.Uri> {
const fakeFile = randomFilePath({ root: testWorkspaceRoot, ext: options.ext });
await fs.promises.writeFile(fakeFile.fsPath, Buffer.from(options.contents));
return fakeFile;
}
const disposables: vscode.Disposable[] = [];
function _register<T extends vscode.Disposable>(disposable: T) {
disposables.push(disposable);
return disposable;
}
class CustomEditorUpdateListener {
public static create() {
return _register(new CustomEditorUpdateListener());
}
private readonly commandSubscription: vscode.Disposable;
private readonly unconsumedResponses: Array<Testing.CustomEditorContentChangeEvent> = [];
private readonly callbackQueue: Array<(data: Testing.CustomEditorContentChangeEvent) => void> = [];
private constructor() {
this.commandSubscription = vscode.commands.registerCommand(Testing.abcEditorContentChangeCommand, (data: Testing.CustomEditorContentChangeEvent) => {
if (this.callbackQueue.length) {
const callback = this.callbackQueue.shift();
assert.ok(callback);
callback!(data);
} else {
this.unconsumedResponses.push(data);
}
});
}
dispose() {
this.commandSubscription.dispose();
}
async nextResponse(): Promise<Testing.CustomEditorContentChangeEvent> {
if (this.unconsumedResponses.length) {
return this.unconsumedResponses.shift()!;
}
return new Promise(resolve => {
this.callbackQueue.push(resolve);
});
}
}
suite('CustomEditor tests', () => {
setup(async () => {
await closeAllEditors();
await resetTestWorkspace();
});
teardown(async () => {
await closeAllEditors();
disposeAll(disposables);
await resetTestWorkspace();
});
test('Should load basic content from disk', async () => {
const startingContent = `load, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
const { content } = await listener.nextResponse();
assert.strictEqual(content, startingContent);
});
test('Should support basic edits', async () => {
const startingContent = `basic edit, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
await listener.nextResponse();
const newContent = `basic edit test`;
await vscode.commands.executeCommand(Testing.abcEditorTypeCommand, newContent);
const { content } = await listener.nextResponse();
assert.strictEqual(content, newContent);
});
test('Should support single undo', async () => {
const startingContent = `single undo, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
await listener.nextResponse();
const newContent = `undo test`;
{
await vscode.commands.executeCommand(Testing.abcEditorTypeCommand, newContent);
const { content } = await listener.nextResponse();
assert.strictEqual(content, newContent);
}
await delay(100);
{
await vscode.commands.executeCommand(commands.undo);
const { content } = await listener.nextResponse();
assert.strictEqual(content, startingContent);
}
});
test('Should support multiple undo', async () => {
const startingContent = `multiple undo, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
await listener.nextResponse();
const count = 10;
// Make edits
for (let i = 0; i < count; ++i) {
await vscode.commands.executeCommand(Testing.abcEditorTypeCommand, `${i}`);
const { content } = await listener.nextResponse();
assert.strictEqual(`${i}`, content);
}
// Then undo them in order
for (let i = count - 1; i; --i) {
await delay(100);
await vscode.commands.executeCommand(commands.undo);
const { content } = await listener.nextResponse();
assert.strictEqual(`${i - 1}`, content);
}
{
await delay(100);
await vscode.commands.executeCommand(commands.undo);
const { content } = await listener.nextResponse();
assert.strictEqual(content, startingContent);
}
});
test('Should update custom editor on file move', async () => {
const startingContent = `file move, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
await listener.nextResponse();
const newFileName = vscode.Uri.file(path.join(testWorkspaceRoot.fsPath, 'y.abc'));
const edit = new vscode.WorkspaceEdit();
edit.renameFile(testDocument, newFileName);
await vscode.workspace.applyEdit(edit);
const response = (await listener.nextResponse());
assert.strictEqual(response.content, startingContent);
assert.strictEqual(response.source.toString(), newFileName.toString());
});
test('Should support saving custom editors', async () => {
const startingContent = `save, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
await listener.nextResponse();
const newContent = `save, new`;
{
await vscode.commands.executeCommand(Testing.abcEditorTypeCommand, newContent);
const { content } = await listener.nextResponse();
assert.strictEqual(content, newContent);
}
{
await vscode.commands.executeCommand(commands.save);
const fileContent = (await fs.promises.readFile(testDocument.fsPath)).toString();
assert.strictEqual(fileContent, newContent);
}
});
test('Should undo after saving custom editor', async () => {
const startingContent = `undo after save, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
await listener.nextResponse();
const newContent = `undo after save, new`;
{
await vscode.commands.executeCommand(Testing.abcEditorTypeCommand, newContent);
const { content } = await listener.nextResponse();
assert.strictEqual(content, newContent);
}
{
await vscode.commands.executeCommand(commands.save);
const fileContent = (await fs.promises.readFile(testDocument.fsPath)).toString();
assert.strictEqual(fileContent, newContent);
}
await delay(100);
{
await vscode.commands.executeCommand(commands.undo);
const { content } = await listener.nextResponse();
assert.strictEqual(content, startingContent);
}
});
test.skip('Should support untitled custom editors', async () => {
const listener = CustomEditorUpdateListener.create();
const untitledFile = randomFilePath({ root: testWorkspaceRoot, ext: '.abc' }).with({ scheme: 'untitled' });
await vscode.commands.executeCommand(commands.open, untitledFile);
assert.strictEqual((await listener.nextResponse()).content, '');
await vscode.commands.executeCommand(Testing.abcEditorTypeCommand, `123`);
assert.strictEqual((await listener.nextResponse()).content, '123');
await vscode.commands.executeCommand(commands.save);
const content = await fs.promises.readFile(untitledFile.fsPath);
assert.strictEqual(content.toString(), '123');
});
test.skip('When switching away from a non-default custom editors and then back, we should continue using the non-default editor', async () => {
const startingContent = `switch, init`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
{
await vscode.commands.executeCommand(commands.open, testDocument, { preview: false });
const { content } = await listener.nextResponse();
assert.strictEqual(content, startingContent.toString());
const activeEditor = vscode.window.activeTextEditor;
assert.ok(!activeEditor);
}
// Switch to non-default editor
await vscode.commands.executeCommand(commands.openWith, testDocument, 'default', { preview: false });
assert.strictEqual(vscode.window.activeTextEditor!?.document.uri.toString(), testDocument.toString());
// Then open a new document (hiding existing one)
const otherFile = vscode.Uri.file(path.join(testWorkspaceRoot.fsPath, 'other.json'));
await vscode.commands.executeCommand(commands.open, otherFile);
assert.strictEqual(vscode.window.activeTextEditor!?.document.uri.toString(), otherFile.toString());
// And then back
await vscode.commands.executeCommand('workbench.action.navigateBack');
await vscode.commands.executeCommand('workbench.action.navigateBack');
// Make sure we have the file on as text
assert.ok(vscode.window.activeTextEditor);
assert.strictEqual(vscode.window.activeTextEditor!?.document.uri.toString(), testDocument.toString());
});
test('Should release the text document when the editor is closed', async () => {
const startingContent = `release document init,`;
const testDocument = await writeRandomFile({ ext: '.abc', contents: startingContent });
const listener = CustomEditorUpdateListener.create();
await vscode.commands.executeCommand(commands.open, testDocument);
await listener.nextResponse();
const doc = vscode.workspace.textDocuments.find(x => x.uri.toString() === testDocument.toString());
assert.ok(doc);
assert.ok(!doc!.isClosed);
await closeAllEditors();
await delay(100);
assert.ok(doc!.isClosed);
});
});
async function resetTestWorkspace() {
try {
await vscode.workspace.fs.delete(testWorkspaceRoot, { recursive: true });
} catch {
// ok if file doesn't exist
}
await vscode.workspace.fs.createDirectory(testWorkspaceRoot);
}

View file

@ -1,30 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const testRunner = require('../../../../test/integration/electron/testrunner');
const suite = 'Custom Editor Tests';
const options: any = {
ui: 'tdd',
color: true,
timeout: 60000
};
if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
options.reporter = 'mocha-multi-reporters';
options.reporterOptions = {
reporterEnabled: 'spec, mocha-junit-reporter',
mochaJunitReporterReporterOptions: {
testsuitesTitle: `${suite} ${process.platform}`,
mochaFile: path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${process.arch}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`)
}
};
}
testRunner.configure(options);
export = testRunner;

View file

@ -1,32 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export function randomFilePath(args: { root: vscode.Uri; ext: string }): vscode.Uri {
const fileName = rndName();
return vscode.Uri.joinPath(args.root, fileName + args.ext);
}
export function rndName() {
let name = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 10; i++) {
name += possible.charAt(Math.floor(Math.random() * possible.length));
}
return name;
}
export function closeAllEditors(): Thenable<any> {
return vscode.commands.executeCommand('workbench.action.closeAllEditors');
}
export function disposeAll(disposables: vscode.Disposable[]) {
vscode.Disposable.from(...disposables).dispose();
}
export function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

View file

@ -1,13 +0,0 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "./out",
"types": [
"node"
]
},
"include": [
"src/**/*",
"../../src/vscode-dts/vscode.d.ts"
]
}

View file

@ -1,32 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/mocha@^9.1.1":
version "9.1.1"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4"
integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==
"@types/node@16.x":
version "16.11.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==
"@types/p-limit@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@types/p-limit/-/p-limit-2.2.0.tgz#94a608e9b258a6c6156a13d1a14fd720dba70b97"
integrity sha512-fGFbybl1r0oE9mqgfc2EHHUin9ZL5rbQIexWI6jYRU1ADVn4I3LHzT+g/kpPpZsfp8PB94CQ655pfAjNF8LP6A==
dependencies:
p-limit "*"
p-limit@*, p-limit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.0.2.tgz#1664e010af3cadc681baafd3e2a437be7b0fb5fe"
integrity sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg==
dependencies:
p-try "^2.0.0"
p-try@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==

View file

@ -25,7 +25,6 @@ if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" (
:: compile-extension:vscode-colorize-tests^
:: compile-extension:markdown-language-features^
:: compile-extension:typescript-language-features^
:: compile-extension:vscode-custom-editor-tests^
:: compile-extension:vscode-notebook-tests^
:: compile-extension:emmet^
:: compile-extension:css-language-features-server^

View file

@ -32,7 +32,6 @@ else
# and the build bundles extensions into .build webpacked
# yarn gulp compile-extension:vscode-api-tests \
# compile-extension:vscode-colorize-tests \
# compile-extension:vscode-custom-editor-tests \
# compile-extension:vscode-notebook-tests \
# compile-extension:markdown-language-features \
# compile-extension:typescript-language-features \