Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge [master] branch to [beta] and Enable GitHub Actions on [beta] branch #1762

Merged
merged 4 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Node.js CI

on:
push:
branches: [ master ]
branches: [ master, beta ]
pull_request:
branches: [ master ]
branches: [ master, beta ]

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches: [ master, beta ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [ master, beta ]
schedule:
- cron: '17 15 * * 2'

Expand Down
22 changes: 12 additions & 10 deletions common/Tests/Framework/src/Assert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference path="../../External/qunit.d.ts" />

import { expectedToString, stateToString } from "./DebugHelpers";

/**
* Wrapper around QUnit asserts. This class has two purposes:
* - Make Assertion methods easy to discover.
Expand All @@ -19,7 +21,7 @@ export class Assert {
* @param message A short description of the assertion
*/
public static deepEqual(expected: any, actual: any, message?: string): any {
return QUnit.assert.deepEqual(actual, expected, message);
return QUnit.assert.deepEqual(actual, expected, message || expectedToString(expected));
}

/**
Expand All @@ -35,7 +37,7 @@ export class Assert {
* @param message A short description of the assertion
*/
public static equal(expected: any, actual: any, message?: string): any {
return QUnit.assert.equal(actual, expected, message);
return QUnit.assert.equal(actual, expected, message || expectedToString(expected));
}

/**
Expand All @@ -51,7 +53,7 @@ export class Assert {
* @param message A short description of the assertion
*/
public static notDeepEqual(expected: any, actual: any, message?: string): any {
return QUnit.assert.notDeepEqual(actual, expected, message);
return QUnit.assert.notDeepEqual(actual, expected, message || expectedToString(expected));
}

/**
Expand All @@ -67,15 +69,15 @@ export class Assert {
* @param message A short description of the assertion
*/
public static notEqual(expected: any, actual: any, message?: string): any {
return QUnit.assert.notEqual(actual, expected, message);
return QUnit.assert.notEqual(actual, expected, message || expectedToString(expected));
}

public static notPropEqual(expected: any, actual: any, message?: string): any {
return QUnit.assert.notPropEqual(actual, expected, message);
return QUnit.assert.notPropEqual(actual, expected, message || expectedToString(expected));
}

public static propEqual(expected: any, actual: any, message?: string): any {
return QUnit.assert.propEqual(actual, expected, message);
return QUnit.assert.propEqual(actual, expected, message || expectedToString(expected));
}

/**
Expand All @@ -91,7 +93,7 @@ export class Assert {
* @param message A short description of the assertion
*/
public static notStrictEqual(expected: any, actual: any, message?: string): any {
return QUnit.assert.notStrictEqual(actual, expected, message);
return QUnit.assert.notStrictEqual(actual, expected, message || expectedToString(expected));
}

/**
Expand All @@ -106,7 +108,7 @@ export class Assert {
* @param message A short description of the assertion
*/
public static ok(state: any, message?: string): any {
return QUnit.assert.ok(state, message);
return QUnit.assert.ok(state, message || stateToString(state));
}

/**
Expand All @@ -120,7 +122,7 @@ export class Assert {
* @param message A short description of the assertion
*/
public static strictEqual(expected: any, actual: any, message?: string): any {
return QUnit.assert.strictEqual(actual, expected, message);
return QUnit.assert.strictEqual(actual, expected, message || expectedToString(expected));
}

/**
Expand All @@ -142,6 +144,6 @@ export class Assert {
public static throws(block: () => any, message?: string): any;

public static throws(block: () => any, expected?: any, message?: string): any {
return QUnit.assert.throws(block, expected, message);
return QUnit.assert.throws(block, expected, message || expectedToString(expected));
}
}
37 changes: 37 additions & 0 deletions common/Tests/Framework/src/DebugHelpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@


export function _toString(value: any, isRecursive: boolean = false): string {
if (value === undefined) {
return "<undefined>";
}

if (value === null) {
return "<null>";
}

try {
if (typeof value !== "string") {
const objectTypeDump: string = Object.prototype.toString.call(value);
let propertyValueDump: string = "";
if (objectTypeDump === "[object Error]") {
propertyValueDump = "{ stack: '" + value.stack + "', message: '" + value.message + "', name: '" + value.name + "'";
} else {
propertyValueDump = JSON.stringify(value);
}

return objectTypeDump + propertyValueDump;
}
} catch (e) {
return "!!!Unable to convert to a string!!! - " + (!isRecursive ? _toString(e, true) : "%$#%&*@");
}

return value || "";
}

export function expectedToString(value: any) {
return "Expected: [" + _toString(value) + "]";
}

export function stateToString(value: any) {
return "State: [" + _toString(value) + "]";
}
55 changes: 44 additions & 11 deletions shared/AppInsightsCore/Tests/Perf/src/CorePerfCheck.Tests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Assert, AITestClass } from "@microsoft/ai-test-framework";
import { ITestContext, StepResult } from "@microsoft/ai-test-framework/dist-esm/src/TestCase";
import { _InternalMessageId, LoggingSeverity } from "../../../src/JavaScriptSDK.Enums/LoggingEnums";
import { _InternalLogMessage, DiagnosticLogger } from "../../../src/JavaScriptSDK/DiagnosticLogger";
import { isObject, objForEachKey, objKeys, optimizeObject, setValue } from "../../../src/JavaScriptSDK/HelperFuncs";
import { _InternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums";
import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger";
import { isObject, isPlainObject, isString, objForEachKey, objKeys, optimizeObject, setValue } from "../../../src/JavaScriptSDK/HelperFuncs";

interface PerfMeasurements {
duration: number;
Expand All @@ -27,6 +26,22 @@ export class CorePerfCheckTests extends AITestClass {

public registerTests() {

this.testCase({
name: "PerfChecks: isString",
test: () => {
let testObject = "Value";
let iterations = 500000;
let checks = 0;
let duration = this._runPerfTest("isString", () => {
if (isString(testObject)) {
checks++;
}
}, 10, iterations, 0.00001);

Assert.equal(iterations * duration.attempts, checks, "Make sure we hit all of them");
}
});

this.testCase({
name: "PerfChecks: isObject",
test: () => {
Expand All @@ -45,6 +60,24 @@ export class CorePerfCheckTests extends AITestClass {
}
});

this.testCase({
name: "PerfChecks: isPlainObject",
test: () => {
let testObject = {
test: "Value"
};
let iterations = 100000;
let checks = 0;
let duration = this._runPerfTest("isPlainObject", () => {
if (isPlainObject(testObject)) {
checks++;
}
}, 50, iterations, 0.00001);

Assert.equal(iterations * duration.attempts, checks, "Make sure we hit all of them");
}
});

/**
* This test always currently fails on chromium based browsers due to the way that chromium provides super
* fast internal private classes for fixed objects and using the optimizeObject() creates a non-optimized
Expand Down Expand Up @@ -143,7 +176,7 @@ export class CorePerfCheckTests extends AITestClass {
name: "PerfChecks: objForEachKey dynamic large (40 fields) object",
timeout: 60000,
test: () => {
let iterations = 100000;
let iterations = 90000;
let baseTestObject = { };
for (let lp = 0; lp < 40; lp++) {
baseTestObject["test.value" + lp] = "Test Value " + lp;
Expand Down Expand Up @@ -182,7 +215,7 @@ export class CorePerfCheckTests extends AITestClass {
name: "PerfChecks: objForEachKey complete small (<20 fields) dynamic object",
timeout: 60000,
test: () => {
let iterations = 100000;
let iterations = 90000;
let baseTestObject = { } as any;
let objectFields = 19; // There is a JIT optimization for objects with <= 19 fields
for (let lp = 0; lp < objectFields; lp++) {
Expand Down Expand Up @@ -222,7 +255,7 @@ export class CorePerfCheckTests extends AITestClass {
name: "PerfChecks: objForEachKey complete large (>= 20 fields) dynamic object",
timeout: 60000,
test: () => {
let iterations = 100000;
let iterations = 90000;
let baseTestObject = { } as any;
let objectFields = 21; // There is a JIT optimization for objects with <= 19 fields
for (let lp = 0; lp < objectFields; lp++) {
Expand Down Expand Up @@ -262,7 +295,7 @@ export class CorePerfCheckTests extends AITestClass {
name: "PerfChecks: objForEachKey with small (<20 fields) extended dynamic object",
timeout: 60000,
test: () => {
let iterations = 100000;
let iterations = 90000;
let baseTestObject = {
a: 1
} as any;
Expand Down Expand Up @@ -304,7 +337,7 @@ export class CorePerfCheckTests extends AITestClass {
name: "PerfChecks: objForEachKey with large (>=20 fields) extended dynamic object",
timeout: 60000,
test: () => {
let iterations = 100000;
let iterations = 90000;
let baseTestObject = {
a: 1
} as any;
Expand Down Expand Up @@ -459,7 +492,7 @@ export class CorePerfCheckTests extends AITestClass {
let checks = 0;
return this._runPerfTestAsync("baseTestObject", () => {
JSON.stringify(baseTestObject);
}, 50, iterations, 0.005).then((baseDuration) => {
}, 60, iterations, 0.005).then((baseDuration) => {
checks = 0;
return this._runPerfTestAsync("optTestObject", () => {
JSON.stringify(optTestObject);
Expand Down Expand Up @@ -494,7 +527,7 @@ export class CorePerfCheckTests extends AITestClass {

return this._runPerfTestAsync("baseTestObject", () => {
JSON.stringify(baseTestObject);
}, 50, iterations, 0.005).then((baseDuration) => {
}, 60, iterations, 0.005).then((baseDuration) => {
return this._runPerfTestAsync("optTestObject", () => {
JSON.stringify(optTestObject);
}, 50, iterations, 0.003, baseDuration).then((optDuration) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Assert, AITestClass } from "@microsoft/ai-test-framework";
import { IConfiguration, ITelemetryPlugin, ITelemetryItem, IPlugin, CoreUtils, IAppInsightsCore, normalizeJsName, random32, mwcRandom32, mwcRandomSeed } from "../../../src/applicationinsights-core-js"
import { IConfiguration, ITelemetryPlugin, ITelemetryItem, IPlugin, CoreUtils, IAppInsightsCore, normalizeJsName, random32, mwcRandomSeed } from "../../../src/applicationinsights-core-js"
import { AppInsightsCore } from "../../../src/JavaScriptSDK/AppInsightsCore";
import { IChannelControls } from "../../../src/JavaScriptSDK.Interfaces/IChannelControls";
import { _InternalMessageId, LoggingSeverity } from "../../../src/JavaScriptSDK.Enums/LoggingEnums";
Expand Down
Loading