mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
81
src/vs/base/test/browser/ui/menu/menubar.test.ts
Normal file
81
src/vs/base/test/browser/ui/menu/menubar.test.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { $ } from 'vs/base/browser/dom';
|
||||
import { MenuBar } from 'vs/base/browser/ui/menu/menubar';
|
||||
|
||||
function getButtonElementByAriaLabel(menubarElement: HTMLElement, ariaLabel: string): HTMLElement | null {
|
||||
let i;
|
||||
for (i = 0; i < menubarElement.childElementCount; i++) {
|
||||
|
||||
if (menubarElement.children[i].getAttribute('aria-label') === ariaLabel) {
|
||||
return menubarElement.children[i] as HTMLElement;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getTitleDivFromButtonDiv(menuButtonElement: HTMLElement): HTMLElement | null {
|
||||
let i;
|
||||
for (i = 0; i < menuButtonElement.childElementCount; i++) {
|
||||
if (menuButtonElement.children[i].classList.contains('menubar-menu-title')) {
|
||||
return menuButtonElement.children[i] as HTMLElement;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getMnemonicFromTitleDiv(menuTitleDiv: HTMLElement): string | null {
|
||||
let i;
|
||||
for (i = 0; i < menuTitleDiv.childElementCount; i++) {
|
||||
if (menuTitleDiv.children[i].tagName.toLocaleLowerCase() === 'mnemonic') {
|
||||
return menuTitleDiv.children[i].textContent;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateMenuBarItem(menubar: MenuBar, menubarContainer: HTMLElement, label: string, readableLabel: string, mnemonic: string) {
|
||||
menubar.push([
|
||||
{
|
||||
actions: [],
|
||||
label: label
|
||||
}
|
||||
]);
|
||||
|
||||
const buttonElement = getButtonElementByAriaLabel(menubarContainer, readableLabel);
|
||||
assert(buttonElement !== null, `Button element not found for ${readableLabel} button.`);
|
||||
|
||||
const titleDiv = getTitleDivFromButtonDiv(buttonElement!);
|
||||
assert(titleDiv !== null, `Title div not found for ${readableLabel} button.`);
|
||||
|
||||
const mnem = getMnemonicFromTitleDiv(titleDiv!);
|
||||
assert.equal(mnem, mnemonic, 'Mnemonic not correct');
|
||||
}
|
||||
|
||||
suite('Menubar', () => {
|
||||
const container = $('.container');
|
||||
|
||||
const menubar = new MenuBar(container, {
|
||||
enableMnemonics: true,
|
||||
visibility: 'visible'
|
||||
});
|
||||
|
||||
test('English File menu renders mnemonics', function () {
|
||||
validateMenuBarItem(menubar, container, '&File', 'File', 'F');
|
||||
});
|
||||
|
||||
test('Russian File menu renders mnemonics', function () {
|
||||
validateMenuBarItem(menubar, container, '&Файл', 'Файл', 'Ф');
|
||||
});
|
||||
|
||||
test('Chinese File menu renders mnemonics', function () {
|
||||
validateMenuBarItem(menubar, container, '文件(&F)', '文件', 'F');
|
||||
});
|
||||
});
|
||||
@@ -101,4 +101,229 @@ suite('AsyncDataTree', function () {
|
||||
await tree.updateChildren(root);
|
||||
assert.equal(container.querySelectorAll('.monaco-list-row').length, 1);
|
||||
});
|
||||
|
||||
test('issue #68648', async () => {
|
||||
const container = document.createElement('div');
|
||||
container.style.width = '200px';
|
||||
container.style.height = '200px';
|
||||
|
||||
const delegate = new class implements IListVirtualDelegate<Element> {
|
||||
getHeight() { return 20; }
|
||||
getTemplateId(element: Element): string { return 'default'; }
|
||||
};
|
||||
|
||||
const renderer = new class implements ITreeRenderer<Element, void, HTMLElement> {
|
||||
readonly templateId = 'default';
|
||||
renderTemplate(container: HTMLElement): HTMLElement {
|
||||
return container;
|
||||
}
|
||||
renderElement(element: ITreeNode<Element, void>, index: number, templateData: HTMLElement): void {
|
||||
templateData.textContent = element.element.id;
|
||||
}
|
||||
disposeTemplate(templateData: HTMLElement): void {
|
||||
// noop
|
||||
}
|
||||
};
|
||||
|
||||
const getChildrenCalls: string[] = [];
|
||||
const dataSource = new class implements IAsyncDataSource<Element, Element> {
|
||||
hasChildren(element: Element): boolean {
|
||||
return !!element.children && element.children.length > 0;
|
||||
}
|
||||
getChildren(element: Element): Promise<Element[]> {
|
||||
getChildrenCalls.push(element.id);
|
||||
return Promise.resolve(element.children || []);
|
||||
}
|
||||
};
|
||||
|
||||
const identityProvider = new class implements IIdentityProvider<Element> {
|
||||
getId(element: Element) {
|
||||
return element.id;
|
||||
}
|
||||
};
|
||||
|
||||
const root: Element = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'a'
|
||||
}]
|
||||
};
|
||||
|
||||
const _: (id: string) => Element = find.bind(null, root.children);
|
||||
|
||||
const tree = new AsyncDataTree<Element, Element>(container, delegate, [renderer], dataSource, { identityProvider });
|
||||
tree.layout(200);
|
||||
|
||||
await tree.setInput(root);
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root']);
|
||||
|
||||
let twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement;
|
||||
assert(!hasClass(twistie, 'collapsible'));
|
||||
assert(!hasClass(twistie, 'collapsed'));
|
||||
assert(tree.getNode().children[0].collapsed);
|
||||
|
||||
_('a').children = [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }];
|
||||
await tree.updateChildren(root);
|
||||
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root', 'root']);
|
||||
twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement;
|
||||
assert(hasClass(twistie, 'collapsible'));
|
||||
assert(hasClass(twistie, 'collapsed'));
|
||||
assert(tree.getNode().children[0].collapsed);
|
||||
|
||||
_('a').children = [];
|
||||
await tree.updateChildren(root);
|
||||
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root', 'root', 'root']);
|
||||
twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement;
|
||||
assert(!hasClass(twistie, 'collapsible'));
|
||||
assert(!hasClass(twistie, 'collapsed'));
|
||||
assert(tree.getNode().children[0].collapsed);
|
||||
|
||||
_('a').children = [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }];
|
||||
await tree.updateChildren(root);
|
||||
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root', 'root', 'root', 'root']);
|
||||
twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement;
|
||||
assert(hasClass(twistie, 'collapsible'));
|
||||
assert(hasClass(twistie, 'collapsed'));
|
||||
assert(tree.getNode().children[0].collapsed);
|
||||
});
|
||||
|
||||
test('issue #67722 - once resolved, refreshed collapsed nodes should only get children when expanded', async () => {
|
||||
const container = document.createElement('div');
|
||||
container.style.width = '200px';
|
||||
container.style.height = '200px';
|
||||
|
||||
const delegate = new class implements IListVirtualDelegate<Element> {
|
||||
getHeight() { return 20; }
|
||||
getTemplateId(element: Element): string { return 'default'; }
|
||||
};
|
||||
|
||||
const renderer = new class implements ITreeRenderer<Element, void, HTMLElement> {
|
||||
readonly templateId = 'default';
|
||||
renderTemplate(container: HTMLElement): HTMLElement {
|
||||
return container;
|
||||
}
|
||||
renderElement(element: ITreeNode<Element, void>, index: number, templateData: HTMLElement): void {
|
||||
templateData.textContent = element.element.id;
|
||||
}
|
||||
disposeTemplate(templateData: HTMLElement): void {
|
||||
// noop
|
||||
}
|
||||
};
|
||||
|
||||
const getChildrenCalls: string[] = [];
|
||||
const dataSource = new class implements IAsyncDataSource<Element, Element> {
|
||||
hasChildren(element: Element): boolean {
|
||||
return !!element.children && element.children.length > 0;
|
||||
}
|
||||
getChildren(element: Element): Promise<Element[]> {
|
||||
getChildrenCalls.push(element.id);
|
||||
return Promise.resolve(element.children || []);
|
||||
}
|
||||
};
|
||||
|
||||
const identityProvider = new class implements IIdentityProvider<Element> {
|
||||
getId(element: Element) {
|
||||
return element.id;
|
||||
}
|
||||
};
|
||||
|
||||
const root: Element = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'a', children: [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }]
|
||||
}]
|
||||
};
|
||||
|
||||
const _: (id: string) => Element = find.bind(null, root.children);
|
||||
|
||||
const tree = new AsyncDataTree<Element, Element>(container, delegate, [renderer], dataSource, { identityProvider });
|
||||
tree.layout(200);
|
||||
|
||||
await tree.setInput(root);
|
||||
assert(tree.getNode(_('a')).collapsed);
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root']);
|
||||
|
||||
await tree.expand(_('a'));
|
||||
assert(!tree.getNode(_('a')).collapsed);
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root', 'a']);
|
||||
|
||||
tree.collapse(_('a'));
|
||||
assert(tree.getNode(_('a')).collapsed);
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root', 'a']);
|
||||
|
||||
await tree.updateChildren();
|
||||
assert(tree.getNode(_('a')).collapsed);
|
||||
assert.deepStrictEqual(getChildrenCalls, ['root', 'a', 'root'], 'a should not be refreshed, since it\' collapsed');
|
||||
});
|
||||
|
||||
test('resolved collapsed nodes which lose children should lose twistie as well', async () => {
|
||||
const container = document.createElement('div');
|
||||
container.style.width = '200px';
|
||||
container.style.height = '200px';
|
||||
|
||||
const delegate = new class implements IListVirtualDelegate<Element> {
|
||||
getHeight() { return 20; }
|
||||
getTemplateId(element: Element): string { return 'default'; }
|
||||
};
|
||||
|
||||
const renderer = new class implements ITreeRenderer<Element, void, HTMLElement> {
|
||||
readonly templateId = 'default';
|
||||
renderTemplate(container: HTMLElement): HTMLElement {
|
||||
return container;
|
||||
}
|
||||
renderElement(element: ITreeNode<Element, void>, index: number, templateData: HTMLElement): void {
|
||||
templateData.textContent = element.element.id;
|
||||
}
|
||||
disposeTemplate(templateData: HTMLElement): void {
|
||||
// noop
|
||||
}
|
||||
};
|
||||
|
||||
const dataSource = new class implements IAsyncDataSource<Element, Element> {
|
||||
hasChildren(element: Element): boolean {
|
||||
return !!element.children && element.children.length > 0;
|
||||
}
|
||||
getChildren(element: Element): Promise<Element[]> {
|
||||
return Promise.resolve(element.children || []);
|
||||
}
|
||||
};
|
||||
|
||||
const identityProvider = new class implements IIdentityProvider<Element> {
|
||||
getId(element: Element) {
|
||||
return element.id;
|
||||
}
|
||||
};
|
||||
|
||||
const root: Element = {
|
||||
id: 'root',
|
||||
children: [{
|
||||
id: 'a', children: [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }]
|
||||
}]
|
||||
};
|
||||
|
||||
const _: (id: string) => Element = find.bind(null, root.children);
|
||||
|
||||
const tree = new AsyncDataTree<Element, Element>(container, delegate, [renderer], dataSource, { identityProvider });
|
||||
tree.layout(200);
|
||||
|
||||
await tree.setInput(root);
|
||||
await tree.expand(_('a'));
|
||||
|
||||
let twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement;
|
||||
assert(hasClass(twistie, 'collapsible'));
|
||||
assert(!hasClass(twistie, 'collapsed'));
|
||||
assert(!tree.getNode(_('a')).collapsed);
|
||||
|
||||
tree.collapse(_('a'));
|
||||
_('a').children = [];
|
||||
await tree.updateChildren(root);
|
||||
|
||||
twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement;
|
||||
assert(!hasClass(twistie, 'collapsible'));
|
||||
assert(!hasClass(twistie, 'collapsed'));
|
||||
assert(tree.getNode(_('a')).collapsed);
|
||||
});
|
||||
});
|
||||
@@ -168,4 +168,77 @@ suite('ObjectTreeModel', function () {
|
||||
model.setChildren(null, data);
|
||||
assert.deepEqual(toArray(list), ['father']);
|
||||
});
|
||||
|
||||
test('sorter', () => {
|
||||
let compare: (a: string, b: string) => number = (a, b) => a < b ? -1 : 1;
|
||||
|
||||
const list: ITreeNode<string>[] = [];
|
||||
const model = new ObjectTreeModel<string>(toSpliceable(list), { sorter: { compare(a, b) { return compare(a, b); } } });
|
||||
const data = [
|
||||
{ element: 'cars', children: [{ element: 'sedan' }, { element: 'convertible' }, { element: 'compact' }] },
|
||||
{ element: 'airplanes', children: [{ element: 'passenger' }, { element: 'jet' }] },
|
||||
{ element: 'bicycles', children: [{ element: 'dutch' }, { element: 'mountain' }, { element: 'electric' }] },
|
||||
];
|
||||
|
||||
model.setChildren(null, data);
|
||||
assert.deepEqual(toArray(list), ['airplanes', 'jet', 'passenger', 'bicycles', 'dutch', 'electric', 'mountain', 'cars', 'compact', 'convertible', 'sedan']);
|
||||
});
|
||||
|
||||
test('resort', () => {
|
||||
let compare: (a: string, b: string) => number = () => 0;
|
||||
|
||||
const list: ITreeNode<string>[] = [];
|
||||
const model = new ObjectTreeModel<string>(toSpliceable(list), { sorter: { compare(a, b) { return compare(a, b); } } });
|
||||
const data = [
|
||||
{ element: 'cars', children: [{ element: 'sedan' }, { element: 'convertible' }, { element: 'compact' }] },
|
||||
{ element: 'airplanes', children: [{ element: 'passenger' }, { element: 'jet' }] },
|
||||
{ element: 'bicycles', children: [{ element: 'dutch' }, { element: 'mountain' }, { element: 'electric' }] },
|
||||
];
|
||||
|
||||
model.setChildren(null, data);
|
||||
assert.deepEqual(toArray(list), ['cars', 'sedan', 'convertible', 'compact', 'airplanes', 'passenger', 'jet', 'bicycles', 'dutch', 'mountain', 'electric']);
|
||||
|
||||
// lexicographical
|
||||
compare = (a, b) => a < b ? -1 : 1;
|
||||
|
||||
// non-recursive
|
||||
model.resort(null, false);
|
||||
assert.deepEqual(toArray(list), ['airplanes', 'passenger', 'jet', 'bicycles', 'dutch', 'mountain', 'electric', 'cars', 'sedan', 'convertible', 'compact']);
|
||||
|
||||
// recursive
|
||||
model.resort();
|
||||
assert.deepEqual(toArray(list), ['airplanes', 'jet', 'passenger', 'bicycles', 'dutch', 'electric', 'mountain', 'cars', 'compact', 'convertible', 'sedan']);
|
||||
|
||||
// reverse
|
||||
compare = (a, b) => a < b ? 1 : -1;
|
||||
|
||||
// scoped
|
||||
model.resort('cars');
|
||||
assert.deepEqual(toArray(list), ['airplanes', 'jet', 'passenger', 'bicycles', 'dutch', 'electric', 'mountain', 'cars', 'sedan', 'convertible', 'compact']);
|
||||
|
||||
// recursive
|
||||
model.resort();
|
||||
assert.deepEqual(toArray(list), ['cars', 'sedan', 'convertible', 'compact', 'bicycles', 'mountain', 'electric', 'dutch', 'airplanes', 'passenger', 'jet']);
|
||||
});
|
||||
|
||||
test('expandTo', () => {
|
||||
const list: ITreeNode<number>[] = [];
|
||||
const model = new ObjectTreeModel<number>(toSpliceable(list), { collapseByDefault: true });
|
||||
|
||||
model.setChildren(null, [
|
||||
{
|
||||
element: 0, children: [
|
||||
{ element: 10, children: [{ element: 100, children: [{ element: 1000 }] }] },
|
||||
{ element: 11 },
|
||||
{ element: 12 },
|
||||
]
|
||||
},
|
||||
{ element: 1 },
|
||||
{ element: 2 }
|
||||
]);
|
||||
|
||||
assert.deepEqual(toArray(list), [0, 1, 2]);
|
||||
model.expandTo(1000);
|
||||
assert.deepEqual(toArray(list), [0, 10, 100, 1000, 11, 12, 1, 2]);
|
||||
});
|
||||
});
|
||||
68
src/vs/base/test/common/extpath.test.ts
Normal file
68
src/vs/base/test/common/extpath.test.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as extpath from 'vs/base/common/extpath';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
|
||||
suite('Paths', () => {
|
||||
|
||||
test('toForwardSlashes', () => {
|
||||
assert.equal(extpath.toSlashes('\\\\server\\share\\some\\path'), '//server/share/some/path');
|
||||
assert.equal(extpath.toSlashes('c:\\test'), 'c:/test');
|
||||
assert.equal(extpath.toSlashes('foo\\bar'), 'foo/bar');
|
||||
assert.equal(extpath.toSlashes('/user/far'), '/user/far');
|
||||
});
|
||||
|
||||
test('getRoot', () => {
|
||||
|
||||
assert.equal(extpath.getRoot('/user/far'), '/');
|
||||
assert.equal(extpath.getRoot('\\\\server\\share\\some\\path'), '//server/share/');
|
||||
assert.equal(extpath.getRoot('//server/share/some/path'), '//server/share/');
|
||||
assert.equal(extpath.getRoot('//server/share'), '/');
|
||||
assert.equal(extpath.getRoot('//server'), '/');
|
||||
assert.equal(extpath.getRoot('//server//'), '/');
|
||||
assert.equal(extpath.getRoot('c:/user/far'), 'c:/');
|
||||
assert.equal(extpath.getRoot('c:user/far'), 'c:');
|
||||
assert.equal(extpath.getRoot('http://www'), '');
|
||||
assert.equal(extpath.getRoot('http://www/'), 'http://www/');
|
||||
assert.equal(extpath.getRoot('file:///foo'), 'file:///');
|
||||
assert.equal(extpath.getRoot('file://foo'), '');
|
||||
|
||||
});
|
||||
|
||||
test('isUNC', () => {
|
||||
if (platform.isWindows) {
|
||||
assert.ok(!extpath.isUNC('foo'));
|
||||
assert.ok(!extpath.isUNC('/foo'));
|
||||
assert.ok(!extpath.isUNC('\\foo'));
|
||||
assert.ok(!extpath.isUNC('\\\\foo'));
|
||||
assert.ok(extpath.isUNC('\\\\a\\b'));
|
||||
assert.ok(!extpath.isUNC('//a/b'));
|
||||
assert.ok(extpath.isUNC('\\\\server\\share'));
|
||||
assert.ok(extpath.isUNC('\\\\server\\share\\'));
|
||||
assert.ok(extpath.isUNC('\\\\server\\share\\path'));
|
||||
}
|
||||
});
|
||||
|
||||
test('isValidBasename', () => {
|
||||
assert.ok(!extpath.isValidBasename(null));
|
||||
assert.ok(!extpath.isValidBasename(''));
|
||||
assert.ok(extpath.isValidBasename('test.txt'));
|
||||
assert.ok(!extpath.isValidBasename('/test.txt'));
|
||||
assert.ok(!extpath.isValidBasename('\\test.txt'));
|
||||
|
||||
if (platform.isWindows) {
|
||||
assert.ok(!extpath.isValidBasename('aux'));
|
||||
assert.ok(!extpath.isValidBasename('Aux'));
|
||||
assert.ok(!extpath.isValidBasename('LPT0'));
|
||||
assert.ok(!extpath.isValidBasename('test.txt.'));
|
||||
assert.ok(!extpath.isValidBasename('test.txt..'));
|
||||
assert.ok(!extpath.isValidBasename('test.txt '));
|
||||
assert.ok(!extpath.isValidBasename('test.txt\t'));
|
||||
assert.ok(!extpath.isValidBasename('tes:t.txt'));
|
||||
assert.ok(!extpath.isValidBasename('tes"t.txt'));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -20,35 +20,35 @@ suite('keyCodes', () => {
|
||||
}
|
||||
|
||||
test(null, 0);
|
||||
test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter), KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, false, KeyCode.Enter), KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter), KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, false, KeyCode.Enter), KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, false, KeyCode.Enter), KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, false, KeyCode.Enter), KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, false, KeyCode.Enter), KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, false, KeyCode.Enter), KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, false, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter).toChord(), KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, false, KeyCode.Enter).toChord(), KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter).toChord(), KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, false, KeyCode.Enter).toChord(), KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, false, KeyCode.Enter).toChord(), KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, false, KeyCode.Enter).toChord(), KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, false, KeyCode.Enter).toChord(), KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, false, KeyCode.Enter).toChord(), KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, false, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
|
||||
test(
|
||||
new ChordKeybinding(
|
||||
new ChordKeybinding([
|
||||
new SimpleKeybinding(false, false, false, false, KeyCode.Enter),
|
||||
new SimpleKeybinding(false, false, false, false, KeyCode.Tab)
|
||||
),
|
||||
]),
|
||||
KeyChord(KeyCode.Enter, KeyCode.Tab)
|
||||
);
|
||||
test(
|
||||
new ChordKeybinding(
|
||||
new ChordKeybinding([
|
||||
new SimpleKeybinding(false, false, false, true, KeyCode.KEY_Y),
|
||||
new SimpleKeybinding(false, false, false, false, KeyCode.KEY_Z)
|
||||
),
|
||||
]),
|
||||
KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_Y, KeyCode.KEY_Z)
|
||||
);
|
||||
});
|
||||
@@ -62,35 +62,35 @@ suite('keyCodes', () => {
|
||||
}
|
||||
|
||||
test(null, 0);
|
||||
test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter), KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, false, true, KeyCode.Enter), KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter), KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, true, KeyCode.Enter), KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, false, KeyCode.Enter), KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, true, KeyCode.Enter), KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, false, KeyCode.Enter), KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, true, KeyCode.Enter), KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, false, KeyCode.Enter), KeyMod.CtrlCmd | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, false, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, false, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, false, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, true, KeyCode.Enter), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, false, false, KeyCode.Enter).toChord(), KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, false, true, KeyCode.Enter).toChord(), KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, false, KeyCode.Enter).toChord(), KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, false, true, true, KeyCode.Enter).toChord(), KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, false, KeyCode.Enter).toChord(), KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, false, true, KeyCode.Enter).toChord(), KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, false, KeyCode.Enter).toChord(), KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(false, true, true, true, KeyCode.Enter).toChord(), KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, false, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, false, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, false, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, false, true, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, false, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, false, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, false, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.Enter);
|
||||
test(new SimpleKeybinding(true, true, true, true, KeyCode.Enter).toChord(), KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.Enter);
|
||||
|
||||
test(
|
||||
new ChordKeybinding(
|
||||
new ChordKeybinding([
|
||||
new SimpleKeybinding(false, false, false, false, KeyCode.Enter),
|
||||
new SimpleKeybinding(false, false, false, false, KeyCode.Tab)
|
||||
),
|
||||
]),
|
||||
KeyChord(KeyCode.Enter, KeyCode.Tab)
|
||||
);
|
||||
test(
|
||||
new ChordKeybinding(
|
||||
new ChordKeybinding([
|
||||
new SimpleKeybinding(true, false, false, false, KeyCode.KEY_Y),
|
||||
new SimpleKeybinding(false, false, false, false, KeyCode.KEY_Z)
|
||||
),
|
||||
]),
|
||||
KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_Y, KeyCode.KEY_Z)
|
||||
);
|
||||
|
||||
|
||||
@@ -226,6 +226,50 @@ suite('Map', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('LinkedMap - delete Head and Tail', function () {
|
||||
const map = new LinkedMap<string, number>();
|
||||
|
||||
assert.equal(map.size, 0);
|
||||
|
||||
map.set('1', 1);
|
||||
assert.equal(map.size, 1);
|
||||
map.delete('1');
|
||||
assert.equal(map.get('1'), undefined);
|
||||
assert.equal(map.size, 0);
|
||||
assert.equal(map.keys().length, 0);
|
||||
});
|
||||
|
||||
test('LinkedMap - delete Head', function () {
|
||||
const map = new LinkedMap<string, number>();
|
||||
|
||||
assert.equal(map.size, 0);
|
||||
|
||||
map.set('1', 1);
|
||||
map.set('2', 2);
|
||||
assert.equal(map.size, 2);
|
||||
map.delete('1');
|
||||
assert.equal(map.get('2'), 2);
|
||||
assert.equal(map.size, 1);
|
||||
assert.equal(map.keys().length, 1);
|
||||
assert.equal(map.keys()[0], 2);
|
||||
});
|
||||
|
||||
test('LinkedMap - delete Tail', function () {
|
||||
const map = new LinkedMap<string, number>();
|
||||
|
||||
assert.equal(map.size, 0);
|
||||
|
||||
map.set('1', 1);
|
||||
map.set('2', 2);
|
||||
assert.equal(map.size, 2);
|
||||
map.delete('2');
|
||||
assert.equal(map.get('1'), 1);
|
||||
assert.equal(map.size, 1);
|
||||
assert.equal(map.keys().length, 1);
|
||||
assert.equal(map.keys()[0], 1);
|
||||
});
|
||||
|
||||
|
||||
test('PathIterator', () => {
|
||||
const iter = new PathIterator();
|
||||
iter.reset('file:///usr/bin/file.txt');
|
||||
|
||||
824
src/vs/base/test/common/path.test.ts
Normal file
824
src/vs/base/test/common/path.test.ts
Normal file
@@ -0,0 +1,824 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// NOTE: VSCode's copy of nodejs path library to be usable in common (non-node) namespace
|
||||
// Copied from: https://github.com/nodejs/node/tree/43dd49c9782848c25e5b03448c8a0f923f13c158
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
suite('Paths (Node Implementation)', () => {
|
||||
test('join', () => {
|
||||
const failures = [] as string[];
|
||||
const backslashRE = /\\/g;
|
||||
|
||||
const joinTests: any = [
|
||||
[[path.posix.join, path.win32.join],
|
||||
// arguments result
|
||||
[[['.', 'x/b', '..', '/b/c.js'], 'x/b/c.js'],
|
||||
[[], '.'],
|
||||
[['/.', 'x/b', '..', '/b/c.js'], '/x/b/c.js'],
|
||||
[['/foo', '../../../bar'], '/bar'],
|
||||
[['foo', '../../../bar'], '../../bar'],
|
||||
[['foo/', '../../../bar'], '../../bar'],
|
||||
[['foo/x', '../../../bar'], '../bar'],
|
||||
[['foo/x', './bar'], 'foo/x/bar'],
|
||||
[['foo/x/', './bar'], 'foo/x/bar'],
|
||||
[['foo/x/', '.', 'bar'], 'foo/x/bar'],
|
||||
[['./'], './'],
|
||||
[['.', './'], './'],
|
||||
[['.', '.', '.'], '.'],
|
||||
[['.', './', '.'], '.'],
|
||||
[['.', '/./', '.'], '.'],
|
||||
[['.', '/////./', '.'], '.'],
|
||||
[['.'], '.'],
|
||||
[['', '.'], '.'],
|
||||
[['', 'foo'], 'foo'],
|
||||
[['foo', '/bar'], 'foo/bar'],
|
||||
[['', '/foo'], '/foo'],
|
||||
[['', '', '/foo'], '/foo'],
|
||||
[['', '', 'foo'], 'foo'],
|
||||
[['foo', ''], 'foo'],
|
||||
[['foo/', ''], 'foo/'],
|
||||
[['foo', '', '/bar'], 'foo/bar'],
|
||||
[['./', '..', '/foo'], '../foo'],
|
||||
[['./', '..', '..', '/foo'], '../../foo'],
|
||||
[['.', '..', '..', '/foo'], '../../foo'],
|
||||
[['', '..', '..', '/foo'], '../../foo'],
|
||||
[['/'], '/'],
|
||||
[['/', '.'], '/'],
|
||||
[['/', '..'], '/'],
|
||||
[['/', '..', '..'], '/'],
|
||||
[[''], '.'],
|
||||
[['', ''], '.'],
|
||||
[[' /foo'], ' /foo'],
|
||||
[[' ', 'foo'], ' /foo'],
|
||||
[[' ', '.'], ' '],
|
||||
[[' ', '/'], ' /'],
|
||||
[[' ', ''], ' '],
|
||||
[['/', 'foo'], '/foo'],
|
||||
[['/', '/foo'], '/foo'],
|
||||
[['/', '//foo'], '/foo'],
|
||||
[['/', '', '/foo'], '/foo'],
|
||||
[['', '/', 'foo'], '/foo'],
|
||||
[['', '/', '/foo'], '/foo']
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// Windows-specific join tests
|
||||
joinTests.push([
|
||||
path.win32.join,
|
||||
joinTests[0][1].slice(0).concat(
|
||||
[// arguments result
|
||||
// UNC path expected
|
||||
[['//foo/bar'], '\\\\foo\\bar\\'],
|
||||
[['\\/foo/bar'], '\\\\foo\\bar\\'],
|
||||
[['\\\\foo/bar'], '\\\\foo\\bar\\'],
|
||||
// UNC path expected - server and share separate
|
||||
[['//foo', 'bar'], '\\\\foo\\bar\\'],
|
||||
[['//foo/', 'bar'], '\\\\foo\\bar\\'],
|
||||
[['//foo', '/bar'], '\\\\foo\\bar\\'],
|
||||
// UNC path expected - questionable
|
||||
[['//foo', '', 'bar'], '\\\\foo\\bar\\'],
|
||||
[['//foo/', '', 'bar'], '\\\\foo\\bar\\'],
|
||||
[['//foo/', '', '/bar'], '\\\\foo\\bar\\'],
|
||||
// UNC path expected - even more questionable
|
||||
[['', '//foo', 'bar'], '\\\\foo\\bar\\'],
|
||||
[['', '//foo/', 'bar'], '\\\\foo\\bar\\'],
|
||||
[['', '//foo/', '/bar'], '\\\\foo\\bar\\'],
|
||||
// No UNC path expected (no double slash in first component)
|
||||
[['\\', 'foo/bar'], '\\foo\\bar'],
|
||||
[['\\', '/foo/bar'], '\\foo\\bar'],
|
||||
[['', '/', '/foo/bar'], '\\foo\\bar'],
|
||||
// No UNC path expected (no non-slashes in first component -
|
||||
// questionable)
|
||||
[['//', 'foo/bar'], '\\foo\\bar'],
|
||||
[['//', '/foo/bar'], '\\foo\\bar'],
|
||||
[['\\\\', '/', '/foo/bar'], '\\foo\\bar'],
|
||||
[['//'], '\\'],
|
||||
// No UNC path expected (share name missing - questionable).
|
||||
[['//foo'], '\\foo'],
|
||||
[['//foo/'], '\\foo\\'],
|
||||
[['//foo', '/'], '\\foo\\'],
|
||||
[['//foo', '', '/'], '\\foo\\'],
|
||||
// No UNC path expected (too many leading slashes - questionable)
|
||||
[['///foo/bar'], '\\foo\\bar'],
|
||||
[['////foo', 'bar'], '\\foo\\bar'],
|
||||
[['\\\\\\/foo/bar'], '\\foo\\bar'],
|
||||
// Drive-relative vs drive-absolute paths. This merely describes the
|
||||
// status quo, rather than being obviously right
|
||||
[['c:'], 'c:.'],
|
||||
[['c:.'], 'c:.'],
|
||||
[['c:', ''], 'c:.'],
|
||||
[['', 'c:'], 'c:.'],
|
||||
[['c:.', '/'], 'c:.\\'],
|
||||
[['c:.', 'file'], 'c:file'],
|
||||
[['c:', '/'], 'c:\\'],
|
||||
[['c:', 'file'], 'c:\\file']
|
||||
]
|
||||
)
|
||||
]);
|
||||
joinTests.forEach((test) => {
|
||||
if (!Array.isArray(test[0])) {
|
||||
test[0] = [test[0]];
|
||||
}
|
||||
test[0].forEach((join) => {
|
||||
test[1].forEach((test) => {
|
||||
const actual = join.apply(null, test[0]);
|
||||
const expected = test[1];
|
||||
// For non-Windows specific tests with the Windows join(), we need to try
|
||||
// replacing the slashes since the non-Windows specific tests' `expected`
|
||||
// use forward slashes
|
||||
let actualAlt;
|
||||
let os;
|
||||
if (join === path.win32.join) {
|
||||
actualAlt = actual.replace(backslashRE, '/');
|
||||
os = 'win32';
|
||||
} else {
|
||||
os = 'posix';
|
||||
}
|
||||
const message =
|
||||
`path.${os}.join(${test[0].map(JSON.stringify).join(',')})\n expect=${
|
||||
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
|
||||
if (actual !== expected && actualAlt !== expected) {
|
||||
failures.push(`\n${message}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
assert.strictEqual(failures.length, 0, failures.join(''));
|
||||
});
|
||||
|
||||
test('dirname', () => {
|
||||
assert.strictEqual(path.dirname(path.normalize(__filename)).substr(-11),
|
||||
isWindows ? 'test\\common' : 'test/common');
|
||||
|
||||
assert.strictEqual(path.posix.dirname('/a/b/'), '/a');
|
||||
assert.strictEqual(path.posix.dirname('/a/b'), '/a');
|
||||
assert.strictEqual(path.posix.dirname('/a'), '/');
|
||||
assert.strictEqual(path.posix.dirname(''), '.');
|
||||
assert.strictEqual(path.posix.dirname('/'), '/');
|
||||
assert.strictEqual(path.posix.dirname('////'), '/');
|
||||
assert.strictEqual(path.posix.dirname('//a'), '//');
|
||||
assert.strictEqual(path.posix.dirname('foo'), '.');
|
||||
|
||||
assert.strictEqual(path.win32.dirname('c:\\'), 'c:\\');
|
||||
assert.strictEqual(path.win32.dirname('c:\\foo'), 'c:\\');
|
||||
assert.strictEqual(path.win32.dirname('c:\\foo\\'), 'c:\\');
|
||||
assert.strictEqual(path.win32.dirname('c:\\foo\\bar'), 'c:\\foo');
|
||||
assert.strictEqual(path.win32.dirname('c:\\foo\\bar\\'), 'c:\\foo');
|
||||
assert.strictEqual(path.win32.dirname('c:\\foo\\bar\\baz'), 'c:\\foo\\bar');
|
||||
assert.strictEqual(path.win32.dirname('\\'), '\\');
|
||||
assert.strictEqual(path.win32.dirname('\\foo'), '\\');
|
||||
assert.strictEqual(path.win32.dirname('\\foo\\'), '\\');
|
||||
assert.strictEqual(path.win32.dirname('\\foo\\bar'), '\\foo');
|
||||
assert.strictEqual(path.win32.dirname('\\foo\\bar\\'), '\\foo');
|
||||
assert.strictEqual(path.win32.dirname('\\foo\\bar\\baz'), '\\foo\\bar');
|
||||
assert.strictEqual(path.win32.dirname('c:'), 'c:');
|
||||
assert.strictEqual(path.win32.dirname('c:foo'), 'c:');
|
||||
assert.strictEqual(path.win32.dirname('c:foo\\'), 'c:');
|
||||
assert.strictEqual(path.win32.dirname('c:foo\\bar'), 'c:foo');
|
||||
assert.strictEqual(path.win32.dirname('c:foo\\bar\\'), 'c:foo');
|
||||
assert.strictEqual(path.win32.dirname('c:foo\\bar\\baz'), 'c:foo\\bar');
|
||||
assert.strictEqual(path.win32.dirname('file:stream'), '.');
|
||||
assert.strictEqual(path.win32.dirname('dir\\file:stream'), 'dir');
|
||||
assert.strictEqual(path.win32.dirname('\\\\unc\\share'),
|
||||
'\\\\unc\\share');
|
||||
assert.strictEqual(path.win32.dirname('\\\\unc\\share\\foo'),
|
||||
'\\\\unc\\share\\');
|
||||
assert.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\'),
|
||||
'\\\\unc\\share\\');
|
||||
assert.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar'),
|
||||
'\\\\unc\\share\\foo');
|
||||
assert.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar\\'),
|
||||
'\\\\unc\\share\\foo');
|
||||
assert.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar\\baz'),
|
||||
'\\\\unc\\share\\foo\\bar');
|
||||
assert.strictEqual(path.win32.dirname('/a/b/'), '/a');
|
||||
assert.strictEqual(path.win32.dirname('/a/b'), '/a');
|
||||
assert.strictEqual(path.win32.dirname('/a'), '/');
|
||||
assert.strictEqual(path.win32.dirname(''), '.');
|
||||
assert.strictEqual(path.win32.dirname('/'), '/');
|
||||
assert.strictEqual(path.win32.dirname('////'), '/');
|
||||
assert.strictEqual(path.win32.dirname('foo'), '.');
|
||||
|
||||
// Tests from VSCode
|
||||
|
||||
function assertDirname(p: string, expected: string, win = false) {
|
||||
const actual = win ? path.win32.dirname(p) : path.posix.dirname(p);
|
||||
|
||||
if (actual !== expected) {
|
||||
assert.fail(`${p}: expected: ${expected}, ours: ${actual}`);
|
||||
}
|
||||
}
|
||||
|
||||
assertDirname('foo/bar', 'foo');
|
||||
assertDirname('foo\\bar', 'foo', true);
|
||||
assertDirname('/foo/bar', '/foo');
|
||||
assertDirname('\\foo\\bar', '\\foo', true);
|
||||
assertDirname('/foo', '/');
|
||||
assertDirname('\\foo', '\\', true);
|
||||
assertDirname('/', '/');
|
||||
assertDirname('\\', '\\', true);
|
||||
assertDirname('foo', '.');
|
||||
assertDirname('f', '.');
|
||||
assertDirname('f/', '.');
|
||||
assertDirname('/folder/', '/');
|
||||
assertDirname('c:\\some\\file.txt', 'c:\\some', true);
|
||||
assertDirname('c:\\some', 'c:\\', true);
|
||||
assertDirname('c:\\', 'c:\\', true);
|
||||
assertDirname('c:', 'c:', true);
|
||||
assertDirname('\\\\server\\share\\some\\path', '\\\\server\\share\\some', true);
|
||||
assertDirname('\\\\server\\share\\some', '\\\\server\\share\\', true);
|
||||
assertDirname('\\\\server\\share\\', '\\\\server\\share\\', true);
|
||||
});
|
||||
|
||||
test('extname', () => {
|
||||
const failures = [] as string[];
|
||||
const slashRE = /\//g;
|
||||
|
||||
[
|
||||
[__filename, '.js'],
|
||||
['', ''],
|
||||
['/path/to/file', ''],
|
||||
['/path/to/file.ext', '.ext'],
|
||||
['/path.to/file.ext', '.ext'],
|
||||
['/path.to/file', ''],
|
||||
['/path.to/.file', ''],
|
||||
['/path.to/.file.ext', '.ext'],
|
||||
['/path/to/f.ext', '.ext'],
|
||||
['/path/to/..ext', '.ext'],
|
||||
['/path/to/..', ''],
|
||||
['file', ''],
|
||||
['file.ext', '.ext'],
|
||||
['.file', ''],
|
||||
['.file.ext', '.ext'],
|
||||
['/file', ''],
|
||||
['/file.ext', '.ext'],
|
||||
['/.file', ''],
|
||||
['/.file.ext', '.ext'],
|
||||
['.path/file.ext', '.ext'],
|
||||
['file.ext.ext', '.ext'],
|
||||
['file.', '.'],
|
||||
['.', ''],
|
||||
['./', ''],
|
||||
['.file.ext', '.ext'],
|
||||
['.file', ''],
|
||||
['.file.', '.'],
|
||||
['.file..', '.'],
|
||||
['..', ''],
|
||||
['../', ''],
|
||||
['..file.ext', '.ext'],
|
||||
['..file', '.file'],
|
||||
['..file.', '.'],
|
||||
['..file..', '.'],
|
||||
['...', '.'],
|
||||
['...ext', '.ext'],
|
||||
['....', '.'],
|
||||
['file.ext/', '.ext'],
|
||||
['file.ext//', '.ext'],
|
||||
['file/', ''],
|
||||
['file//', ''],
|
||||
['file./', '.'],
|
||||
['file.//', '.'],
|
||||
].forEach((test) => {
|
||||
const expected = test[1];
|
||||
[path.posix.extname, path.win32.extname].forEach((extname) => {
|
||||
let input = test[0];
|
||||
let os;
|
||||
if (extname === path.win32.extname) {
|
||||
input = input.replace(slashRE, '\\');
|
||||
os = 'win32';
|
||||
} else {
|
||||
os = 'posix';
|
||||
}
|
||||
const actual = extname(input);
|
||||
const message = `path.${os}.extname(${JSON.stringify(input)})\n expect=${
|
||||
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
|
||||
if (actual !== expected) {
|
||||
failures.push(`\n${message}`);
|
||||
}
|
||||
});
|
||||
{
|
||||
const input = `C:${test[0].replace(slashRE, '\\')}`;
|
||||
const actual = path.win32.extname(input);
|
||||
const message = `path.win32.extname(${JSON.stringify(input)})\n expect=${
|
||||
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
|
||||
if (actual !== expected) {
|
||||
failures.push(`\n${message}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
assert.strictEqual(failures.length, 0, failures.join(''));
|
||||
|
||||
// On Windows, backslash is a path separator.
|
||||
assert.strictEqual(path.win32.extname('.\\'), '');
|
||||
assert.strictEqual(path.win32.extname('..\\'), '');
|
||||
assert.strictEqual(path.win32.extname('file.ext\\'), '.ext');
|
||||
assert.strictEqual(path.win32.extname('file.ext\\\\'), '.ext');
|
||||
assert.strictEqual(path.win32.extname('file\\'), '');
|
||||
assert.strictEqual(path.win32.extname('file\\\\'), '');
|
||||
assert.strictEqual(path.win32.extname('file.\\'), '.');
|
||||
assert.strictEqual(path.win32.extname('file.\\\\'), '.');
|
||||
|
||||
// On *nix, backslash is a valid name component like any other character.
|
||||
assert.strictEqual(path.posix.extname('.\\'), '');
|
||||
assert.strictEqual(path.posix.extname('..\\'), '.\\');
|
||||
assert.strictEqual(path.posix.extname('file.ext\\'), '.ext\\');
|
||||
assert.strictEqual(path.posix.extname('file.ext\\\\'), '.ext\\\\');
|
||||
assert.strictEqual(path.posix.extname('file\\'), '');
|
||||
assert.strictEqual(path.posix.extname('file\\\\'), '');
|
||||
assert.strictEqual(path.posix.extname('file.\\'), '.\\');
|
||||
assert.strictEqual(path.posix.extname('file.\\\\'), '.\\\\');
|
||||
|
||||
// Tests from VSCode
|
||||
assert.equal(path.extname('far.boo'), '.boo');
|
||||
assert.equal(path.extname('far.b'), '.b');
|
||||
assert.equal(path.extname('far.'), '.');
|
||||
assert.equal(path.extname('far.boo/boo.far'), '.far');
|
||||
assert.equal(path.extname('far.boo/boo'), '');
|
||||
});
|
||||
|
||||
test('resolve', () => {
|
||||
const failures = [] as string[];
|
||||
const slashRE = /\//g;
|
||||
const backslashRE = /\\/g;
|
||||
|
||||
const resolveTests = [
|
||||
[path.win32.resolve,
|
||||
// arguments result
|
||||
[[['c:/blah\\blah', 'd:/games', 'c:../a'], 'c:\\blah\\a'],
|
||||
[['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'], 'd:\\e.exe'],
|
||||
[['c:/ignore', 'c:/some/file'], 'c:\\some\\file'],
|
||||
[['d:/ignore', 'd:some/dir//'], 'd:\\ignore\\some\\dir'],
|
||||
[['.'], process.cwd()],
|
||||
[['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'],
|
||||
[['c:/', '//'], 'c:\\'],
|
||||
[['c:/', '//dir'], 'c:\\dir'],
|
||||
[['c:/', '//server/share'], '\\\\server\\share\\'],
|
||||
[['c:/', '//server//share'], '\\\\server\\share\\'],
|
||||
[['c:/', '///some//dir'], 'c:\\some\\dir'],
|
||||
[['C:\\foo\\tmp.3\\', '..\\tmp.3\\cycles\\root.js'],
|
||||
'C:\\foo\\tmp.3\\cycles\\root.js']
|
||||
]
|
||||
],
|
||||
[path.posix.resolve,
|
||||
// arguments result
|
||||
[[['/var/lib', '../', 'file/'], '/var/file'],
|
||||
[['/var/lib', '/../', 'file/'], '/file'],
|
||||
[['a/b/c/', '../../..'], process.cwd()],
|
||||
[['.'], process.cwd()],
|
||||
[['/some/dir', '.', '/absolute/'], '/absolute'],
|
||||
[['/foo/tmp.3/', '../tmp.3/cycles/root.js'], '/foo/tmp.3/cycles/root.js']
|
||||
]
|
||||
]
|
||||
];
|
||||
resolveTests.forEach((test) => {
|
||||
const resolve = test[0];
|
||||
//@ts-ignore
|
||||
test[1].forEach((test) => {
|
||||
//@ts-ignore
|
||||
const actual = resolve.apply(null, test[0]);
|
||||
let actualAlt;
|
||||
const os = resolve === path.win32.resolve ? 'win32' : 'posix';
|
||||
if (resolve === path.win32.resolve && !isWindows) {
|
||||
actualAlt = actual.replace(backslashRE, '/');
|
||||
}
|
||||
else if (resolve !== path.win32.resolve && isWindows) {
|
||||
actualAlt = actual.replace(slashRE, '\\');
|
||||
}
|
||||
|
||||
const expected = test[1];
|
||||
const message =
|
||||
`path.${os}.resolve(${test[0].map(JSON.stringify).join(',')})\n expect=${
|
||||
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
|
||||
if (actual !== expected && actualAlt !== expected) {
|
||||
failures.push(`\n${message}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
assert.strictEqual(failures.length, 0, failures.join(''));
|
||||
|
||||
// if (isWindows) {
|
||||
// // Test resolving the current Windows drive letter from a spawned process.
|
||||
// // See https://github.com/nodejs/node/issues/7215
|
||||
// const currentDriveLetter = path.parse(process.cwd()).root.substring(0, 2);
|
||||
// const resolveFixture = fixtures.path('path-resolve.js');
|
||||
// const spawnResult = child.spawnSync(
|
||||
// process.argv[0], [resolveFixture, currentDriveLetter]);
|
||||
// const resolvedPath = spawnResult.stdout.toString().trim();
|
||||
// assert.strictEqual(resolvedPath.toLowerCase(), process.cwd().toLowerCase());
|
||||
// }
|
||||
});
|
||||
|
||||
test('basename', () => {
|
||||
assert.strictEqual(path.basename(__filename), 'path.test.js');
|
||||
assert.strictEqual(path.basename(__filename, '.js'), 'path.test');
|
||||
assert.strictEqual(path.basename('.js', '.js'), '');
|
||||
assert.strictEqual(path.basename(''), '');
|
||||
assert.strictEqual(path.basename('/dir/basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.basename('/basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.basename('basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.basename('basename.ext/'), 'basename.ext');
|
||||
assert.strictEqual(path.basename('basename.ext//'), 'basename.ext');
|
||||
assert.strictEqual(path.basename('aaa/bbb', '/bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('aaa/bbb', 'a/bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('aaa/bbb', 'bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('aaa/bbb//', 'bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('aaa/bbb', 'bb'), 'b');
|
||||
assert.strictEqual(path.basename('aaa/bbb', 'b'), 'bb');
|
||||
assert.strictEqual(path.basename('/aaa/bbb', '/bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('/aaa/bbb', 'a/bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('/aaa/bbb', 'bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('/aaa/bbb//', 'bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('/aaa/bbb', 'bb'), 'b');
|
||||
assert.strictEqual(path.basename('/aaa/bbb', 'b'), 'bb');
|
||||
assert.strictEqual(path.basename('/aaa/bbb'), 'bbb');
|
||||
assert.strictEqual(path.basename('/aaa/'), 'aaa');
|
||||
assert.strictEqual(path.basename('/aaa/b'), 'b');
|
||||
assert.strictEqual(path.basename('/a/b'), 'b');
|
||||
assert.strictEqual(path.basename('//a'), 'a');
|
||||
assert.strictEqual(path.basename('a', 'a'), '');
|
||||
|
||||
// On Windows a backslash acts as a path separator.
|
||||
assert.strictEqual(path.win32.basename('\\dir\\basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('\\basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('basename.ext\\'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('basename.ext\\\\'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('foo'), 'foo');
|
||||
assert.strictEqual(path.win32.basename('aaa\\bbb', '\\bbb'), 'bbb');
|
||||
assert.strictEqual(path.win32.basename('aaa\\bbb', 'a\\bbb'), 'bbb');
|
||||
assert.strictEqual(path.win32.basename('aaa\\bbb', 'bbb'), 'bbb');
|
||||
assert.strictEqual(path.win32.basename('aaa\\bbb\\\\\\\\', 'bbb'), 'bbb');
|
||||
assert.strictEqual(path.win32.basename('aaa\\bbb', 'bb'), 'b');
|
||||
assert.strictEqual(path.win32.basename('aaa\\bbb', 'b'), 'bb');
|
||||
assert.strictEqual(path.win32.basename('C:'), '');
|
||||
assert.strictEqual(path.win32.basename('C:.'), '.');
|
||||
assert.strictEqual(path.win32.basename('C:\\'), '');
|
||||
assert.strictEqual(path.win32.basename('C:\\dir\\base.ext'), 'base.ext');
|
||||
assert.strictEqual(path.win32.basename('C:\\basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('C:basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('C:basename.ext\\'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('C:basename.ext\\\\'), 'basename.ext');
|
||||
assert.strictEqual(path.win32.basename('C:foo'), 'foo');
|
||||
assert.strictEqual(path.win32.basename('file:stream'), 'file:stream');
|
||||
assert.strictEqual(path.win32.basename('a', 'a'), '');
|
||||
|
||||
// On unix a backslash is just treated as any other character.
|
||||
assert.strictEqual(path.posix.basename('\\dir\\basename.ext'),
|
||||
'\\dir\\basename.ext');
|
||||
assert.strictEqual(path.posix.basename('\\basename.ext'), '\\basename.ext');
|
||||
assert.strictEqual(path.posix.basename('basename.ext'), 'basename.ext');
|
||||
assert.strictEqual(path.posix.basename('basename.ext\\'), 'basename.ext\\');
|
||||
assert.strictEqual(path.posix.basename('basename.ext\\\\'), 'basename.ext\\\\');
|
||||
assert.strictEqual(path.posix.basename('foo'), 'foo');
|
||||
|
||||
// POSIX filenames may include control characters
|
||||
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
|
||||
const controlCharFilename = `Icon${String.fromCharCode(13)}`;
|
||||
assert.strictEqual(path.posix.basename(`/a/b/${controlCharFilename}`),
|
||||
controlCharFilename);
|
||||
|
||||
// Tests from VSCode
|
||||
assert.equal(path.basename('foo/bar'), 'bar');
|
||||
assert.equal(path.posix.basename('foo\\bar'), 'foo\\bar');
|
||||
assert.equal(path.win32.basename('foo\\bar'), 'bar');
|
||||
assert.equal(path.basename('/foo/bar'), 'bar');
|
||||
assert.equal(path.posix.basename('\\foo\\bar'), '\\foo\\bar');
|
||||
assert.equal(path.win32.basename('\\foo\\bar'), 'bar');
|
||||
assert.equal(path.basename('./bar'), 'bar');
|
||||
assert.equal(path.posix.basename('.\\bar'), '.\\bar');
|
||||
assert.equal(path.win32.basename('.\\bar'), 'bar');
|
||||
assert.equal(path.basename('/bar'), 'bar');
|
||||
assert.equal(path.posix.basename('\\bar'), '\\bar');
|
||||
assert.equal(path.win32.basename('\\bar'), 'bar');
|
||||
assert.equal(path.basename('bar/'), 'bar');
|
||||
assert.equal(path.posix.basename('bar\\'), 'bar\\');
|
||||
assert.equal(path.win32.basename('bar\\'), 'bar');
|
||||
assert.equal(path.basename('bar'), 'bar');
|
||||
assert.equal(path.basename('////////'), '');
|
||||
assert.equal(path.posix.basename('\\\\\\\\'), '\\\\\\\\');
|
||||
assert.equal(path.win32.basename('\\\\\\\\'), '');
|
||||
});
|
||||
|
||||
test('relative', () => {
|
||||
const failures = [] as string[];
|
||||
|
||||
const relativeTests = [
|
||||
[path.win32.relative,
|
||||
// arguments result
|
||||
[['c:/blah\\blah', 'd:/games', 'd:\\games'],
|
||||
['c:/aaaa/bbbb', 'c:/aaaa', '..'],
|
||||
['c:/aaaa/bbbb', 'c:/cccc', '..\\..\\cccc'],
|
||||
['c:/aaaa/bbbb', 'c:/aaaa/bbbb', ''],
|
||||
['c:/aaaa/bbbb', 'c:/aaaa/cccc', '..\\cccc'],
|
||||
['c:/aaaa/', 'c:/aaaa/cccc', 'cccc'],
|
||||
['c:/', 'c:\\aaaa\\bbbb', 'aaaa\\bbbb'],
|
||||
['c:/aaaa/bbbb', 'd:\\', 'd:\\'],
|
||||
['c:/AaAa/bbbb', 'c:/aaaa/bbbb', ''],
|
||||
['c:/aaaaa/', 'c:/aaaa/cccc', '..\\aaaa\\cccc'],
|
||||
['C:\\foo\\bar\\baz\\quux', 'C:\\', '..\\..\\..\\..'],
|
||||
['C:\\foo\\test', 'C:\\foo\\test\\bar\\package.json', 'bar\\package.json'],
|
||||
['C:\\foo\\bar\\baz-quux', 'C:\\foo\\bar\\baz', '..\\baz'],
|
||||
['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz-quux', '..\\baz-quux'],
|
||||
['\\\\foo\\bar', '\\\\foo\\bar\\baz', 'baz'],
|
||||
['\\\\foo\\bar\\baz', '\\\\foo\\bar', '..'],
|
||||
['\\\\foo\\bar\\baz-quux', '\\\\foo\\bar\\baz', '..\\baz'],
|
||||
['\\\\foo\\bar\\baz', '\\\\foo\\bar\\baz-quux', '..\\baz-quux'],
|
||||
['C:\\baz-quux', 'C:\\baz', '..\\baz'],
|
||||
['C:\\baz', 'C:\\baz-quux', '..\\baz-quux'],
|
||||
['\\\\foo\\baz-quux', '\\\\foo\\baz', '..\\baz'],
|
||||
['\\\\foo\\baz', '\\\\foo\\baz-quux', '..\\baz-quux'],
|
||||
['C:\\baz', '\\\\foo\\bar\\baz', '\\\\foo\\bar\\baz'],
|
||||
['\\\\foo\\bar\\baz', 'C:\\baz', 'C:\\baz']
|
||||
]
|
||||
],
|
||||
[path.posix.relative,
|
||||
// arguments result
|
||||
[['/var/lib', '/var', '..'],
|
||||
['/var/lib', '/bin', '../../bin'],
|
||||
['/var/lib', '/var/lib', ''],
|
||||
['/var/lib', '/var/apache', '../apache'],
|
||||
['/var/', '/var/lib', 'lib'],
|
||||
['/', '/var/lib', 'var/lib'],
|
||||
['/foo/test', '/foo/test/bar/package.json', 'bar/package.json'],
|
||||
['/Users/a/web/b/test/mails', '/Users/a/web/b', '../..'],
|
||||
['/foo/bar/baz-quux', '/foo/bar/baz', '../baz'],
|
||||
['/foo/bar/baz', '/foo/bar/baz-quux', '../baz-quux'],
|
||||
['/baz-quux', '/baz', '../baz'],
|
||||
['/baz', '/baz-quux', '../baz-quux']
|
||||
]
|
||||
]
|
||||
];
|
||||
relativeTests.forEach((test) => {
|
||||
const relative = test[0];
|
||||
//@ts-ignore
|
||||
test[1].forEach((test) => {
|
||||
//@ts-ignore
|
||||
const actual = relative(test[0], test[1]);
|
||||
const expected = test[2];
|
||||
const os = relative === path.win32.relative ? 'win32' : 'posix';
|
||||
const message = `path.${os}.relative(${
|
||||
test.slice(0, 2).map(JSON.stringify).join(',')})\n expect=${
|
||||
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
|
||||
if (actual !== expected) {
|
||||
failures.push(`\n${message}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
assert.strictEqual(failures.length, 0, failures.join(''));
|
||||
});
|
||||
|
||||
test('normalize', () => {
|
||||
assert.strictEqual(path.win32.normalize('./fixtures///b/../b/c.js'),
|
||||
'fixtures\\b\\c.js');
|
||||
assert.strictEqual(path.win32.normalize('/foo/../../../bar'), '\\bar');
|
||||
assert.strictEqual(path.win32.normalize('a//b//../b'), 'a\\b');
|
||||
assert.strictEqual(path.win32.normalize('a//b//./c'), 'a\\b\\c');
|
||||
assert.strictEqual(path.win32.normalize('a//b//.'), 'a\\b');
|
||||
assert.strictEqual(path.win32.normalize('//server/share/dir/file.ext'),
|
||||
'\\\\server\\share\\dir\\file.ext');
|
||||
assert.strictEqual(path.win32.normalize('/a/b/c/../../../x/y/z'), '\\x\\y\\z');
|
||||
assert.strictEqual(path.win32.normalize('C:'), 'C:.');
|
||||
assert.strictEqual(path.win32.normalize('C:..\\abc'), 'C:..\\abc');
|
||||
assert.strictEqual(path.win32.normalize('C:..\\..\\abc\\..\\def'),
|
||||
'C:..\\..\\def');
|
||||
assert.strictEqual(path.win32.normalize('C:\\.'), 'C:\\');
|
||||
assert.strictEqual(path.win32.normalize('file:stream'), 'file:stream');
|
||||
assert.strictEqual(path.win32.normalize('bar\\foo..\\..\\'), 'bar\\');
|
||||
assert.strictEqual(path.win32.normalize('bar\\foo..\\..'), 'bar');
|
||||
assert.strictEqual(path.win32.normalize('bar\\foo..\\..\\baz'), 'bar\\baz');
|
||||
assert.strictEqual(path.win32.normalize('bar\\foo..\\'), 'bar\\foo..\\');
|
||||
assert.strictEqual(path.win32.normalize('bar\\foo..'), 'bar\\foo..');
|
||||
assert.strictEqual(path.win32.normalize('..\\foo..\\..\\..\\bar'),
|
||||
'..\\..\\bar');
|
||||
assert.strictEqual(path.win32.normalize('..\\...\\..\\.\\...\\..\\..\\bar'),
|
||||
'..\\..\\bar');
|
||||
assert.strictEqual(path.win32.normalize('../../../foo/../../../bar'),
|
||||
'..\\..\\..\\..\\..\\bar');
|
||||
assert.strictEqual(path.win32.normalize('../../../foo/../../../bar/../../'),
|
||||
'..\\..\\..\\..\\..\\..\\');
|
||||
assert.strictEqual(
|
||||
path.win32.normalize('../foobar/barfoo/foo/../../../bar/../../'),
|
||||
'..\\..\\'
|
||||
);
|
||||
assert.strictEqual(
|
||||
path.win32.normalize('../.../../foobar/../../../bar/../../baz'),
|
||||
'..\\..\\..\\..\\baz'
|
||||
);
|
||||
assert.strictEqual(path.win32.normalize('foo/bar\\baz'), 'foo\\bar\\baz');
|
||||
|
||||
assert.strictEqual(path.posix.normalize('./fixtures///b/../b/c.js'),
|
||||
'fixtures/b/c.js');
|
||||
assert.strictEqual(path.posix.normalize('/foo/../../../bar'), '/bar');
|
||||
assert.strictEqual(path.posix.normalize('a//b//../b'), 'a/b');
|
||||
assert.strictEqual(path.posix.normalize('a//b//./c'), 'a/b/c');
|
||||
assert.strictEqual(path.posix.normalize('a//b//.'), 'a/b');
|
||||
assert.strictEqual(path.posix.normalize('/a/b/c/../../../x/y/z'), '/x/y/z');
|
||||
assert.strictEqual(path.posix.normalize('///..//./foo/.//bar'), '/foo/bar');
|
||||
assert.strictEqual(path.posix.normalize('bar/foo../../'), 'bar/');
|
||||
assert.strictEqual(path.posix.normalize('bar/foo../..'), 'bar');
|
||||
assert.strictEqual(path.posix.normalize('bar/foo../../baz'), 'bar/baz');
|
||||
assert.strictEqual(path.posix.normalize('bar/foo../'), 'bar/foo../');
|
||||
assert.strictEqual(path.posix.normalize('bar/foo..'), 'bar/foo..');
|
||||
assert.strictEqual(path.posix.normalize('../foo../../../bar'), '../../bar');
|
||||
assert.strictEqual(path.posix.normalize('../.../.././.../../../bar'),
|
||||
'../../bar');
|
||||
assert.strictEqual(path.posix.normalize('../../../foo/../../../bar'),
|
||||
'../../../../../bar');
|
||||
assert.strictEqual(path.posix.normalize('../../../foo/../../../bar/../../'),
|
||||
'../../../../../../');
|
||||
assert.strictEqual(
|
||||
path.posix.normalize('../foobar/barfoo/foo/../../../bar/../../'),
|
||||
'../../'
|
||||
);
|
||||
assert.strictEqual(
|
||||
path.posix.normalize('../.../../foobar/../../../bar/../../baz'),
|
||||
'../../../../baz'
|
||||
);
|
||||
assert.strictEqual(path.posix.normalize('foo/bar\\baz'), 'foo/bar\\baz');
|
||||
});
|
||||
|
||||
test('isAbsolute', () => {
|
||||
assert.strictEqual(path.win32.isAbsolute('/'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('//'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('//server'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('//server/file'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('\\\\server\\file'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('\\\\server'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('\\\\'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('c'), false);
|
||||
assert.strictEqual(path.win32.isAbsolute('c:'), false);
|
||||
assert.strictEqual(path.win32.isAbsolute('c:\\'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('c:/'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('c://'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('C:/Users/'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('C:\\Users\\'), true);
|
||||
assert.strictEqual(path.win32.isAbsolute('C:cwd/another'), false);
|
||||
assert.strictEqual(path.win32.isAbsolute('C:cwd\\another'), false);
|
||||
assert.strictEqual(path.win32.isAbsolute('directory/directory'), false);
|
||||
assert.strictEqual(path.win32.isAbsolute('directory\\directory'), false);
|
||||
|
||||
assert.strictEqual(path.posix.isAbsolute('/home/foo'), true);
|
||||
assert.strictEqual(path.posix.isAbsolute('/home/foo/..'), true);
|
||||
assert.strictEqual(path.posix.isAbsolute('bar/'), false);
|
||||
assert.strictEqual(path.posix.isAbsolute('./baz'), false);
|
||||
|
||||
// Tests from VSCode:
|
||||
|
||||
// Absolute Paths
|
||||
[
|
||||
'C:/',
|
||||
'C:\\',
|
||||
'C:/foo',
|
||||
'C:\\foo',
|
||||
'z:/foo/bar.txt',
|
||||
'z:\\foo\\bar.txt',
|
||||
|
||||
'\\\\localhost\\c$\\foo',
|
||||
|
||||
'/',
|
||||
'/foo'
|
||||
].forEach(absolutePath => {
|
||||
assert.ok(path.win32.isAbsolute(absolutePath), absolutePath);
|
||||
});
|
||||
|
||||
[
|
||||
'/',
|
||||
'/foo',
|
||||
'/foo/bar.txt'
|
||||
].forEach(absolutePath => {
|
||||
assert.ok(path.posix.isAbsolute(absolutePath), absolutePath);
|
||||
});
|
||||
|
||||
// Relative Paths
|
||||
[
|
||||
'',
|
||||
'foo',
|
||||
'foo/bar',
|
||||
'./foo',
|
||||
'http://foo.com/bar'
|
||||
].forEach(nonAbsolutePath => {
|
||||
assert.ok(!path.win32.isAbsolute(nonAbsolutePath), nonAbsolutePath);
|
||||
});
|
||||
|
||||
[
|
||||
'',
|
||||
'foo',
|
||||
'foo/bar',
|
||||
'./foo',
|
||||
'http://foo.com/bar',
|
||||
'z:/foo/bar.txt',
|
||||
].forEach(nonAbsolutePath => {
|
||||
assert.ok(!path.posix.isAbsolute(nonAbsolutePath), nonAbsolutePath);
|
||||
});
|
||||
});
|
||||
|
||||
test('path', () => {
|
||||
// path.sep tests
|
||||
// windows
|
||||
assert.strictEqual(path.win32.sep, '\\');
|
||||
// posix
|
||||
assert.strictEqual(path.posix.sep, '/');
|
||||
|
||||
// path.delimiter tests
|
||||
// windows
|
||||
assert.strictEqual(path.win32.delimiter, ';');
|
||||
// posix
|
||||
assert.strictEqual(path.posix.delimiter, ':');
|
||||
|
||||
// if (isWindows) {
|
||||
// assert.strictEqual(path, path.win32);
|
||||
// } else {
|
||||
// assert.strictEqual(path, path.posix);
|
||||
// }
|
||||
});
|
||||
|
||||
// test('perf', () => {
|
||||
// const folderNames = [
|
||||
// 'abc',
|
||||
// 'Users',
|
||||
// 'reallylongfoldername',
|
||||
// 's',
|
||||
// 'reallyreallyreallylongfoldername',
|
||||
// 'home'
|
||||
// ];
|
||||
|
||||
// const basePaths = [
|
||||
// 'C:',
|
||||
// '',
|
||||
// ];
|
||||
|
||||
// const separators = [
|
||||
// '\\',
|
||||
// '/'
|
||||
// ];
|
||||
|
||||
// function randomInt(ciel: number): number {
|
||||
// return Math.floor(Math.random() * ciel);
|
||||
// }
|
||||
|
||||
// let pathsToNormalize = [];
|
||||
// let pathsToJoin = [];
|
||||
// let i;
|
||||
// for (i = 0; i < 1000000; i++) {
|
||||
// const basePath = basePaths[randomInt(basePaths.length)];
|
||||
// let lengthOfPath = randomInt(10) + 2;
|
||||
|
||||
// let pathToNormalize = basePath + separators[randomInt(separators.length)];
|
||||
// while (lengthOfPath-- > 0) {
|
||||
// pathToNormalize = pathToNormalize + folderNames[randomInt(folderNames.length)] + separators[randomInt(separators.length)];
|
||||
// }
|
||||
|
||||
// pathsToNormalize.push(pathToNormalize);
|
||||
|
||||
// let pathToJoin = '';
|
||||
// lengthOfPath = randomInt(10) + 2;
|
||||
// while (lengthOfPath-- > 0) {
|
||||
// pathToJoin = pathToJoin + folderNames[randomInt(folderNames.length)] + separators[randomInt(separators.length)];
|
||||
// }
|
||||
|
||||
// pathsToJoin.push(pathToJoin + '.ts');
|
||||
// }
|
||||
|
||||
// let newTime = 0;
|
||||
|
||||
// let j;
|
||||
// for(j = 0; j < pathsToJoin.length; j++) {
|
||||
// const path1 = pathsToNormalize[j];
|
||||
// const path2 = pathsToNormalize[j];
|
||||
|
||||
// const newStart = performance.now();
|
||||
// path.join(path1, path2);
|
||||
// newTime += performance.now() - newStart;
|
||||
// }
|
||||
|
||||
// assert.ok(false, `Time: ${newTime}ms.`);
|
||||
// });
|
||||
});
|
||||
@@ -1,241 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
|
||||
suite('Paths', () => {
|
||||
|
||||
function assertDirname(path: string, expected: string, win = false) {
|
||||
const actual = paths.dirname(path, win ? '\\' : '/');
|
||||
|
||||
if (actual !== expected) {
|
||||
assert.fail(`${path}: expected: ${expected}, ours: ${actual}`);
|
||||
}
|
||||
}
|
||||
|
||||
test('dirname', () => {
|
||||
assertDirname('foo/bar', 'foo');
|
||||
assertDirname('foo\\bar', 'foo', true);
|
||||
assertDirname('/foo/bar', '/foo');
|
||||
assertDirname('\\foo\\bar', '\\foo', true);
|
||||
assertDirname('/foo', '/');
|
||||
assertDirname('\\foo', '\\', true);
|
||||
assertDirname('/', '/');
|
||||
assertDirname('\\', '\\', true);
|
||||
assertDirname('foo', '.');
|
||||
assertDirname('f', '.');
|
||||
assertDirname('f/', '.');
|
||||
assertDirname('/folder/', '/');
|
||||
assertDirname('c:\\some\\file.txt', 'c:\\some', true);
|
||||
assertDirname('c:\\some', 'c:\\', true);
|
||||
assertDirname('c:\\', 'c:\\', true);
|
||||
assertDirname('c:', 'c:', true);
|
||||
assertDirname('\\\\server\\share\\some\\path', '\\\\server\\share\\some', true);
|
||||
assertDirname('\\\\server\\share\\some', '\\\\server\\share\\', true);
|
||||
assertDirname('\\\\server\\share\\', '\\\\server\\share\\', true);
|
||||
});
|
||||
|
||||
test('normalize', () => {
|
||||
assert.equal(paths.normalize(''), '.');
|
||||
assert.equal(paths.normalize('.'), '.');
|
||||
assert.equal(paths.normalize('.'), '.');
|
||||
assert.equal(paths.normalize('../../far'), '../../far');
|
||||
assert.equal(paths.normalize('../bar'), '../bar');
|
||||
assert.equal(paths.normalize('../far'), '../far');
|
||||
assert.equal(paths.normalize('./'), './');
|
||||
assert.equal(paths.normalize('./././'), './');
|
||||
assert.equal(paths.normalize('./ff/./'), 'ff/');
|
||||
assert.equal(paths.normalize('./foo'), 'foo');
|
||||
assert.equal(paths.normalize('/'), '/');
|
||||
assert.equal(paths.normalize('/..'), '/');
|
||||
assert.equal(paths.normalize('///'), '/');
|
||||
assert.equal(paths.normalize('//foo'), '/foo');
|
||||
assert.equal(paths.normalize('//foo//'), '/foo/');
|
||||
assert.equal(paths.normalize('/foo'), '/foo');
|
||||
assert.equal(paths.normalize('/foo/bar.test'), '/foo/bar.test');
|
||||
assert.equal(paths.normalize('\\\\\\'), '/');
|
||||
assert.equal(paths.normalize('c:/../ff'), 'c:/ff');
|
||||
assert.equal(paths.normalize('c:\\./'), 'c:/');
|
||||
assert.equal(paths.normalize('foo/'), 'foo/');
|
||||
assert.equal(paths.normalize('foo/../../bar'), '../bar');
|
||||
assert.equal(paths.normalize('foo/./'), 'foo/');
|
||||
assert.equal(paths.normalize('foo/./bar'), 'foo/bar');
|
||||
assert.equal(paths.normalize('foo//'), 'foo/');
|
||||
assert.equal(paths.normalize('foo//'), 'foo/');
|
||||
assert.equal(paths.normalize('foo//bar'), 'foo/bar');
|
||||
assert.equal(paths.normalize('foo//bar/far'), 'foo/bar/far');
|
||||
assert.equal(paths.normalize('foo/bar/../../far'), 'far');
|
||||
assert.equal(paths.normalize('foo/bar/../far'), 'foo/far');
|
||||
assert.equal(paths.normalize('foo/far/../../bar'), 'bar');
|
||||
assert.equal(paths.normalize('foo/far/../../bar'), 'bar');
|
||||
assert.equal(paths.normalize('foo/xxx/..'), 'foo');
|
||||
assert.equal(paths.normalize('foo/xxx/../bar'), 'foo/bar');
|
||||
assert.equal(paths.normalize('foo/xxx/./..'), 'foo');
|
||||
assert.equal(paths.normalize('foo/xxx/./../bar'), 'foo/bar');
|
||||
assert.equal(paths.normalize('foo/xxx/./bar'), 'foo/xxx/bar');
|
||||
assert.equal(paths.normalize('foo\\bar'), 'foo/bar');
|
||||
assert.equal(paths.normalize(null), null);
|
||||
assert.equal(paths.normalize(undefined), undefined);
|
||||
|
||||
// https://github.com/Microsoft/vscode/issues/7234
|
||||
assert.equal(paths.join('/home/aeschli/workspaces/vscode/extensions/css', './syntaxes/css.plist'), '/home/aeschli/workspaces/vscode/extensions/css/syntaxes/css.plist');
|
||||
});
|
||||
|
||||
test('getRootLength', () => {
|
||||
|
||||
assert.equal(paths.getRoot('/user/far'), '/');
|
||||
assert.equal(paths.getRoot('\\\\server\\share\\some\\path'), '//server/share/');
|
||||
assert.equal(paths.getRoot('//server/share/some/path'), '//server/share/');
|
||||
assert.equal(paths.getRoot('//server/share'), '/');
|
||||
assert.equal(paths.getRoot('//server'), '/');
|
||||
assert.equal(paths.getRoot('//server//'), '/');
|
||||
assert.equal(paths.getRoot('c:/user/far'), 'c:/');
|
||||
assert.equal(paths.getRoot('c:user/far'), 'c:');
|
||||
assert.equal(paths.getRoot('http://www'), '');
|
||||
assert.equal(paths.getRoot('http://www/'), 'http://www/');
|
||||
assert.equal(paths.getRoot('file:///foo'), 'file:///');
|
||||
assert.equal(paths.getRoot('file://foo'), '');
|
||||
|
||||
});
|
||||
|
||||
test('basename', () => {
|
||||
assert.equal(paths.basename('foo/bar'), 'bar');
|
||||
assert.equal(paths.basename('foo\\bar'), 'bar');
|
||||
assert.equal(paths.basename('/foo/bar'), 'bar');
|
||||
assert.equal(paths.basename('\\foo\\bar'), 'bar');
|
||||
assert.equal(paths.basename('./bar'), 'bar');
|
||||
assert.equal(paths.basename('.\\bar'), 'bar');
|
||||
assert.equal(paths.basename('/bar'), 'bar');
|
||||
assert.equal(paths.basename('\\bar'), 'bar');
|
||||
assert.equal(paths.basename('bar/'), 'bar');
|
||||
assert.equal(paths.basename('bar\\'), 'bar');
|
||||
assert.equal(paths.basename('bar'), 'bar');
|
||||
assert.equal(paths.basename('////////'), '');
|
||||
assert.equal(paths.basename('\\\\\\\\'), '');
|
||||
});
|
||||
|
||||
test('join', () => {
|
||||
assert.equal(paths.join('.', 'bar'), 'bar');
|
||||
assert.equal(paths.join('../../foo/bar', '../../foo'), '../../foo');
|
||||
assert.equal(paths.join('../../foo/bar', '../bar/foo'), '../../foo/bar/foo');
|
||||
assert.equal(paths.join('../foo/bar', '../bar/foo'), '../foo/bar/foo');
|
||||
assert.equal(paths.join('/', 'bar'), '/bar');
|
||||
assert.equal(paths.join('//server/far/boo', '../file.txt'), '//server/far/file.txt');
|
||||
assert.equal(paths.join('/foo/', '/bar'), '/foo/bar');
|
||||
assert.equal(paths.join('\\\\server\\far\\boo', '../file.txt'), '//server/far/file.txt');
|
||||
assert.equal(paths.join('\\\\server\\far\\boo', './file.txt'), '//server/far/boo/file.txt');
|
||||
assert.equal(paths.join('\\\\server\\far\\boo', '.\\file.txt'), '//server/far/boo/file.txt');
|
||||
assert.equal(paths.join('\\\\server\\far\\boo', 'file.txt'), '//server/far/boo/file.txt');
|
||||
assert.equal(paths.join('file:///c/users/test', 'test'), 'file:///c/users/test/test');
|
||||
assert.equal(paths.join('file://localhost/c$/GitDevelopment/express', './settings'), 'file://localhost/c$/GitDevelopment/express/settings'); // unc
|
||||
assert.equal(paths.join('file://localhost/c$/GitDevelopment/express', '.settings'), 'file://localhost/c$/GitDevelopment/express/.settings'); // unc
|
||||
assert.equal(paths.join('foo', '/bar'), 'foo/bar');
|
||||
assert.equal(paths.join('foo', 'bar'), 'foo/bar');
|
||||
assert.equal(paths.join('foo', 'bar/'), 'foo/bar/');
|
||||
assert.equal(paths.join('foo/', '/bar'), 'foo/bar');
|
||||
assert.equal(paths.join('foo/', '/bar/'), 'foo/bar/');
|
||||
assert.equal(paths.join('foo/', 'bar'), 'foo/bar');
|
||||
assert.equal(paths.join('foo/bar', '../bar/foo'), 'foo/bar/foo');
|
||||
assert.equal(paths.join('foo/bar', './bar/foo'), 'foo/bar/bar/foo');
|
||||
assert.equal(paths.join('http://localhost/test', '../next'), 'http://localhost/next');
|
||||
assert.equal(paths.join('http://localhost/test', 'test'), 'http://localhost/test/test');
|
||||
});
|
||||
|
||||
test('extname', () => {
|
||||
assert.equal(paths.extname('far.boo'), '.boo');
|
||||
assert.equal(paths.extname('far.b'), '.b');
|
||||
assert.equal(paths.extname('far.'), '.');
|
||||
assert.equal(paths.extname('far.boo/boo.far'), '.far');
|
||||
assert.equal(paths.extname('far.boo/boo'), '');
|
||||
});
|
||||
|
||||
test('isUNC', () => {
|
||||
if (platform.isWindows) {
|
||||
assert.ok(!paths.isUNC('foo'));
|
||||
assert.ok(!paths.isUNC('/foo'));
|
||||
assert.ok(!paths.isUNC('\\foo'));
|
||||
assert.ok(!paths.isUNC('\\\\foo'));
|
||||
assert.ok(paths.isUNC('\\\\a\\b'));
|
||||
assert.ok(!paths.isUNC('//a/b'));
|
||||
assert.ok(paths.isUNC('\\\\server\\share'));
|
||||
assert.ok(paths.isUNC('\\\\server\\share\\'));
|
||||
assert.ok(paths.isUNC('\\\\server\\share\\path'));
|
||||
}
|
||||
});
|
||||
|
||||
test('isValidBasename', () => {
|
||||
assert.ok(!paths.isValidBasename(null));
|
||||
assert.ok(!paths.isValidBasename(''));
|
||||
assert.ok(paths.isValidBasename('test.txt'));
|
||||
assert.ok(!paths.isValidBasename('/test.txt'));
|
||||
assert.ok(!paths.isValidBasename('\\test.txt'));
|
||||
|
||||
if (platform.isWindows) {
|
||||
assert.ok(!paths.isValidBasename('aux'));
|
||||
assert.ok(!paths.isValidBasename('Aux'));
|
||||
assert.ok(!paths.isValidBasename('LPT0'));
|
||||
assert.ok(!paths.isValidBasename('test.txt.'));
|
||||
assert.ok(!paths.isValidBasename('test.txt..'));
|
||||
assert.ok(!paths.isValidBasename('test.txt '));
|
||||
assert.ok(!paths.isValidBasename('test.txt\t'));
|
||||
assert.ok(!paths.isValidBasename('tes:t.txt'));
|
||||
assert.ok(!paths.isValidBasename('tes"t.txt'));
|
||||
}
|
||||
});
|
||||
|
||||
test('isAbsolute_win', () => {
|
||||
// Absolute paths
|
||||
[
|
||||
'C:/',
|
||||
'C:\\',
|
||||
'C:/foo',
|
||||
'C:\\foo',
|
||||
'z:/foo/bar.txt',
|
||||
'z:\\foo\\bar.txt',
|
||||
|
||||
'\\\\localhost\\c$\\foo',
|
||||
|
||||
'/',
|
||||
'/foo'
|
||||
].forEach(absolutePath => {
|
||||
assert.ok(paths.isAbsolute_win32(absolutePath), absolutePath);
|
||||
});
|
||||
|
||||
// Not absolute paths
|
||||
[
|
||||
'',
|
||||
'foo',
|
||||
'foo/bar',
|
||||
'./foo',
|
||||
'http://foo.com/bar'
|
||||
].forEach(nonAbsolutePath => {
|
||||
assert.ok(!paths.isAbsolute_win32(nonAbsolutePath), nonAbsolutePath);
|
||||
});
|
||||
});
|
||||
|
||||
test('isAbsolute_posix', () => {
|
||||
// Absolute paths
|
||||
[
|
||||
'/',
|
||||
'/foo',
|
||||
'/foo/bar.txt'
|
||||
].forEach(absolutePath => {
|
||||
assert.ok(paths.isAbsolute_posix(absolutePath), absolutePath);
|
||||
});
|
||||
|
||||
// Not absolute paths
|
||||
[
|
||||
'',
|
||||
'foo',
|
||||
'foo/bar',
|
||||
'./foo',
|
||||
'http://foo.com/bar',
|
||||
'z:/foo/bar.txt',
|
||||
].forEach(nonAbsolutePath => {
|
||||
assert.ok(!paths.isAbsolute_posix(nonAbsolutePath), nonAbsolutePath);
|
||||
});
|
||||
});
|
||||
});
|
||||
33
src/vs/base/test/common/processes.test.ts
Normal file
33
src/vs/base/test/common/processes.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as processes from 'vs/base/common/processes';
|
||||
|
||||
suite('Processes', () => {
|
||||
test('sanitizeProcessEnvironment', () => {
|
||||
let env = {
|
||||
FOO: 'bar',
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 'x',
|
||||
ELECTRON_ENABLE_LOGGING: 'x',
|
||||
ELECTRON_NO_ASAR: 'x',
|
||||
ELECTRON_NO_ATTACH_CONSOLE: 'x',
|
||||
ELECTRON_RUN_AS_NODE: 'x',
|
||||
GOOGLE_API_KEY: 'x',
|
||||
VSCODE_CLI: 'x',
|
||||
VSCODE_DEV: 'x',
|
||||
VSCODE_IPC_HOOK: 'x',
|
||||
VSCODE_LOGS: 'x',
|
||||
VSCODE_NLS_CONFIG: 'x',
|
||||
VSCODE_PORTABLE: 'x',
|
||||
VSCODE_PID: 'x',
|
||||
VSCODE_NODE_CACHED_DATA_DIR: 'x',
|
||||
VSCODE_NEW_VAR: 'x'
|
||||
};
|
||||
processes.sanitizeProcessEnvironment(env);
|
||||
assert.equal(env['FOO'], 'bar');
|
||||
assert.equal(Object.keys(env).length, 1);
|
||||
});
|
||||
});
|
||||
@@ -3,9 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { dirname, basename, distinctParents, joinPath, isEqual, isEqualOrParent, hasToIgnoreCase, normalizePath, isAbsolutePath, isMalformedFileUri } from 'vs/base/common/resources';
|
||||
import { URI, setUriThrowOnMissingScheme } from 'vs/base/common/uri';
|
||||
import { dirname, basename, distinctParents, joinPath, isEqual, isEqualOrParent, hasToIgnoreCase, normalizePath, isAbsolutePath, relativePath, removeTrailingPathSeparator, hasTrailingPathSeparator, resolvePath } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { toSlashes } from 'vs/base/common/extpath';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { isAbsolute } from 'vs/base/common/path';
|
||||
|
||||
|
||||
suite('Resources', () => {
|
||||
|
||||
@@ -42,23 +46,23 @@ suite('Resources', () => {
|
||||
|
||||
test('dirname', () => {
|
||||
if (isWindows) {
|
||||
assert.equal(dirname(URI.file('c:\\some\\file\\test.txt'))!.toString(), 'file:///c%3A/some/file');
|
||||
assert.equal(dirname(URI.file('c:\\some\\file'))!.toString(), 'file:///c%3A/some');
|
||||
assert.equal(dirname(URI.file('c:\\some\\file\\'))!.toString(), 'file:///c%3A/some');
|
||||
assert.equal(dirname(URI.file('c:\\some'))!.toString(), 'file:///c%3A/');
|
||||
assert.equal(dirname(URI.file('C:\\some'))!.toString(), 'file:///c%3A/');
|
||||
assert.equal(dirname(URI.file('c:\\'))!.toString(), 'file:///c%3A/');
|
||||
assert.equal(dirname(URI.file('c:\\some\\file\\test.txt')).toString(), 'file:///c%3A/some/file');
|
||||
assert.equal(dirname(URI.file('c:\\some\\file')).toString(), 'file:///c%3A/some');
|
||||
assert.equal(dirname(URI.file('c:\\some\\file\\')).toString(), 'file:///c%3A/some');
|
||||
assert.equal(dirname(URI.file('c:\\some')).toString(), 'file:///c%3A/');
|
||||
assert.equal(dirname(URI.file('C:\\some')).toString(), 'file:///c%3A/');
|
||||
assert.equal(dirname(URI.file('c:\\')).toString(), 'file:///c%3A/');
|
||||
} else {
|
||||
assert.equal(dirname(URI.file('/some/file/test.txt'))!.toString(), 'file:///some/file');
|
||||
assert.equal(dirname(URI.file('/some/file/'))!.toString(), 'file:///some');
|
||||
assert.equal(dirname(URI.file('/some/file'))!.toString(), 'file:///some');
|
||||
assert.equal(dirname(URI.file('/some/file/test.txt')).toString(), 'file:///some/file');
|
||||
assert.equal(dirname(URI.file('/some/file/')).toString(), 'file:///some');
|
||||
assert.equal(dirname(URI.file('/some/file')).toString(), 'file:///some');
|
||||
}
|
||||
assert.equal(dirname(URI.parse('foo://a/some/file/test.txt'))!.toString(), 'foo://a/some/file');
|
||||
assert.equal(dirname(URI.parse('foo://a/some/file/'))!.toString(), 'foo://a/some');
|
||||
assert.equal(dirname(URI.parse('foo://a/some/file'))!.toString(), 'foo://a/some');
|
||||
assert.equal(dirname(URI.parse('foo://a/some'))!.toString(), 'foo://a/');
|
||||
assert.equal(dirname(URI.parse('foo://a/'))!.toString(), 'foo://a/');
|
||||
assert.equal(dirname(URI.parse('foo://a'))!.toString(), 'foo://a');
|
||||
assert.equal(dirname(URI.parse('foo://a/some/file/test.txt')).toString(), 'foo://a/some/file');
|
||||
assert.equal(dirname(URI.parse('foo://a/some/file/')).toString(), 'foo://a/some');
|
||||
assert.equal(dirname(URI.parse('foo://a/some/file')).toString(), 'foo://a/some');
|
||||
assert.equal(dirname(URI.parse('foo://a/some')).toString(), 'foo://a/');
|
||||
assert.equal(dirname(URI.parse('foo://a/')).toString(), 'foo://a/');
|
||||
assert.equal(dirname(URI.parse('foo://a')).toString(), 'foo://a');
|
||||
|
||||
// does not explode (https://github.com/Microsoft/vscode/issues/41987)
|
||||
dirname(URI.from({ scheme: 'file', authority: '/users/someone/portal.h' }));
|
||||
@@ -166,6 +170,150 @@ suite('Resources', () => {
|
||||
assert.equal(isAbsolutePath(URI.parse('foo://a/foo/.')), true);
|
||||
});
|
||||
|
||||
function assertTrailingSeparator(u1: URI, expected: boolean) {
|
||||
assert.equal(hasTrailingPathSeparator(u1), expected, u1.toString());
|
||||
}
|
||||
|
||||
function assertRemoveTrailingSeparator(u1: URI, expected: URI) {
|
||||
assertEqualURI(removeTrailingPathSeparator(u1), expected, u1.toString());
|
||||
}
|
||||
|
||||
|
||||
test('trailingPathSeparator', () => {
|
||||
assertTrailingSeparator(URI.parse('foo://a/foo'), false);
|
||||
assertTrailingSeparator(URI.parse('foo://a/foo/'), true);
|
||||
assertTrailingSeparator(URI.parse('foo://a/'), false);
|
||||
assertTrailingSeparator(URI.parse('foo://a'), false);
|
||||
|
||||
assertRemoveTrailingSeparator(URI.parse('foo://a/foo'), URI.parse('foo://a/foo'));
|
||||
assertRemoveTrailingSeparator(URI.parse('foo://a/foo/'), URI.parse('foo://a/foo'));
|
||||
assertRemoveTrailingSeparator(URI.parse('foo://a/'), URI.parse('foo://a/'));
|
||||
assertRemoveTrailingSeparator(URI.parse('foo://a'), URI.parse('foo://a'));
|
||||
|
||||
if (isWindows) {
|
||||
assertTrailingSeparator(URI.file('c:\\a\\foo'), false);
|
||||
assertTrailingSeparator(URI.file('c:\\a\\foo\\'), true);
|
||||
assertTrailingSeparator(URI.file('c:\\'), false);
|
||||
assertTrailingSeparator(URI.file('\\\\server\\share\\some\\'), true);
|
||||
assertTrailingSeparator(URI.file('\\\\server\\share\\'), false);
|
||||
|
||||
assertRemoveTrailingSeparator(URI.file('c:\\a\\foo'), URI.file('c:\\a\\foo'));
|
||||
assertRemoveTrailingSeparator(URI.file('c:\\a\\foo\\'), URI.file('c:\\a\\foo'));
|
||||
assertRemoveTrailingSeparator(URI.file('c:\\'), URI.file('c:\\'));
|
||||
assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share\\some'));
|
||||
assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\'), URI.file('\\\\server\\share\\'));
|
||||
} else {
|
||||
assertTrailingSeparator(URI.file('/foo/bar'), false);
|
||||
assertTrailingSeparator(URI.file('/foo/bar/'), true);
|
||||
assertTrailingSeparator(URI.file('/'), false);
|
||||
|
||||
assertRemoveTrailingSeparator(URI.file('/foo/bar'), URI.file('/foo/bar'));
|
||||
assertRemoveTrailingSeparator(URI.file('/foo/bar/'), URI.file('/foo/bar'));
|
||||
assertRemoveTrailingSeparator(URI.file('/'), URI.file('/'));
|
||||
}
|
||||
});
|
||||
|
||||
function assertEqualURI(actual: URI, expected: URI, message?: string) {
|
||||
if (!isEqual(expected, actual)) {
|
||||
assert.equal(expected.toString(), actual.toString(), message);
|
||||
}
|
||||
}
|
||||
|
||||
function assertRelativePath(u1: URI, u2: URI, expectedPath: string | undefined, ignoreJoin?: boolean) {
|
||||
assert.equal(relativePath(u1, u2), expectedPath, `from ${u1.toString()} to ${u2.toString()}`);
|
||||
if (expectedPath !== undefined && !ignoreJoin) {
|
||||
assertEqualURI(removeTrailingPathSeparator(joinPath(u1, expectedPath)), removeTrailingPathSeparator(u2), 'joinPath on relativePath should be equal');
|
||||
}
|
||||
}
|
||||
|
||||
test('relativePath', () => {
|
||||
assertRelativePath(URI.parse('foo://a/foo'), URI.parse('foo://a/foo/bar'), 'bar');
|
||||
assertRelativePath(URI.parse('foo://a/foo'), URI.parse('foo://a/foo/bar/'), 'bar');
|
||||
assertRelativePath(URI.parse('foo://a/foo'), URI.parse('foo://a/foo/bar/goo'), 'bar/goo');
|
||||
assertRelativePath(URI.parse('foo://a/'), URI.parse('foo://a/foo/bar/goo'), 'foo/bar/goo');
|
||||
assertRelativePath(URI.parse('foo://a/foo/xoo'), URI.parse('foo://a/foo/bar'), '../bar');
|
||||
assertRelativePath(URI.parse('foo://a/foo/xoo/yoo'), URI.parse('foo://a'), '../../..');
|
||||
assertRelativePath(URI.parse('foo://a/foo'), URI.parse('foo://a/foo/'), '');
|
||||
assertRelativePath(URI.parse('foo://a/foo/'), URI.parse('foo://a/foo'), '');
|
||||
assertRelativePath(URI.parse('foo://a/foo/'), URI.parse('foo://a/foo/'), '');
|
||||
assertRelativePath(URI.parse('foo://a/foo'), URI.parse('foo://a/foo'), '');
|
||||
assertRelativePath(URI.parse('foo://a'), URI.parse('foo://a'), '');
|
||||
assertRelativePath(URI.parse('foo://a/'), URI.parse('foo://a/'), '');
|
||||
assertRelativePath(URI.parse('foo://a/'), URI.parse('foo://a'), '');
|
||||
assertRelativePath(URI.parse('foo://a/foo?q'), URI.parse('foo://a/foo/bar#h'), 'bar');
|
||||
assertRelativePath(URI.parse('foo://'), URI.parse('foo://a/b'), undefined);
|
||||
assertRelativePath(URI.parse('foo://a2/b'), URI.parse('foo://a/b'), undefined);
|
||||
assertRelativePath(URI.parse('goo://a/b'), URI.parse('foo://a/b'), undefined);
|
||||
|
||||
if (isWindows) {
|
||||
assertRelativePath(URI.file('c:\\foo\\bar'), URI.file('c:\\foo\\bar'), '');
|
||||
assertRelativePath(URI.file('c:\\foo\\bar\\huu'), URI.file('c:\\foo\\bar'), '..');
|
||||
assertRelativePath(URI.file('c:\\foo\\bar\\a1\\a2'), URI.file('c:\\foo\\bar'), '../..');
|
||||
assertRelativePath(URI.file('c:\\foo\\bar\\'), URI.file('c:\\foo\\bar\\a1\\a2'), 'a1/a2');
|
||||
assertRelativePath(URI.file('c:\\foo\\bar\\'), URI.file('c:\\foo\\bar\\a1\\a2\\'), 'a1/a2');
|
||||
assertRelativePath(URI.file('c:\\'), URI.file('c:\\foo\\bar'), 'foo/bar');
|
||||
assertRelativePath(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share\\some\\path'), 'path');
|
||||
assertRelativePath(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share2\\some\\path'), '../../share2/some/path', true); // ignore joinPath assert: path.join is not root aware
|
||||
} else {
|
||||
assertRelativePath(URI.file('/a/foo'), URI.file('/a/foo/bar'), 'bar');
|
||||
assertRelativePath(URI.file('/a/foo'), URI.file('/a/foo/bar/'), 'bar');
|
||||
assertRelativePath(URI.file('/a/foo'), URI.file('/a/foo/bar/goo'), 'bar/goo');
|
||||
assertRelativePath(URI.file('/a/'), URI.file('/a/foo/bar/goo'), 'foo/bar/goo');
|
||||
assertRelativePath(URI.file('/'), URI.file('/a/foo/bar/goo'), 'a/foo/bar/goo');
|
||||
assertRelativePath(URI.file('/a/foo/xoo'), URI.file('/a/foo/bar'), '../bar');
|
||||
assertRelativePath(URI.file('/a/foo/xoo/yoo'), URI.file('/a'), '../../..');
|
||||
assertRelativePath(URI.file('/a/foo'), URI.file('/a/foo/'), '');
|
||||
assertRelativePath(URI.file('/a/foo'), URI.file('/b/foo/'), '../../b/foo');
|
||||
}
|
||||
});
|
||||
|
||||
function assertResolve(u1: URI, path: string, expected: URI) {
|
||||
const actual = resolvePath(u1, path);
|
||||
assertEqualURI(actual, expected, `from ${u1.toString()} and ${path}`);
|
||||
|
||||
if (!isAbsolute(path)) {
|
||||
let expectedPath = isWindows ? toSlashes(path) : path;
|
||||
expectedPath = startsWith(expectedPath, './') ? expectedPath.substr(2) : expectedPath;
|
||||
assert.equal(relativePath(u1, actual), expectedPath, `relativePath (${u1.toString()}) on actual (${actual.toString()}) should be to path (${expectedPath})`);
|
||||
}
|
||||
}
|
||||
|
||||
test('resolve', () => {
|
||||
if (isWindows) {
|
||||
assertResolve(URI.file('c:\\foo\\bar'), 'file.js', URI.file('c:\\foo\\bar\\file.js'));
|
||||
assertResolve(URI.file('c:\\foo\\bar'), 't\\file.js', URI.file('c:\\foo\\bar\\t\\file.js'));
|
||||
assertResolve(URI.file('c:\\foo\\bar'), '.\\t\\file.js', URI.file('c:\\foo\\bar\\t\\file.js'));
|
||||
assertResolve(URI.file('c:\\foo\\bar'), 'a1/file.js', URI.file('c:\\foo\\bar\\a1\\file.js'));
|
||||
assertResolve(URI.file('c:\\foo\\bar'), './a1/file.js', URI.file('c:\\foo\\bar\\a1\\file.js'));
|
||||
assertResolve(URI.file('c:\\foo\\bar'), '\\b1\\file.js', URI.file('c:\\b1\\file.js'));
|
||||
assertResolve(URI.file('c:\\foo\\bar'), '/b1/file.js', URI.file('c:\\b1\\file.js'));
|
||||
assertResolve(URI.file('c:\\foo\\bar\\'), 'file.js', URI.file('c:\\foo\\bar\\file.js'));
|
||||
|
||||
assertResolve(URI.file('c:\\'), 'file.js', URI.file('c:\\file.js'));
|
||||
assertResolve(URI.file('c:\\'), '\\b1\\file.js', URI.file('c:\\b1\\file.js'));
|
||||
assertResolve(URI.file('c:\\'), '/b1/file.js', URI.file('c:\\b1\\file.js'));
|
||||
assertResolve(URI.file('c:\\'), 'd:\\foo\\bar.txt', URI.file('d:\\foo\\bar.txt'));
|
||||
|
||||
assertResolve(URI.file('\\\\server\\share\\some\\'), 'b1\\file.js', URI.file('\\\\server\\share\\some\\b1\\file.js'));
|
||||
assertResolve(URI.file('\\\\server\\share\\some\\'), '\\file.js', URI.file('\\\\server\\share\\file.js'));
|
||||
|
||||
assertResolve(URI.file('c:\\'), '\\\\server\\share\\some\\', URI.file('\\\\server\\share\\some'));
|
||||
assertResolve(URI.file('\\\\server\\share\\some\\'), 'c:\\', URI.file('c:\\'));
|
||||
} else {
|
||||
assertResolve(URI.file('/foo/bar'), 'file.js', URI.file('/foo/bar/file.js'));
|
||||
assertResolve(URI.file('/foo/bar'), './file.js', URI.file('/foo/bar/file.js'));
|
||||
assertResolve(URI.file('/foo/bar'), '/file.js', URI.file('/file.js'));
|
||||
assertResolve(URI.file('/foo/bar/'), 'file.js', URI.file('/foo/bar/file.js'));
|
||||
assertResolve(URI.file('/'), 'file.js', URI.file('/file.js'));
|
||||
assertResolve(URI.file(''), './file.js', URI.file('/file.js'));
|
||||
assertResolve(URI.file(''), '/file.js', URI.file('/file.js'));
|
||||
}
|
||||
|
||||
assertResolve(URI.parse('foo://server/foo/bar'), 'file.js', URI.parse('foo://server/foo/bar/file.js'));
|
||||
assertResolve(URI.parse('foo://server/foo/bar'), './file.js', URI.parse('foo://server/foo/bar/file.js'));
|
||||
assertResolve(URI.parse('foo://server/foo/bar'), './file.js', URI.parse('foo://server/foo/bar/file.js'));
|
||||
});
|
||||
|
||||
test('isEqual', () => {
|
||||
let fileURI = isWindows ? URI.file('c:\\foo\\bar') : URI.file('/foo/bar');
|
||||
let fileURI2 = isWindows ? URI.file('C:\\foo\\Bar') : URI.file('/foo/Bar');
|
||||
@@ -184,6 +332,8 @@ suite('Resources', () => {
|
||||
assert.equal(isEqual(fileURI3, fileURI4, false), false);
|
||||
|
||||
assert.equal(isEqual(fileURI, fileURI3, true), false);
|
||||
|
||||
assert.equal(isEqual(URI.parse('foo://server'), URI.parse('foo://server/')), true);
|
||||
});
|
||||
|
||||
test('isEqualOrParent', () => {
|
||||
@@ -210,27 +360,4 @@ suite('Resources', () => {
|
||||
assert.equal(isEqualOrParent(fileURI3, fileURI, true), false, '15');
|
||||
assert.equal(isEqualOrParent(fileURI5, fileURI5, true), true, '16');
|
||||
});
|
||||
|
||||
function assertMalformedFileUri(path: string, expected: string | undefined) {
|
||||
const old = setUriThrowOnMissingScheme(false);
|
||||
const newURI = isMalformedFileUri(URI.parse(path));
|
||||
assert.equal(newURI && newURI.toString(), expected);
|
||||
setUriThrowOnMissingScheme(old);
|
||||
}
|
||||
|
||||
test('isMalformedFileUri', () => {
|
||||
if (isWindows) {
|
||||
assertMalformedFileUri('c:/foo/bar', 'file:///c%3A/foo/bar');
|
||||
assertMalformedFileUri('c:\\foo\\bar', 'file:///c%3A/foo/bar');
|
||||
assertMalformedFileUri('C:\\foo\\bar', 'file:///c%3A/foo/bar');
|
||||
assertMalformedFileUri('\\\\localhost\\c$\\devel\\test', 'file://localhost/c%24/devel/test');
|
||||
}
|
||||
assertMalformedFileUri('/foo/bar', 'file:///foo/bar');
|
||||
|
||||
assertMalformedFileUri('file:///foo/bar', undefined);
|
||||
assertMalformedFileUri('file:///c%3A/foo/bar', undefined);
|
||||
assertMalformedFileUri('file://localhost/c$/devel/test', undefined);
|
||||
assertMalformedFileUri('foo://dadie/foo/bar', undefined);
|
||||
assertMalformedFileUri('foo:///dadie/foo/bar', undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -403,4 +403,59 @@ suite('Strings', () => {
|
||||
assert.equal(strings.getNLines('foo\nbar\nsomething', 2), 'foo\nbar');
|
||||
assert.equal(strings.getNLines('foo', 0), '');
|
||||
});
|
||||
|
||||
test('removeAccents', function () {
|
||||
assert.equal(strings.removeAccents('joào'), 'joao');
|
||||
assert.equal(strings.removeAccents('joáo'), 'joao');
|
||||
assert.equal(strings.removeAccents('joâo'), 'joao');
|
||||
assert.equal(strings.removeAccents('joäo'), 'joao');
|
||||
// assert.equal(strings.removeAccents('joæo'), 'joao'); // not an accent
|
||||
assert.equal(strings.removeAccents('joão'), 'joao');
|
||||
assert.equal(strings.removeAccents('joåo'), 'joao');
|
||||
assert.equal(strings.removeAccents('joåo'), 'joao');
|
||||
assert.equal(strings.removeAccents('joāo'), 'joao');
|
||||
|
||||
assert.equal(strings.removeAccents('fôo'), 'foo');
|
||||
assert.equal(strings.removeAccents('föo'), 'foo');
|
||||
assert.equal(strings.removeAccents('fòo'), 'foo');
|
||||
assert.equal(strings.removeAccents('fóo'), 'foo');
|
||||
// assert.equal(strings.removeAccents('fœo'), 'foo');
|
||||
// assert.equal(strings.removeAccents('føo'), 'foo');
|
||||
assert.equal(strings.removeAccents('fōo'), 'foo');
|
||||
assert.equal(strings.removeAccents('fõo'), 'foo');
|
||||
|
||||
assert.equal(strings.removeAccents('andrè'), 'andre');
|
||||
assert.equal(strings.removeAccents('andré'), 'andre');
|
||||
assert.equal(strings.removeAccents('andrê'), 'andre');
|
||||
assert.equal(strings.removeAccents('andrë'), 'andre');
|
||||
assert.equal(strings.removeAccents('andrē'), 'andre');
|
||||
assert.equal(strings.removeAccents('andrė'), 'andre');
|
||||
assert.equal(strings.removeAccents('andrę'), 'andre');
|
||||
|
||||
assert.equal(strings.removeAccents('hvîc'), 'hvic');
|
||||
assert.equal(strings.removeAccents('hvïc'), 'hvic');
|
||||
assert.equal(strings.removeAccents('hvíc'), 'hvic');
|
||||
assert.equal(strings.removeAccents('hvīc'), 'hvic');
|
||||
assert.equal(strings.removeAccents('hvįc'), 'hvic');
|
||||
assert.equal(strings.removeAccents('hvìc'), 'hvic');
|
||||
|
||||
assert.equal(strings.removeAccents('ûdo'), 'udo');
|
||||
assert.equal(strings.removeAccents('üdo'), 'udo');
|
||||
assert.equal(strings.removeAccents('ùdo'), 'udo');
|
||||
assert.equal(strings.removeAccents('údo'), 'udo');
|
||||
assert.equal(strings.removeAccents('ūdo'), 'udo');
|
||||
|
||||
assert.equal(strings.removeAccents('heÿ'), 'hey');
|
||||
|
||||
// assert.equal(strings.removeAccents('gruß'), 'grus');
|
||||
assert.equal(strings.removeAccents('gruś'), 'grus');
|
||||
assert.equal(strings.removeAccents('gruš'), 'grus');
|
||||
|
||||
assert.equal(strings.removeAccents('çool'), 'cool');
|
||||
assert.equal(strings.removeAccents('ćool'), 'cool');
|
||||
assert.equal(strings.removeAccents('čool'), 'cool');
|
||||
|
||||
assert.equal(strings.removeAccents('ñice'), 'nice');
|
||||
assert.equal(strings.removeAccents('ńice'), 'nice');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { normalize } from 'vs/base/common/paths';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
|
||||
@@ -141,7 +140,6 @@ suite('URI', () => {
|
||||
assert.equal(value.scheme, 'http');
|
||||
assert.equal(value.authority, 'api');
|
||||
assert.equal(value.path, '/files/test.me');
|
||||
assert.equal(value.fsPath, normalize('/files/test.me', true));
|
||||
assert.equal(value.query, 't=1234');
|
||||
assert.equal(value.fragment, '');
|
||||
|
||||
@@ -151,7 +149,7 @@ suite('URI', () => {
|
||||
assert.equal(value.path, '/c:/test/me');
|
||||
assert.equal(value.fragment, '');
|
||||
assert.equal(value.query, '');
|
||||
assert.equal(value.fsPath, normalize('c:/test/me', true));
|
||||
assert.equal(value.fsPath, isWindows ? 'c:\\test\\me' : 'c:/test/me');
|
||||
|
||||
value = URI.parse('file://shares/files/c%23/p.cs');
|
||||
assert.equal(value.scheme, 'file');
|
||||
@@ -159,7 +157,7 @@ suite('URI', () => {
|
||||
assert.equal(value.path, '/files/c#/p.cs');
|
||||
assert.equal(value.fragment, '');
|
||||
assert.equal(value.query, '');
|
||||
assert.equal(value.fsPath, normalize('//shares/files/c#/p.cs', true));
|
||||
assert.equal(value.fsPath, isWindows ? '\\\\shares\\files\\c#\\p.cs' : '//shares/files/c#/p.cs');
|
||||
|
||||
value = URI.parse('file:///c:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins/c%23/plugin.json');
|
||||
assert.equal(value.scheme, 'file');
|
||||
@@ -360,7 +358,6 @@ suite('URI', () => {
|
||||
test('correctFileUriToFilePath2', () => {
|
||||
|
||||
const test = (input: string, expected: string) => {
|
||||
expected = normalize(expected, true);
|
||||
const value = URI.parse(input);
|
||||
assert.equal(value.fsPath, expected, 'Result for ' + input);
|
||||
const value2 = URI.file(value.fsPath);
|
||||
@@ -368,10 +365,10 @@ suite('URI', () => {
|
||||
assert.equal(value.toString(), value2.toString());
|
||||
};
|
||||
|
||||
test('file:///c:/alex.txt', 'c:\\alex.txt');
|
||||
test('file:///c:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins', 'c:\\Source\\Zürich or Zurich (ˈzjʊərɪk,\\Code\\resources\\app\\plugins');
|
||||
test('file://monacotools/folder/isi.txt', '\\\\monacotools\\folder\\isi.txt');
|
||||
test('file://monacotools1/certificates/SSL/', '\\\\monacotools1\\certificates\\SSL\\');
|
||||
test('file:///c:/alex.txt', isWindows ? 'c:\\alex.txt' : 'c:/alex.txt');
|
||||
test('file:///c:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins', isWindows ? 'c:\\Source\\Zürich or Zurich (ˈzjʊərɪk,\\Code\\resources\\app\\plugins' : 'c:/Source/Zürich or Zurich (ˈzjʊərɪk,/Code/resources/app/plugins');
|
||||
test('file://monacotools/folder/isi.txt', isWindows ? '\\\\monacotools\\folder\\isi.txt' : '//monacotools/folder/isi.txt');
|
||||
test('file://monacotools1/certificates/SSL/', isWindows ? '\\\\monacotools1\\certificates\\SSL\\' : '//monacotools1/certificates/SSL/');
|
||||
});
|
||||
|
||||
test('URI - http, query & toString', function () {
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { canceled } from 'vs/base/common/errors';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
export type ValueCallback<T = any> = (value: T | Promise<T>) => void;
|
||||
|
||||
@@ -49,7 +50,11 @@ export class DeferredPromise<T> {
|
||||
}
|
||||
|
||||
export function toResource(this: any, path: string) {
|
||||
return URI.file(paths.join('C:\\', Buffer.from(this.test.fullTitle()).toString('base64'), path));
|
||||
if (isWindows) {
|
||||
return URI.file(join('C:\\', Buffer.from(this.test.fullTitle()).toString('base64'), path));
|
||||
}
|
||||
|
||||
return URI.file(join('/', Buffer.from(this.test.fullTitle()).toString('base64'), path));
|
||||
}
|
||||
|
||||
export function suiteRepeat(n: number, description: string, callback: (this: any) => void): void {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as assert from 'assert';
|
||||
import * as os from 'os';
|
||||
|
||||
import * as path from 'path';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as fs from 'fs';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { ConfigWatcher } from 'vs/base/node/config';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { getFirstFrame } from 'vs/base/node/console';
|
||||
import { normalize } from 'path';
|
||||
import { normalize } from 'vs/base/common/path';
|
||||
|
||||
suite('Console', () => {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { Readable } from 'stream';
|
||||
import { canNormalize } from 'vs/base/common/normalization';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
@@ -102,6 +102,9 @@ suite('Glob', () => {
|
||||
p = 'C:/DNXConsoleApp/**/*.cs';
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\Program.cs');
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.cs');
|
||||
|
||||
p = '*';
|
||||
assertGlobMatch(p, '');
|
||||
});
|
||||
|
||||
test('dot hidden', function () {
|
||||
@@ -719,7 +722,10 @@ suite('Glob', () => {
|
||||
assert.strictEqual(glob.match(expr, 'bar', hasSibling), '**/bar');
|
||||
assert.strictEqual(glob.match(expr, 'foo', hasSibling), null);
|
||||
assert.strictEqual(glob.match(expr, 'foo/bar', hasSibling), '**/bar');
|
||||
assert.strictEqual(glob.match(expr, 'foo\\bar', hasSibling), '**/bar');
|
||||
if (isWindows) {
|
||||
// backslash is a valid file name character on posix
|
||||
assert.strictEqual(glob.match(expr, 'foo\\bar', hasSibling), '**/bar');
|
||||
}
|
||||
assert.strictEqual(glob.match(expr, 'foo/foo', hasSibling), null);
|
||||
assert.strictEqual(glob.match(expr, 'foo.js', hasSibling), '**/*.js');
|
||||
assert.strictEqual(glob.match(expr, 'bar.js', hasSibling), null);
|
||||
@@ -948,14 +954,14 @@ suite('Glob', () => {
|
||||
|
||||
test('relative pattern - glob star', function () {
|
||||
if (isWindows) {
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: '**/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: '**/*.cs' };
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.cs');
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\bar\\Program.cs');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.ts');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\Program.cs');
|
||||
assertNoGlobMatch(p, 'C:\\other\\DNXConsoleApp\\foo\\Program.ts');
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '**/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '**/*.cs' };
|
||||
assertGlobMatch(p, '/DNXConsoleApp/foo/Program.cs');
|
||||
assertGlobMatch(p, '/DNXConsoleApp/foo/bar/Program.cs');
|
||||
assertNoGlobMatch(p, '/DNXConsoleApp/foo/Program.ts');
|
||||
@@ -966,14 +972,14 @@ suite('Glob', () => {
|
||||
|
||||
test('relative pattern - single star', function () {
|
||||
if (isWindows) {
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: '*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: '*.cs' };
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.cs');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\bar\\Program.cs');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.ts');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\Program.cs');
|
||||
assertNoGlobMatch(p, 'C:\\other\\DNXConsoleApp\\foo\\Program.ts');
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '*.cs' };
|
||||
assertGlobMatch(p, '/DNXConsoleApp/foo/Program.cs');
|
||||
assertNoGlobMatch(p, '/DNXConsoleApp/foo/bar/Program.cs');
|
||||
assertNoGlobMatch(p, '/DNXConsoleApp/foo/Program.ts');
|
||||
@@ -984,11 +990,11 @@ suite('Glob', () => {
|
||||
|
||||
test('relative pattern - single star with path', function () {
|
||||
if (isWindows) {
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'something/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'something/*.cs' };
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\something\\Program.cs');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.cs');
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: 'something/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: 'something/*.cs' };
|
||||
assertGlobMatch(p, '/DNXConsoleApp/foo/something/Program.cs');
|
||||
assertNoGlobMatch(p, '/DNXConsoleApp/foo/Program.cs');
|
||||
}
|
||||
@@ -1000,11 +1006,11 @@ suite('Glob', () => {
|
||||
|
||||
test('relative pattern - #57475', function () {
|
||||
if (isWindows) {
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'styles/style.css', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'styles/style.css' };
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\styles\\style.css');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.cs');
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: 'styles/style.css', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: 'styles/style.css' };
|
||||
assertGlobMatch(p, '/DNXConsoleApp/foo/styles/style.css');
|
||||
assertNoGlobMatch(p, '/DNXConsoleApp/foo/Program.cs');
|
||||
}
|
||||
|
||||
35
src/vs/base/test/node/keytar.test.ts
Normal file
35
src/vs/base/test/node/keytar.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
|
||||
suite('Keytar', () => {
|
||||
|
||||
test('loads and is functional', function (done) {
|
||||
if (platform.isLinux) {
|
||||
// Skip test due to set up issue with Travis.
|
||||
this.skip();
|
||||
return;
|
||||
}
|
||||
(async () => {
|
||||
const keytar = await import('keytar');
|
||||
const name = `VSCode Test ${Math.floor(Math.random() * 1e9)}`;
|
||||
try {
|
||||
await keytar.setPassword(name, 'foo', 'bar');
|
||||
assert.equal(await keytar.getPassword(name, 'foo'), 'bar');
|
||||
await keytar.deletePassword(name, 'foo');
|
||||
assert.equal(await keytar.getPassword(name, 'foo'), undefined);
|
||||
} catch (err) {
|
||||
// try to clean up
|
||||
try {
|
||||
await keytar.deletePassword(name, 'foo');
|
||||
} finally {
|
||||
// tslint:disable-next-line: no-unsafe-finally
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
})().then(done, done);
|
||||
});
|
||||
});
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as assert from 'assert';
|
||||
import * as os from 'os';
|
||||
|
||||
import * as path from 'path';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
|
||||
@@ -84,29 +84,4 @@ suite('Processes', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('sanitizeProcessEnvironment', () => {
|
||||
let env = {
|
||||
FOO: 'bar',
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 'x',
|
||||
ELECTRON_ENABLE_LOGGING: 'x',
|
||||
ELECTRON_NO_ASAR: 'x',
|
||||
ELECTRON_NO_ATTACH_CONSOLE: 'x',
|
||||
ELECTRON_RUN_AS_NODE: 'x',
|
||||
GOOGLE_API_KEY: 'x',
|
||||
VSCODE_CLI: 'x',
|
||||
VSCODE_DEV: 'x',
|
||||
VSCODE_IPC_HOOK: 'x',
|
||||
VSCODE_LOGS: 'x',
|
||||
VSCODE_NLS_CONFIG: 'x',
|
||||
VSCODE_PORTABLE: 'x',
|
||||
VSCODE_PID: 'x',
|
||||
VSCODE_NODE_CACHED_DATA_DIR: 'x',
|
||||
VSCODE_NEW_VAR: 'x'
|
||||
};
|
||||
processes.sanitizeProcessEnvironment(env);
|
||||
assert.equal(env['FOO'], 'bar');
|
||||
assert.equal(Object.keys(env).length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Storage, SQLiteStorageDatabase, IStorageDatabase, ISQLiteStorageDatabaseOptions, IStorageItemsChangeEvent } from 'vs/base/node/storage';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { join } from 'path';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { tmpdir } from 'os';
|
||||
import { equal, ok } from 'assert';
|
||||
import { mkdirp, del, writeFile, exists, unlink } from 'vs/base/node/pfs';
|
||||
@@ -31,7 +31,7 @@ suite('Storage Library', () => {
|
||||
|
||||
// Empty fallbacks
|
||||
equal(storage.get('foo', 'bar'), 'bar');
|
||||
equal(storage.getInteger('foo', 55), 55);
|
||||
equal(storage.getNumber('foo', 55), 55);
|
||||
equal(storage.getBoolean('foo', true), true);
|
||||
|
||||
let changes = new Set<string>();
|
||||
@@ -45,7 +45,7 @@ suite('Storage Library', () => {
|
||||
const set3Promise = storage.set('barBoolean', true);
|
||||
|
||||
equal(storage.get('bar'), 'foo');
|
||||
equal(storage.getInteger('barNumber'), 55);
|
||||
equal(storage.getNumber('barNumber'), 55);
|
||||
equal(storage.getBoolean('barBoolean'), true);
|
||||
|
||||
equal(changes.size, 3);
|
||||
@@ -71,7 +71,7 @@ suite('Storage Library', () => {
|
||||
const delete3Promise = storage.delete('barBoolean');
|
||||
|
||||
ok(!storage.get('bar'));
|
||||
ok(!storage.getInteger('barNumber'));
|
||||
ok(!storage.getNumber('barNumber'));
|
||||
ok(!storage.getBoolean('barBoolean'));
|
||||
|
||||
equal(changes.size, 3);
|
||||
@@ -539,7 +539,9 @@ suite('SQLite Storage Library', () => {
|
||||
await del(storageDir, tmpdir());
|
||||
});
|
||||
|
||||
test('real world example', async () => {
|
||||
test('real world example', async function () {
|
||||
this.timeout(20000);
|
||||
|
||||
const storageDir = uniqueStorageDir();
|
||||
|
||||
await mkdirp(storageDir);
|
||||
@@ -553,7 +555,7 @@ suite('SQLite Storage Library', () => {
|
||||
items1.set('debug.actionswidgetposition', '0.6880952380952381');
|
||||
|
||||
const items2 = new Map<string, string>();
|
||||
items2.set('workbench.editors.files.textfileeditor', '{"textEditorViewState":[["file:///Users/dummy/Documents/ticino-playground/play.htm",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":6,"column":16},"position":{"lineNumber":6,"column":16}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":0},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}],["file:///Users/dummy/Documents/ticino-playground/nakefile.js",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":7,"column":81},"position":{"lineNumber":7,"column":81}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":20},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}],["file:///Users/dummy/Desktop/vscode2/.gitattributes",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":9,"column":12},"position":{"lineNumber":9,"column":12}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":20},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}],["file:///Users/dummy/Desktop/vscode2/src/vs/workbench/parts/search/browser/openAnythingHandler.ts",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":1,"column":1},"position":{"lineNumber":1,"column":1}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":0},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}]]}');
|
||||
items2.set('workbench.editors.files.textfileeditor', '{"textEditorViewState":[["file:///Users/dummy/Documents/ticino-playground/play.htm",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":6,"column":16},"position":{"lineNumber":6,"column":16}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":0},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}],["file:///Users/dummy/Documents/ticino-playground/nakefile.js",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":7,"column":81},"position":{"lineNumber":7,"column":81}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":20},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}],["file:///Users/dummy/Desktop/vscode2/.gitattributes",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":9,"column":12},"position":{"lineNumber":9,"column":12}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":20},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}],["file:///Users/dummy/Desktop/vscode2/src/vs/workbench/contrib/search/browser/openAnythingHandler.ts",{"0":{"cursorState":[{"inSelectionMode":false,"selectionStart":{"lineNumber":1,"column":1},"position":{"lineNumber":1,"column":1}}],"viewState":{"scrollLeft":0,"firstPosition":{"lineNumber":1,"column":1},"firstPositionDeltaTop":0},"contributionsState":{"editor.contrib.folding":{},"editor.contrib.wordHighlighter":false}}}]]}');
|
||||
|
||||
const items3 = new Map<string, string>();
|
||||
items3.set('nps/iscandidate', 'false');
|
||||
@@ -628,7 +630,9 @@ suite('SQLite Storage Library', () => {
|
||||
await del(storageDir, tmpdir());
|
||||
});
|
||||
|
||||
test('very large item value', async () => {
|
||||
test('very large item value', async function () {
|
||||
this.timeout(20000);
|
||||
|
||||
const storageDir = uniqueStorageDir();
|
||||
|
||||
await mkdirp(storageDir);
|
||||
|
||||
11
src/vs/base/test/node/testUtils.ts
Normal file
11
src/vs/base/test/node/testUtils.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
|
||||
export function getRandomTestPath(tmpdir: string, ...segments: string[]): string {
|
||||
return join(tmpdir, ...segments, generateUuid());
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { join } from 'path';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { tmpdir } from 'os';
|
||||
import { mkdirp, del } from 'vs/base/node/pfs';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user