Skip to content

Commit

Permalink
Merge pull request #125749 from microsoft/hediet/update-sinon
Browse files Browse the repository at this point in the history
Updates sinon from 1.17 to 11.1.
  • Loading branch information
hediet authored Jun 9, 2021
2 parents 6bf4b4f + 00123b3 commit 83d889c
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 76 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/common/**",
"**/vs/base/test/common/**"
Expand Down Expand Up @@ -139,6 +140,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/{common,browser}/**",
"**/vs/base/test/{common,browser}/**"
Expand Down Expand Up @@ -212,6 +214,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/common/**",
"**/vs/base/parts/*/common/**",
Expand All @@ -225,6 +228,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/{common,browser}/**",
"**/vs/base/parts/*/{common,browser}/**",
Expand Down Expand Up @@ -289,6 +293,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/{common,browser}/**",
"**/vs/base/parts/*/{common,browser}/**",
Expand All @@ -311,6 +316,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/common/**",
"**/vs/platform/*/common/**",
Expand All @@ -334,6 +340,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/{common,browser}/**",
"**/vs/platform/*/{common,browser}/**",
Expand All @@ -357,6 +364,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/common/**",
"**/vs/platform/*/common/**",
Expand All @@ -383,6 +391,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/{common,browser}/**",
"**/vs/platform/*/{common,browser}/**",
Expand All @@ -397,6 +406,7 @@
"restrictions": [
"assert",
"sinon",
"sinon-test",
"vs/nls",
"**/vs/base/{common,browser}/**",
"**/vs/base/test/{common,browser}/**",
Expand Down Expand Up @@ -921,6 +931,7 @@
"**/vs/**",
"assert",
"sinon",
"sinon-test",
"crypto",
"vscode"
]
Expand Down Expand Up @@ -952,6 +963,7 @@
"**/vs/**",
"assert",
"sinon",
"sinon-test",
"crypto",
"xterm*"
]
Expand All @@ -962,6 +974,7 @@
"**/vs/**",
"assert",
"sinon",
"sinon-test",
"crypto",
"xterm*"
]
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"@types/minimist": "^1.2.1",
"@types/mocha": "^8.2.0",
"@types/node": "14.x",
"@types/sinon": "^1.16.36",
"@types/sinon": "^10.0.2",
"@types/sinon-test": "^2.4.2",
"@types/trusted-types": "^1.0.6",
"@types/vscode-windows-registry": "^1.0.0",
"@types/webpack": "^4.41.25",
Expand Down Expand Up @@ -183,7 +184,8 @@
"rcedit": "^1.1.0",
"request": "^2.85.0",
"rimraf": "^2.2.8",
"sinon": "^1.17.2",
"sinon": "^11.1.1",
"sinon-test": "^3.1.0",
"source-map": "0.6.1",
"source-map-support": "^0.3.2",
"style-loader": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/test/common/decorators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ suite('Decorators', () => {

clock.tick(200);
assert.deepStrictEqual(spy.args, [[1], [5]]);
spy.reset();
spy.resetHistory();

t.report(4);
t.report(5);
Expand Down
47 changes: 25 additions & 22 deletions src/vs/platform/telemetry/test/browser/telemetryService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry';
import { NullAppender, ITelemetryAppender } from 'vs/platform/telemetry/common/telemetryUtils';
import * as Errors from 'vs/base/common/errors';
import * as sinon from 'sinon';
import * as sinonTest from 'sinon-test';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

const sinonTestFn = sinonTest(sinon);

class TestTelemetryAppender implements ITelemetryAppender {

public events: any[];
Expand Down Expand Up @@ -85,7 +88,7 @@ class ErrorTestingSettings {

suite('TelemetryService', () => {

test('Disposing', sinon.test(function () {
test('Disposing', sinonTestFn(function () {
let testAppender = new TestTelemetryAppender();
let service = new TelemetryService({ appender: testAppender }, undefined!);

Expand All @@ -98,7 +101,7 @@ suite('TelemetryService', () => {
}));

// event reporting
test('Simple event', sinon.test(function () {
test('Simple event', sinonTestFn(function () {
let testAppender = new TestTelemetryAppender();
let service = new TelemetryService({ appender: testAppender }, undefined!);

Expand All @@ -111,7 +114,7 @@ suite('TelemetryService', () => {
});
}));

test('Event with data', sinon.test(function () {
test('Event with data', sinonTestFn(function () {
let testAppender = new TestTelemetryAppender();
let service = new TelemetryService({ appender: testAppender }, undefined!);

Expand Down Expand Up @@ -193,7 +196,7 @@ suite('TelemetryService', () => {
});
});

test('enableTelemetry on by default', sinon.test(function () {
test('enableTelemetry on by default', sinonTestFn(function () {
let testAppender = new TestTelemetryAppender();
let service = new TelemetryService({ appender: testAppender }, undefined!);

Expand Down Expand Up @@ -224,7 +227,7 @@ suite('TelemetryService', () => {
}
}

test('Error events', sinon.test(async function (this: any) {
test('Error events', sinonTestFn(async function (this: any) {

let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
Expand Down Expand Up @@ -256,7 +259,7 @@ suite('TelemetryService', () => {
}
}));

// test('Unhandled Promise Error events', sinon.test(function() {
// test('Unhandled Promise Error events', sinonTestFn(function() {
//
// let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
// Errors.setUnexpectedErrorHandler(() => {});
Expand Down Expand Up @@ -285,7 +288,7 @@ suite('TelemetryService', () => {
// }
// }));

test('Handle global errors', sinon.test(async function (this: any) {
test('Handle global errors', sinonTestFn(async function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;

Expand Down Expand Up @@ -313,7 +316,7 @@ suite('TelemetryService', () => {
service.dispose();
}));

test('Error Telemetry removes PII from filename with spaces', sinon.test(async function (this: any) {
test('Error Telemetry removes PII from filename with spaces', sinonTestFn(async function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
Expand All @@ -336,7 +339,7 @@ suite('TelemetryService', () => {
service.dispose();
}));

test('Uncaught Error Telemetry removes PII from filename', sinon.test(function (this: any) {
test('Uncaught Error Telemetry removes PII from filename', sinonTestFn(function (this: any) {
let clock = this.clock;
let errorStub = sinon.stub();
window.onerror = errorStub;
Expand Down Expand Up @@ -368,7 +371,7 @@ suite('TelemetryService', () => {
});
}));

test('Unexpected Error Telemetry removes PII', sinon.test(async function (this: any) {
test('Unexpected Error Telemetry removes PII', sinonTestFn(async function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
try {
Expand Down Expand Up @@ -399,7 +402,7 @@ suite('TelemetryService', () => {
}
}));

test('Uncaught Error Telemetry removes PII', sinon.test(async function (this: any) {
test('Uncaught Error Telemetry removes PII', sinonTestFn(async function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
Expand All @@ -426,7 +429,7 @@ suite('TelemetryService', () => {
service.dispose();
}));

test('Unexpected Error Telemetry removes PII but preserves Code file path', sinon.test(async function (this: any) {
test('Unexpected Error Telemetry removes PII but preserves Code file path', sinonTestFn(async function (this: any) {

let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
Expand Down Expand Up @@ -462,7 +465,7 @@ suite('TelemetryService', () => {
}
}));

test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(async function (this: any) {
test('Uncaught Error Telemetry removes PII but preserves Code file path', sinonTestFn(async function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
Expand Down Expand Up @@ -491,7 +494,7 @@ suite('TelemetryService', () => {
service.dispose();
}));

test('Unexpected Error Telemetry removes PII but preserves Code file path with node modules', sinon.test(async function (this: any) {
test('Unexpected Error Telemetry removes PII but preserves Code file path with node modules', sinonTestFn(async function (this: any) {

let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
Expand Down Expand Up @@ -523,7 +526,7 @@ suite('TelemetryService', () => {
}
}));

test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(async function (this: any) {
test('Uncaught Error Telemetry removes PII but preserves Code file path', sinonTestFn(async function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
Expand All @@ -549,7 +552,7 @@ suite('TelemetryService', () => {
}));


test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(async function (this: any) {
test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinonTestFn(async function (this: any) {

let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
Expand Down Expand Up @@ -585,7 +588,7 @@ suite('TelemetryService', () => {
}
}));

test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(async function (this: any) {
test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinonTestFn(async function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
Expand Down Expand Up @@ -614,7 +617,7 @@ suite('TelemetryService', () => {
service.dispose();
}));

test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinon.test(async function (this: any) {
test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinonTestFn(async function (this: any) {

let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
Expand Down Expand Up @@ -650,7 +653,7 @@ suite('TelemetryService', () => {
}
}));

test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinon.test(async function (this: any) {
test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinonTestFn(async function (this: any) {
let errorStub = sinon.stub();
window.onerror = errorStub;
let settings = new ErrorTestingSettings();
Expand Down Expand Up @@ -680,7 +683,7 @@ suite('TelemetryService', () => {
service.dispose();
}));

test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinon.test(async function (this: any) {
test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinonTestFn(async function (this: any) {

let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });
Expand Down Expand Up @@ -716,7 +719,7 @@ suite('TelemetryService', () => {
}
}));

test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinon.test(async function (this: any) {
test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinonTestFn(async function (this: any) {
let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler();
Errors.setUnexpectedErrorHandler(() => { });

Expand Down Expand Up @@ -754,7 +757,7 @@ suite('TelemetryService', () => {
}
}));

test('Telemetry Service sends events when enableTelemetry is on', sinon.test(function () {
test('Telemetry Service sends events when enableTelemetry is on', sinonTestFn(function () {
let testAppender = new TestTelemetryAppender();
let service = new TelemetryService({ appender: testAppender }, undefined!);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ suite('SearchModel', () => {
}

function stub(arg1: any, arg2: any, arg3: any): sinon.SinonStub {
const stub = sinon.stub(arg1, arg2, arg3);
const stub = sinon.stub(arg1, arg2).callsFake(arg3);
restoreStubs.push(stub);
return stub;
}
Expand Down
Loading

0 comments on commit 83d889c

Please sign in to comment.