From cedb55252d8d3f71af41ca31dc0ad3e67620467d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 6 Mar 2023 18:28:55 -0800 Subject: [PATCH 1/6] Remove test262 infra --- src/harness/harnessIO.ts | 7 +- src/harness/runnerbase.ts | 2 +- src/testRunner/_namespaces/Harness.ts | 1 - src/testRunner/compilerRunner.ts | 4 - src/testRunner/runner.ts | 6 - src/testRunner/test262Runner.ts | 120 -------- tests/cases/test262-harness/helpers.d.ts | 367 ----------------------- 7 files changed, 2 insertions(+), 505 deletions(-) delete mode 100644 src/testRunner/test262Runner.ts delete mode 100644 tests/cases/test262-harness/helpers.d.ts diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index da4d11dab3646..50354f3f66bdb 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -719,13 +719,8 @@ export namespace Compiler { return !!diagnostic.file && (vpath.isTsConfigFile(diagnostic.file.fileName)); }); - const numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { - // Count an error generated from tests262-harness folder.This should only apply for test262 - return !!diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0; - }); - // Verify we didn't miss any errors in total - assert.equal(totalErrorsReportedInNonLibraryNonTsconfigFiles + numLibraryDiagnostics + numTsconfigDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); + assert.equal(totalErrorsReportedInNonLibraryNonTsconfigFiles + numLibraryDiagnostics + numTsconfigDiagnostics, diagnostics.length, "total number of errors"); } export function doErrorBaseline(baselinePath: string, inputFiles: readonly TestFile[], errors: readonly ts.Diagnostic[], pretty?: boolean) { diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index dbbdf662a9464..60f61262e92c8 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -5,7 +5,7 @@ import { } from "./_namespaces/Harness"; import * as ts from "./_namespaces/ts"; -export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "dt"; +export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "dt"; export type CompilerTestKind = "conformance" | "compiler"; export type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server"; diff --git a/src/testRunner/_namespaces/Harness.ts b/src/testRunner/_namespaces/Harness.ts index a9e4e0904b3fb..2df05e12e2123 100644 --- a/src/testRunner/_namespaces/Harness.ts +++ b/src/testRunner/_namespaces/Harness.ts @@ -9,7 +9,6 @@ export { Parallel }; export * from "../fourslashRunner"; export * from "../compilerRunner"; export * from "../externalCompileRunner"; -export * from "../test262Runner"; export * from "../runner"; // If running as emitted CJS, don't start executing the tests here; instead start in runner.ts. diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index bcabc2f03a53b..7e6f5bdf73406 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -18,7 +18,6 @@ import * as vpath from "./_namespaces/vpath"; export const enum CompilerTestType { Conformance, Regressions, - Test262 } interface CompilerFileBasedTest extends FileBasedTest { @@ -41,9 +40,6 @@ export class CompilerBaselineRunner extends RunnerBase { else if (testType === CompilerTestType.Regressions) { this.testSuiteName = "compiler"; } - else if (testType === CompilerTestType.Test262) { - this.testSuiteName = "test262"; - } else { this.testSuiteName = "compiler"; // default to this for historical reasons } diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index 566c130f059a1..c2b8fe236325c 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -11,7 +11,6 @@ import { setLightMode, setShardId, setShards, - Test262BaselineRunner, TestRunnerKind, } from "./_namespaces/Harness"; import * as project from "./_namespaces/project"; @@ -76,8 +75,6 @@ export function createRunner(kind: TestRunnerKind): RunnerBase { return new project.ProjectRunner(); case "rwc": return new RWC.RWCRunner(); - case "test262": - return new Test262BaselineRunner(); case "dt": return new DefinitelyTypedRunner(); } @@ -214,9 +211,6 @@ function handleTestConfig() { case "rwc": runners.push(new RWC.RWCRunner()); break; - case "test262": - runners.push(new Test262BaselineRunner()); - break; case "dt": runners.push(new DefinitelyTypedRunner()); break; diff --git a/src/testRunner/test262Runner.ts b/src/testRunner/test262Runner.ts deleted file mode 100644 index f1323d0781024..0000000000000 --- a/src/testRunner/test262Runner.ts +++ /dev/null @@ -1,120 +0,0 @@ -import * as compiler from "./_namespaces/compiler"; -import { - Baseline, - Compiler, - IO, - RunnerBase, - TestCaseParser, - TestRunnerKind, -} from "./_namespaces/Harness"; -import * as ts from "./_namespaces/ts"; -import * as Utils from "./_namespaces/Utils"; - -// In harness baselines, null is different than undefined. See `generateActual` in `harness.ts`. -export class Test262BaselineRunner extends RunnerBase { - private static readonly basePath = "internal/cases/test262"; - private static readonly helpersFilePath = "tests/cases/test262-harness/helpers.d.ts"; - private static readonly helperFile: Compiler.TestFile = { - unitName: Test262BaselineRunner.helpersFilePath, - content: IO.readFile(Test262BaselineRunner.helpersFilePath)!, - }; - private static readonly testFileExtensionRegex = /\.js$/; - private static readonly options: ts.CompilerOptions = { - allowNonTsExtensions: true, - target: ts.ScriptTarget.Latest, - module: ts.ModuleKind.CommonJS - }; - private static readonly baselineOptions: Baseline.BaselineOptions = { - Subfolder: "test262", - Baselinefolder: "internal/baselines" - }; - - private static getTestFilePath(filename: string): string { - return Test262BaselineRunner.basePath + "/" + filename; - } - - private runTest(filePath: string) { - describe("test262 test for " + filePath, () => { - // Mocha holds onto the closure environment of the describe callback even after the test is done. - // Everything declared here should be cleared out in the "after" callback. - let testState: { - filename: string; - compilerResult: compiler.CompilationResult; - inputFiles: Compiler.TestFile[]; - }; - - before(() => { - const content = IO.readFile(filePath)!; - const testFilename = ts.removeFileExtension(filePath).replace(/\//g, "_") + ".test"; - const testCaseContent = TestCaseParser.makeUnitsFromTest(content, testFilename); - - const inputFiles: Compiler.TestFile[] = testCaseContent.testUnitData.map(unit => { - const unitName = Test262BaselineRunner.getTestFilePath(unit.name); - return { unitName, content: unit.content }; - }); - - // Emit the results - testState = { - filename: testFilename, - inputFiles, - compilerResult: undefined!, // TODO: GH#18217 - }; - - testState.compilerResult = Compiler.compileFiles( - [Test262BaselineRunner.helperFile].concat(inputFiles), - /*otherFiles*/ [], - /* harnessOptions */ undefined, - Test262BaselineRunner.options, - /* currentDirectory */ undefined); - }); - - after(() => { - testState = undefined!; - }); - - it("has the expected emitted code", () => { - const files = ts.arrayFrom(testState.compilerResult.js.values()).filter(f => f.file !== Test262BaselineRunner.helpersFilePath); - Baseline.runBaseline(testState.filename + ".output.js", Compiler.collateOutputs(files), Test262BaselineRunner.baselineOptions); - }); - - it("has the expected errors", () => { - const errors = testState.compilerResult.diagnostics; - // eslint-disable-next-line no-null/no-null - const baseline = errors.length === 0 ? null : Compiler.getErrorBaseline(testState.inputFiles, errors); - Baseline.runBaseline(testState.filename + ".errors.txt", baseline, Test262BaselineRunner.baselineOptions); - }); - - it("satisfies invariants", () => { - const sourceFile = testState.compilerResult.program!.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); - Utils.assertInvariants(sourceFile, /*parent:*/ undefined); - }); - - it("has the expected AST", () => { - const sourceFile = testState.compilerResult.program!.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename))!; - Baseline.runBaseline(testState.filename + ".AST.txt", Utils.sourceFileToJSON(sourceFile), Test262BaselineRunner.baselineOptions); - }); - }); - } - - public kind(): TestRunnerKind { - return "test262"; - } - - public enumerateTestFiles() { - // see also: `enumerateTestFiles` in tests/webTestServer.ts - return ts.map(this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true }), ts.normalizePath); - } - - public initializeTests() { - // this will set up a series of describe/it blocks to run between the setup and cleanup phases - if (this.tests.length === 0) { - const testFiles = this.getTestFiles(); - testFiles.forEach(fn => { - this.runTest(fn); - }); - } - else { - this.tests.forEach(test => this.runTest(typeof test === "string" ? test : test.file)); - } - } -} diff --git a/tests/cases/test262-harness/helpers.d.ts b/tests/cases/test262-harness/helpers.d.ts deleted file mode 100644 index 3e281f41b011c..0000000000000 --- a/tests/cases/test262-harness/helpers.d.ts +++ /dev/null @@ -1,367 +0,0 @@ -declare function $FAIL(message: any): void; -declare function $PRINT(message: any): void; -declare function accessorPropertyAttributesAreCorrect(obj: any, name: any, get: any, set: any, setVerifyHelpProp: any, enumerable: any, configurable: any): boolean; -declare function arrayContains(arr: any, expected: any): boolean; -declare function compareArray(aExpected: any, aActual: any): boolean; -declare function testRun(id: any, path: any, description: any, codeString: any, result: any, error: any): void; -declare var print: any; -declare function dataPropertyAttributesAreCorrect(obj: any, name: any, value: any, writable: any, enumerable: any, configurable: any): boolean; -declare var HoursPerDay: number; -declare var MinutesPerHour: number; -declare var SecondsPerMinute: number; -declare var msPerDay: number; -declare var msPerSecond: number; -declare var msPerMinute: number; -declare var msPerHour: number; -declare var date_1899_end: number; -declare var date_1900_start: number; -declare var date_1969_end: number; -declare var date_1970_start: number; -declare var date_1999_end: number; -declare var date_2000_start: number; -declare var date_2099_end: number; -declare var date_2100_start: number; -declare var $LocalTZ: any, $DST_start_month: any, $DST_start_sunday: any, $DST_start_hour: any, $DST_start_minutes: any, $DST_end_month: any, $DST_end_sunday: any, $DST_end_hour: any, $DST_end_minutes: any; -declare function Day(t: any): number; -declare function TimeWithinDay(t: any): number; -declare function DaysInYear(y: any): number; -declare function DayFromYear(y: any): number; -declare function TimeFromYear(y: any): number; -declare function YearFromTime(t: any): number; -declare function InLeapYear(t: any): number; -declare function DayWithinYear(t: any): number; -declare function MonthFromTime(t: any): number; -declare function DateFromTime(t: any): number; -declare function WeekDay(t: any): number; -declare var LocalTZA: number; -declare function DaysInMonth(m: any, leap: any): any; -declare function GetSundayInMonth(t: any, m: any, count: any): any; -declare function DaylightSavingTA(t: any): number; -declare function LocalTime(t: any): any; -declare function UTC(t: any): number; -declare function HourFromTime(t: any): number; -declare function MinFromTime(t: any): number; -declare function SecFromTime(t: any): number; -declare function msFromTime(t: any): number; -declare function MakeTime(hour: any, min: any, sec: any, ms: any): any; -declare function MakeDay(year: any, month: any, date: any): number; -declare function MakeDate(day: any, time: any): any; -declare function TimeClip(time: any): any; -declare function ConstructDate(year: any, month: any, date: any, hours: any, minutes: any, seconds: any, ms: any): any; -declare function __consolePrintHandle__(msg: any): void; -declare function fnExists(): boolean; -declare var __globalObject: any; -declare function fnGlobalObject(): any; -declare function testPrint(message: any): void; -/** - * It is not yet clear that runTestCase should pass the global object - * as the 'this' binding in the call to testcase. - */ -declare var runTestCase: (testcase: any) => void; -declare function assertTruthy(value: any): void; -/** - * falsy means we expect no error. - * truthy means we expect some error. - * A non-empty string means we expect an error whose .name is that string. - */ -declare var expectedErrorName: boolean; -/** - * What was thrown, or the string 'Falsy' if something falsy was thrown. - * null if test completed normally. - */ -declare var actualError: any; -declare function testStarted(expectedErrName: any): void; -declare function testFinished(): void; -declare function Presenter(): void; -declare var presenter: any; -declare var prec: any; -declare function isEqual(num1: any, num2: any): boolean; -declare function getPrecision(num: any): number; -declare function ToInteger(p: any): any; -declare function checkSequence(arr: Promise, message: string): void; -declare var objectStore: { - object: Object; -}; -declare var functionStore: { - fun: () => string; -}; -declare function createEmulatedProxy(target: T, emulatedProps: any, success?: any): T; -declare function Section(parentSection: any, id: any, name: any): void; -declare var NotEarlyErrorString: string; -declare var EarlyErrorRePat: string; -declare var NotEarlyError: Error; -declare var $ERROR: any; -declare function BrowserRunner(): void; -declare function TestLoader(): void; -declare function Controller(): void; -declare var controller: any; -declare function isSiteDebugMode(): boolean; -/** - * @description Helper handler method for tagged string templates - */ -declare function testHandler(literals: any): string; -/** - * @description Tests that obj meets the requirements for built-in objects - * defined by the introduction of chapter 15 of the ECMAScript Language Specification. - * @param {Object} obj the object to be tested. - * @param {boolean} isFunction whether the specification describes obj as a function. - * @param {boolean} isConstructor whether the specification describes obj as a constructor. - * @param {String[]} properties an array with the names of the built-in properties of obj, - * excluding length, prototype, or properties with non-default attributes. - * @param {number} length for functions only: the length specified for the function - * or derived from the argument list. - * @author Norbert Lindenberg - */ -declare function testBuiltInObject(obj: any, isFunction: any, isConstructor: any, properties: any, length: any): boolean; -/** - * @description This is a helper file for testing detached typed arrays - * @author Andrei Borodin (anborod) - */ -declare var lib: { - init: () => void; - dispose: () => void; - detachItem: (item: any) => any; - createDetachCallback: (arr: any, detachAfterNumIterations: any, valueToReturn: any) => (item: any) => any; - createDetachValueOfObject: (arr: any, detachAfterNumIterations: any, value: any) => { - valueOf: () => any; - }; - createDetachToStringObject: (arr: any, detachAfterNumIterations: any, value: any) => { - toString: () => string; - }; - runTestCaseWrapper: (func: any) => void; - expectTypeError: (func: any, reason: any) => void; - expectRangeError: (func: any, reason: any) => void; - expectError: (errorType: any, name: any, func: any, reason: any) => void; - isDetached: (obj: any) => boolean; -}; -declare function testIntlOptions(givenOptions: any, expectedOptions: any): void; -/** - * This file contains shared functions for the tests in the conformance test - * suite for the ECMAScript Internationalization API. - * @author Norbert Lindenberg - */ -/** - * @description Calls the provided function for every service constructor in - * the Intl object, until f returns a falsy value. It returns the result of the - * last call to f, mapped to a boolean. - * @param {Function} f the function to call for each service constructor in - * the Intl object. - * @param {Function} Constructor the constructor object to test with. - * @result {Boolean} whether the test succeeded. - */ -declare function testWithIntlConstructors(f: any): boolean; -/** - * Returns the name of the given constructor object, which must be one of - * Intl.Collator, Intl.NumberFormat, or Intl.DateTimeFormat. - * @param {object} Constructor a constructor - * @return {string} the name of the constructor - */ -declare function getConstructorName(Constructor: any): string; -/** - * Taints a named data property of the given object by installing - * a setter that throws an exception. - * @param {object} obj the object whose data property to taint - * @param {string} property the property to taint - */ -declare function taintDataProperty(obj: any, property: any): void; -/** - * Taints a named method of the given object by replacing it with a function - * that throws an exception. - * @param {object} obj the object whose method to taint - * @param {string} property the name of the method to taint - */ -declare function taintMethod(obj: any, property: any): void; -/** - * Taints the given properties (and similarly named properties) by installing - * setters on Object.prototype that throw exceptions. - * @param {Array} properties an array of property names to taint - */ -declare function taintProperties(properties: any): void; -/** - * Taints the Array object by creating a setter for the property "0" and - * replacing some key methods with functions that throw exceptions. - */ -declare function taintArray(): void; -declare var languages: string[]; -declare var scripts: string[]; -declare var countries: string[]; -declare var localeSupportInfo: {}; -/** - * Gets locale support info for the given constructor object, which must be one - * of Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat. - * @param {object} Constructor the constructor for which to get locale support info - * @return {object} locale support info with the following properties: - * supported: array of fully supported language tags - * byFallback: array of language tags that are supported through fallbacks - * unsupported: array of unsupported language tags - */ -declare function getLocaleSupportInfo(Constructor: any): any; -/** - * @description Tests whether locale is a String value representing a - * structurally valid and canonicalized BCP 47 language tag, as defined in - * sections 6.2.2 and 6.2.3 of the ECMAScript Internationalization API - * Specification. - * @param {String} locale the string to be tested. - * @result {Boolean} whether the test succeeded. - */ -declare function isCanonicalizedStructurallyValidLanguageTag(locale: any): boolean; -/** - * Tests whether the named options property is correctly handled by the given constructor. - * @param {object} Constructor the constructor to test. - * @param {string} property the name of the options property to test. - * @param {string} type the type that values of the property are expected to have - * @param {Array} [values] an array of allowed values for the property. Not needed for boolean. - * @param {any} fallback the fallback value that the property assumes if not provided. - * @param {object} testOptions additional options: - * @param {boolean} isOptional whether support for this property is optional for implementations. - * @param {boolean} noReturn whether the resulting value of the property is not returned. - * @param {boolean} isILD whether the resulting value of the property is implementation and locale dependent. - * @param {object} extra additional option to pass along, properties are value -> {option: value}. - * @return {boolean} whether the test succeeded. - */ -declare function testOption(Constructor: any, property: any, type: any, values: any, fallback: any, testOptions: any): boolean; -/** - * Tests whether the named property of the given object has a valid value - * and the default attributes of the properties of an object literal. - * @param {Object} obj the object to be tested. - * @param {string} property the name of the property - * @param {Function|Array} valid either a function that tests value for validity and returns a boolean, - * an array of valid values. - * @exception if the property has an invalid value. - */ -declare function testProperty(obj: any, property: any, valid: any): void; -/** - * Tests whether the named property of the given object, if present at all, has a valid value - * and the default attributes of the properties of an object literal. - * @param {Object} obj the object to be tested. - * @param {string} property the name of the property - * @param {Function|Array} valid either a function that tests value for validity and returns a boolean, - * an array of valid values. - * @exception if the property is present and has an invalid value. - */ -declare function mayHaveProperty(obj: any, property: any, valid: any): void; -/** - * Tests whether the given object has the named property with a valid value - * and the default attributes of the properties of an object literal. - * @param {Object} obj the object to be tested. - * @param {string} property the name of the property - * @param {Function|Array} valid either a function that tests value for validity and returns a boolean, - * an array of valid values. - * @exception if the property is missing or has an invalid value. - */ -declare function mustHaveProperty(obj: any, property: any, valid: any): void; -/** - * Tests whether the given object does not have the named property. - * @param {Object} obj the object to be tested. - * @param {string} property the name of the property - * @exception if the property is present. - */ -declare function mustNotHaveProperty(obj: any, property: any): void; -/** - * Properties of the RegExp constructor that may be affected by use of regular - * expressions, and the default values of these properties. Properties are from - * https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties - */ -declare var regExpProperties: string[]; -declare var regExpPropertiesDefaultValues: any; -/** - * Tests that executing the provided function (which may use regular expressions - * in its implementation) does not create or modify unwanted properties on the - * RegExp constructor. - */ -declare function testForUnwantedRegExpChanges(testFunc: any): void; -/** - * Tests whether name is a valid BCP 47 numbering system name - * and not excluded from use in the ECMAScript Internationalization API. - * @param {string} name the name to be tested. - * @return {boolean} whether name is a valid BCP 47 numbering system name and - * allowed for use in the ECMAScript Internationalization API. - */ -declare function isValidNumberingSystem(name: any): boolean; -/** - * Provides the digits of numbering systems with simple digit mappings, - * as specified in 11.3.2. - */ -declare var numberingSystemDigits: { - arab: string; - arabext: string; - beng: string; - deva: string; - fullwide: string; - gujr: string; - guru: string; - hanidec: string; - khmr: string; - knda: string; - laoo: string; - latn: string; - mlym: string; - mong: string; - mymr: string; - orya: string; - tamldec: string; - telu: string; - thai: string; - tibt: string; -}; -/** - * Tests that number formatting is handled correctly. The function checks that the - * digit sequences in formatted output are as specified, converted to the - * selected numbering system, and embedded in consistent localized patterns. - * @param {Array} locales the locales to be tested. - * @param {Array} numberingSystems the numbering systems to be tested. - * @param {Object} options the options to pass to Intl.NumberFormat. Options - * must include {useGrouping: false}, and must cause 1.1 to be formatted - * pre- and post-decimal digits. - * @param {Object} testData maps input data (in ES5 9.3.1 format) to expected output strings - * in unlocalized format with Western digits. - */ -declare function testNumberFormat(locales: any, numberingSystems: any, options: any, testData: any): void; -/** - * Return the components of date-time formats. - * @return {Array} an array with all date-time components. - */ -declare function getDateTimeComponents(): string[]; -/** - * Return the valid values for the given date-time component, as specified - * by the table in section 12.1.1. - * @param {string} component a date-time component. - * @return {Array} an array with the valid values for the component. - */ -declare function getDateTimeComponentValues(component: any): any; -/** - * Tests that the given value is valid for the given date-time component. - * @param {string} component a date-time component. - * @param {string} value the value to be tested. - * @return {boolean} true if the test succeeds. - * @exception if the test fails. - */ -declare function testValidDateTimeComponentValue(component: any, value: any): boolean; -/** - * Verifies that the actual array matches the expected one in length, elements, - * and element order. - * @param {Array} expected the expected array. - * @param {Array} actual the actual array. - * @return {boolean} true if the test succeeds. - * @exception if the test fails. - */ -declare function testArraysAreSame(expected: any, actual: any): boolean; -/** - * @description Helper methods for TypedArrays - */ -declare function CreateTypedArrayTypes(): [typeof Int8Array, typeof Uint8Array, typeof Int16Array, typeof Uint16Array, typeof Int32Array, typeof Uint32Array, typeof Float32Array, typeof Float64Array, typeof Uint8ClampedArray]; -declare function CreateTypedArrayInstances(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; -declare function CreateIntegerTypedArrayTypes(): [typeof Int8Array, typeof Uint8Array, typeof Int16Array, typeof Uint16Array, typeof Int32Array, typeof Uint32Array, typeof Uint8ClampedArray]; -declare function CreateIntegerTypedArrays(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Uint8ClampedArray]; -declare function CreateTypedRedcuedSetOfArrayTypes(): [typeof Float64Array]; -declare function CreateTypedRedcuedSetOfArrays(obj: any): [Float64Array]; -declare function CreateTypedArraysFrom(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; -declare function CreateTypedArraysOf(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; -declare function CreateTypedArraysFromMapFn(obj: any, mapFn: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; -declare function CreateTypedArraysFromThisObj(obj: any, mapFn: any, thisArg: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; -declare function CreatestringsOf(obj: any): string[]; -declare function CreateSignedTypedArrayInstances(obj: any): [Int8Array, Int16Array, Int32Array, Float32Array, Float64Array]; -declare function CreateUnSignedTypedArrayInstances(obj: any): [Uint8Array, Uint16Array, Uint32Array, Uint8ClampedArray]; -declare var $LOG: any; -declare var WScript: any; -declare var $DONE: any; \ No newline at end of file From efb702884b0ba78473af1978daa07d9537570a8f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 6 Mar 2023 18:30:54 -0800 Subject: [PATCH 2/6] Remove dt runner infra --- Herebyfile.mjs | 7 - scripts/importDefinitelyTypedTests.mjs | 178 ------------------------ src/harness/runnerbase.ts | 2 +- src/testRunner/_namespaces/Harness.ts | 1 - src/testRunner/externalCompileRunner.ts | 132 ------------------ src/testRunner/runner.ts | 6 - 6 files changed, 1 insertion(+), 325 deletions(-) delete mode 100644 scripts/importDefinitelyTypedTests.mjs delete mode 100644 src/testRunner/externalCompileRunner.ts diff --git a/Herebyfile.mjs b/Herebyfile.mjs index f3a53ee44c86e..2ba40ce74a7b5 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -799,13 +799,6 @@ export const updateSublime = task({ } }); -// TODO(rbuckton): Should the path to DefinitelyTyped be configurable via an environment variable? -export const importDefinitelyTypedTests = task({ - name: "importDefinitelyTypedTests", - description: "Runs the importDefinitelyTypedTests script to copy DT's tests to the TS-internal RWC tests", - run: () => exec(process.execPath, ["scripts/importDefinitelyTypedTests.mjs", "./", "../DefinitelyTyped"]), -}); - export const produceLKG = task({ name: "LKG", diff --git a/scripts/importDefinitelyTypedTests.mjs b/scripts/importDefinitelyTypedTests.mjs deleted file mode 100644 index 4687be1fe6bfa..0000000000000 --- a/scripts/importDefinitelyTypedTests.mjs +++ /dev/null @@ -1,178 +0,0 @@ -import * as childProcess from "child_process"; -import * as fs from "fs"; -import * as os from "os"; -import * as path from "path"; -import url from "url"; - -const __filename = url.fileURLToPath(new URL(import.meta.url)); -const __dirname = path.dirname(__filename); - -main(); -function main() { - const [, progName, tscRoot, definitelyTypedRoot] = process.argv; - if (process.argv.length !== 4) { - if (process.argv.length < 2) { - throw new Error("Expected at least 2 argv elements."); - } - console.log("Usage:"); - console.log(` node ${path.relative(__dirname, progName)} [TypeScript Repo Root] [DefinitelyTyped Repo Root]`); - return; - } - - const tscPath = path.resolve(tscRoot, "built", "local", "tsc.js"); - const rwcTestPath = path.resolve(tscRoot, "internal", "cases", "rwc"); - const resolvedDefinitelyTypedRoot = path.resolve(definitelyTypedRoot); - - console.log(`Resolved TypeScript Compiler Path: '${tscPath}'.`); - console.log(`Resolved TypeScript RWC Path: '${rwcTestPath}'.`); - console.log(`Resolved DefinitelyTyped Repo Root: '${resolvedDefinitelyTypedRoot}'.`); - importDefinitelyTypedTests(tscPath, rwcTestPath, resolvedDefinitelyTypedRoot); -} - -/** - * @param {string} path - * @param {string} endingString - * @returns {boolean} - */ -function filePathEndsWith(path, endingString) { - const pathLen = path.length; - const extLen = endingString.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === endingString.toLocaleLowerCase(); -} - -/** - * @param {string} source - * @param {string} destination - */ -function copyFileSync(source, destination) { - const text = fs.readFileSync(source); - fs.writeFileSync(destination, text); -} - -/** - * @param {string} tscPath - * @param {string} rwcTestPath - * @param {string} testCaseName - * @param {string[]} testFiles - * @param {string | undefined} responseFile - */ -function importDefinitelyTypedTest(tscPath, rwcTestPath, testCaseName, testFiles, responseFile) { - let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); - if (responseFile) { - cmd += " @" + responseFile; - } - - const testDirectoryName = testCaseName + "_" + Math.floor((Math.random() * 10000) + 1); - const testDirectoryPath = path.join(os.tmpdir(), testDirectoryName); - if (fs.existsSync(testDirectoryPath)) { - throw new Error("Could not create test directory"); - } - fs.mkdirSync(testDirectoryPath); - - childProcess.exec(cmd, { - maxBuffer: 1 * 1024 * 1024, - cwd: testDirectoryPath - }, (error, stdout, stderr) => { - console.log("importing " + testCaseName + " ..."); - console.log(cmd); - - if (error) { - console.log("importing " + testCaseName + " ..."); - console.log(cmd); - console.log("==> error " + JSON.stringify(error)); - console.log("==> stdout " + String(stdout)); - console.log("==> stderr " + String(stderr)); - console.log("\r\n"); - return; - } - - // copy generated file to output location - const outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); - const testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); - copyFileSync(outputFilePath, testCasePath); - - //console.log("output generated at: " + outputFilePath); - - if (!fs.existsSync(testCasePath)) { - throw new Error("could not find test case at: " + testCasePath); - } - else { - fs.unlinkSync(outputFilePath); - fs.rmdirSync(testDirectoryPath); - //console.log("testcase generated at: " + testCasePath); - //console.log("Done."); - } - //console.log("\r\n"); - - }).on("error", (error) => { - console.log("==> error " + JSON.stringify(error)); - console.log("\r\n"); - }); -} - -/** - * @param {string} tscPath - * @param {string} rwcTestPath - * @param {string} definitelyTypedRoot - */ -function importDefinitelyTypedTests(tscPath, rwcTestPath, definitelyTypedRoot) { - fs.readdir(definitelyTypedRoot, (err, subDirectories) => { - if (err) { - throw err; - } - - // When you just want to test the script out on one or two files, - // just add a line like the following: - // - // .filter(d => d.indexOf("sipml") >= 0 ) - subDirectories - .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) - .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) - .forEach(d => { - const directoryPath = path.join(definitelyTypedRoot, d); - fs.readdir(directoryPath, (err, files) => { - if (err) { - throw err; - } - - /** @type {string[]} */ - const tsFiles = []; - /** @type {string[]} */ - const testFiles = []; - /** @type {string | undefined} */ - let paramFile; - - for (const filePath of files.map(f => path.join(directoryPath, f))) { - if (filePathEndsWith(filePath, ".ts")) { - tsFiles.push(filePath); - - if (filePathEndsWith(filePath, "-tests.ts")) { - testFiles.push(filePath); - } - } - else if (filePathEndsWith(filePath, ".tscparams")) { - paramFile = filePath; - } - } - - if (testFiles.length === 0) { - // no test files but multiple d.ts's, e.g. winjs - const regexp = new RegExp(d + "(([-][0-9])|(\\.d\\.ts))"); - if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) { - for (const fileName of tsFiles) { - importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile); - } - } - else { - importDefinitelyTypedTest(tscPath, rwcTestPath, d, tsFiles, paramFile); - } - } - else { - for (const fileName of tsFiles) { - importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, "-tests.ts"), [fileName], paramFile); - } - } - }); - }); - }); -} diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 60f61262e92c8..f195920ecec2a 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -5,7 +5,7 @@ import { } from "./_namespaces/Harness"; import * as ts from "./_namespaces/ts"; -export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "dt"; +export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc"; export type CompilerTestKind = "conformance" | "compiler"; export type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server"; diff --git a/src/testRunner/_namespaces/Harness.ts b/src/testRunner/_namespaces/Harness.ts index 2df05e12e2123..8ce2b8b171027 100644 --- a/src/testRunner/_namespaces/Harness.ts +++ b/src/testRunner/_namespaces/Harness.ts @@ -8,7 +8,6 @@ export { Parallel }; export * from "../fourslashRunner"; export * from "../compilerRunner"; -export * from "../externalCompileRunner"; export * from "../runner"; // If running as emitted CJS, don't start executing the tests here; instead start in runner.ts. diff --git a/src/testRunner/externalCompileRunner.ts b/src/testRunner/externalCompileRunner.ts deleted file mode 100644 index f251cce17647c..0000000000000 --- a/src/testRunner/externalCompileRunner.ts +++ /dev/null @@ -1,132 +0,0 @@ -import * as del from "del"; -import * as fs from "fs"; -import * as path from "path"; - -import { - Baseline, - IO, - isWorker, - RunnerBase, - TestRunnerKind, -} from "./_namespaces/Harness"; -import * as ts from "./_namespaces/ts"; - -interface ExecResult { - stdout: Buffer; - stderr: Buffer; - status: number | null; -} - -interface UserConfig { - types: string[]; - cloneUrl: string; - branch?: string; - path?: string; -} - -abstract class ExternalCompileRunnerBase extends RunnerBase { - abstract testDir: string; - abstract report(result: ExecResult): string | null; - enumerateTestFiles() { - return IO.getDirectories(this.testDir); - } - /** Setup the runner's tests so that they are ready to be executed by the harness - * The first test should be a describe/it block that sets up the harness's compiler instance appropriately - */ - initializeTests(): void { - // Read in and evaluate the test list - const testList = this.tests && this.tests.length ? this.tests : this.getTestFiles(); - - // eslint-disable-next-line @typescript-eslint/no-this-alias - const cls = this; - describe(`${this.kind()} code samples`, function (this: Mocha.Suite) { - this.timeout(600_000); // 10 minutes - for (const test of testList) { - cls.runTest(typeof test === "string" ? test : test.file); - } - }); - } - private runTest(directoryName: string) { - // eslint-disable-next-line @typescript-eslint/no-this-alias - const cls = this; - const timeout = 600_000; // 10 minutes - describe(directoryName, function (this: Mocha.Suite) { - this.timeout(timeout); - const cp: typeof import("child_process") = require("child_process"); - - it("should build successfully", () => { - let cwd = path.join(IO.getWorkspaceRoot(), cls.testDir, directoryName); - const originalCwd = cwd; - const stdio = isWorker ? "pipe" : "inherit"; - let types: string[] | undefined; - if (fs.existsSync(path.join(cwd, "test.json"))) { - const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig; - ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present."); - ts.Debug.assert(!!config.cloneUrl, "Bad format from test.json: cloneUrl field must be present."); - const submoduleDir = path.join(cwd, directoryName); - if (!fs.existsSync(submoduleDir)) { - exec("git", ["--work-tree", submoduleDir, "clone", "-b", config.branch || "master", config.cloneUrl, path.join(submoduleDir, ".git")], { cwd }); - } - else { - exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "checkout", config.branch || "master"], { cwd: submoduleDir }); - exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "reset", "HEAD", "--hard"], { cwd: submoduleDir }); - exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "clean", "-f"], { cwd: submoduleDir }); - exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "pull", "-f"], { cwd: submoduleDir }); - } - - types = config.types; - - cwd = config.path ? path.join(cwd, config.path) : submoduleDir; - } - const npmVersionText = exec("npm", ["--version"], { cwd, stdio: "pipe" })?.trim(); - const npmVersion = npmVersionText ? ts.Version.tryParse(npmVersionText.trim()) : undefined; - const isV7OrLater = !!npmVersion && npmVersion.major >= 7; - if (fs.existsSync(path.join(cwd, "package.json"))) { - if (fs.existsSync(path.join(cwd, "package-lock.json"))) { - fs.unlinkSync(path.join(cwd, "package-lock.json")); - } - if (fs.existsSync(path.join(cwd, "node_modules"))) { - del.sync(path.join(cwd, "node_modules"), { force: true }); - } - exec("npm", ["i", "--ignore-scripts", ...(isV7OrLater ? ["--legacy-peer-deps"] : [])], { cwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure - } - const args = [path.join(IO.getWorkspaceRoot(), "built/local/tsc.js")]; - if (types) { - args.push("--types", types.join(",")); - // Also actually install those types (for, eg, the js projects which need node) - if (types.length) { - exec("npm", ["i", ...types.map(t => `@types/${t}`), "--no-save", "--ignore-scripts", ...(isV7OrLater ? ["--legacy-peer-deps"] : [])], { cwd: originalCwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure - } - } - args.push("--noEmit"); - Baseline.runBaseline(`${cls.kind()}/${directoryName}.log`, cls.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }))); - - function exec(command: string, args: string[], options: { cwd: string, timeout?: number, stdio?: import("child_process").StdioOptions }): string | undefined { - const res = cp.spawnSync(isWorker ? `${command} 2>&1` : command, args, { shell: true, stdio, ...options }); - if (res.status !== 0) { - throw new Error(`${command} ${args.join(" ")} for ${directoryName} failed: ${res.stdout && res.stdout.toString()}`); - } - return options.stdio === "pipe" ? res.stdout.toString("utf8") : undefined; - } - }); - }); - } -} - -export class DefinitelyTypedRunner extends ExternalCompileRunnerBase { - readonly testDir = "../DefinitelyTyped/types/"; - override workingDirectory = this.testDir; - kind(): TestRunnerKind { - return "dt"; - } - report(result: ExecResult) { - // eslint-disable-next-line no-null/no-null - return !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status} -Standard output: -${result.stdout.toString().replace(/\r\n/g, "\n")} - - -Standard error: -${result.stderr.toString().replace(/\r\n/g, "\n")}`; - } -} diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index c2b8fe236325c..7f2c5b77dc396 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -2,7 +2,6 @@ import * as FourSlash from "./_namespaces/FourSlash"; import { CompilerBaselineRunner, CompilerTestType, - DefinitelyTypedRunner, FourSlashRunner, GeneratedFourslashRunner, IO, @@ -75,8 +74,6 @@ export function createRunner(kind: TestRunnerKind): RunnerBase { return new project.ProjectRunner(); case "rwc": return new RWC.RWCRunner(); - case "dt": - return new DefinitelyTypedRunner(); } return ts.Debug.fail(`Unknown runner kind ${kind}`); } @@ -211,9 +208,6 @@ function handleTestConfig() { case "rwc": runners.push(new RWC.RWCRunner()); break; - case "dt": - runners.push(new DefinitelyTypedRunner()); - break; } } } From dc24e9b678b2730fc89d23959817a650f2b957fa Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:01:45 -0800 Subject: [PATCH 3/6] Bring back tasks/scripts; they involve RWC, not the DT tests --- Herebyfile.mjs | 7 + scripts/importDefinitelyTypedTests.mjs | 178 +++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 scripts/importDefinitelyTypedTests.mjs diff --git a/Herebyfile.mjs b/Herebyfile.mjs index 2ba40ce74a7b5..f3a53ee44c86e 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -799,6 +799,13 @@ export const updateSublime = task({ } }); +// TODO(rbuckton): Should the path to DefinitelyTyped be configurable via an environment variable? +export const importDefinitelyTypedTests = task({ + name: "importDefinitelyTypedTests", + description: "Runs the importDefinitelyTypedTests script to copy DT's tests to the TS-internal RWC tests", + run: () => exec(process.execPath, ["scripts/importDefinitelyTypedTests.mjs", "./", "../DefinitelyTyped"]), +}); + export const produceLKG = task({ name: "LKG", diff --git a/scripts/importDefinitelyTypedTests.mjs b/scripts/importDefinitelyTypedTests.mjs new file mode 100644 index 0000000000000..4687be1fe6bfa --- /dev/null +++ b/scripts/importDefinitelyTypedTests.mjs @@ -0,0 +1,178 @@ +import * as childProcess from "child_process"; +import * as fs from "fs"; +import * as os from "os"; +import * as path from "path"; +import url from "url"; + +const __filename = url.fileURLToPath(new URL(import.meta.url)); +const __dirname = path.dirname(__filename); + +main(); +function main() { + const [, progName, tscRoot, definitelyTypedRoot] = process.argv; + if (process.argv.length !== 4) { + if (process.argv.length < 2) { + throw new Error("Expected at least 2 argv elements."); + } + console.log("Usage:"); + console.log(` node ${path.relative(__dirname, progName)} [TypeScript Repo Root] [DefinitelyTyped Repo Root]`); + return; + } + + const tscPath = path.resolve(tscRoot, "built", "local", "tsc.js"); + const rwcTestPath = path.resolve(tscRoot, "internal", "cases", "rwc"); + const resolvedDefinitelyTypedRoot = path.resolve(definitelyTypedRoot); + + console.log(`Resolved TypeScript Compiler Path: '${tscPath}'.`); + console.log(`Resolved TypeScript RWC Path: '${rwcTestPath}'.`); + console.log(`Resolved DefinitelyTyped Repo Root: '${resolvedDefinitelyTypedRoot}'.`); + importDefinitelyTypedTests(tscPath, rwcTestPath, resolvedDefinitelyTypedRoot); +} + +/** + * @param {string} path + * @param {string} endingString + * @returns {boolean} + */ +function filePathEndsWith(path, endingString) { + const pathLen = path.length; + const extLen = endingString.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === endingString.toLocaleLowerCase(); +} + +/** + * @param {string} source + * @param {string} destination + */ +function copyFileSync(source, destination) { + const text = fs.readFileSync(source); + fs.writeFileSync(destination, text); +} + +/** + * @param {string} tscPath + * @param {string} rwcTestPath + * @param {string} testCaseName + * @param {string[]} testFiles + * @param {string | undefined} responseFile + */ +function importDefinitelyTypedTest(tscPath, rwcTestPath, testCaseName, testFiles, responseFile) { + let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); + if (responseFile) { + cmd += " @" + responseFile; + } + + const testDirectoryName = testCaseName + "_" + Math.floor((Math.random() * 10000) + 1); + const testDirectoryPath = path.join(os.tmpdir(), testDirectoryName); + if (fs.existsSync(testDirectoryPath)) { + throw new Error("Could not create test directory"); + } + fs.mkdirSync(testDirectoryPath); + + childProcess.exec(cmd, { + maxBuffer: 1 * 1024 * 1024, + cwd: testDirectoryPath + }, (error, stdout, stderr) => { + console.log("importing " + testCaseName + " ..."); + console.log(cmd); + + if (error) { + console.log("importing " + testCaseName + " ..."); + console.log(cmd); + console.log("==> error " + JSON.stringify(error)); + console.log("==> stdout " + String(stdout)); + console.log("==> stderr " + String(stderr)); + console.log("\r\n"); + return; + } + + // copy generated file to output location + const outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); + const testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); + copyFileSync(outputFilePath, testCasePath); + + //console.log("output generated at: " + outputFilePath); + + if (!fs.existsSync(testCasePath)) { + throw new Error("could not find test case at: " + testCasePath); + } + else { + fs.unlinkSync(outputFilePath); + fs.rmdirSync(testDirectoryPath); + //console.log("testcase generated at: " + testCasePath); + //console.log("Done."); + } + //console.log("\r\n"); + + }).on("error", (error) => { + console.log("==> error " + JSON.stringify(error)); + console.log("\r\n"); + }); +} + +/** + * @param {string} tscPath + * @param {string} rwcTestPath + * @param {string} definitelyTypedRoot + */ +function importDefinitelyTypedTests(tscPath, rwcTestPath, definitelyTypedRoot) { + fs.readdir(definitelyTypedRoot, (err, subDirectories) => { + if (err) { + throw err; + } + + // When you just want to test the script out on one or two files, + // just add a line like the following: + // + // .filter(d => d.indexOf("sipml") >= 0 ) + subDirectories + .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) + .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) + .forEach(d => { + const directoryPath = path.join(definitelyTypedRoot, d); + fs.readdir(directoryPath, (err, files) => { + if (err) { + throw err; + } + + /** @type {string[]} */ + const tsFiles = []; + /** @type {string[]} */ + const testFiles = []; + /** @type {string | undefined} */ + let paramFile; + + for (const filePath of files.map(f => path.join(directoryPath, f))) { + if (filePathEndsWith(filePath, ".ts")) { + tsFiles.push(filePath); + + if (filePathEndsWith(filePath, "-tests.ts")) { + testFiles.push(filePath); + } + } + else if (filePathEndsWith(filePath, ".tscparams")) { + paramFile = filePath; + } + } + + if (testFiles.length === 0) { + // no test files but multiple d.ts's, e.g. winjs + const regexp = new RegExp(d + "(([-][0-9])|(\\.d\\.ts))"); + if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) { + for (const fileName of tsFiles) { + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile); + } + } + else { + importDefinitelyTypedTest(tscPath, rwcTestPath, d, tsFiles, paramFile); + } + } + else { + for (const fileName of tsFiles) { + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, "-tests.ts"), [fileName], paramFile); + } + } + }); + }); + }); +} From ea7d4d504c99a23755a315b5c7368abfa35c0d2e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:02:41 -0800 Subject: [PATCH 4/6] Misc cleanup --- .gitignore | 2 -- scripts/build/tests.mjs | 1 - src/harness/harnessIO.ts | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 03766663f28ca..7c830332ae9c4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ node_modules/ .node_modules/ built/* tests/cases/rwc/* -tests/cases/test262/* tests/cases/perf/* !tests/cases/webharness/compilerToString.js test-args.txt @@ -14,7 +13,6 @@ tests/baselines/local.old/* tests/services/baselines/local/* tests/baselines/prototyping/local/* tests/baselines/rwc/* -tests/baselines/test262/* tests/baselines/reference/projectOutput/* tests/baselines/local/projectOutput/* tests/baselines/reference/testresults.tap diff --git a/scripts/build/tests.mjs b/scripts/build/tests.mjs index f1c4292ad9cbe..3edddad9efafa 100644 --- a/scripts/build/tests.mjs +++ b/scripts/build/tests.mjs @@ -14,7 +14,6 @@ export const localBaseline = "tests/baselines/local/"; export const refBaseline = "tests/baselines/reference/"; export const localRwcBaseline = "internal/baselines/rwc/local"; export const refRwcBaseline = "internal/baselines/rwc/reference"; -export const localTest262Baseline = "internal/baselines/test262/local"; /** * @param {string} runJs diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index 50354f3f66bdb..80c55d37b7848 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -610,7 +610,7 @@ export namespace Compiler { // if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers) // then they will be added twice thus triggering 'total errors' assertion with condition // Similarly for tsconfig, which may be in the input files and contain errors. - // 'totalErrorsReportedInNonLibraryNonTsconfigFiles + numLibraryDiagnostics + numTsconfigDiagnostics + numTest262HarnessDiagnostics, diagnostics.length + // 'totalErrorsReportedInNonLibraryNonTsconfigFiles + numLibraryDiagnostics + numTsconfigDiagnostics, diagnostics.length if (!error.file || !isDefaultLibraryFile(error.file.fileName) && !vpath.isTsConfigFile(error.file.fileName)) { totalErrorsReportedInNonLibraryNonTsconfigFiles++; From 71b5d09836212a69243ae4017f4f7b283496e7fa Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:49:23 -0800 Subject: [PATCH 5/6] Huh? --- src/testRunner/_namespaces/Harness.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/testRunner/_namespaces/Harness.ts b/src/testRunner/_namespaces/Harness.ts index 8ce2b8b171027..a650370a94350 100644 --- a/src/testRunner/_namespaces/Harness.ts +++ b/src/testRunner/_namespaces/Harness.ts @@ -1,3 +1,6 @@ +// TODO(jakebailey): Why do random ts-eslint errors appear when this is removed? +/// + /* Generated file to emulate the Harness namespace. */ export * from "../../harness/_namespaces/Harness"; From 7c6278c0283cfcc0f66d4b78639d8eb27a1fd7dc Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 6 Mar 2023 21:02:52 -0800 Subject: [PATCH 6/6] Fix eslint by using its own tsconfig and extra types --- src/.eslintrc.json | 2 +- src/testRunner/_namespaces/Harness.ts | 3 --- src/tsconfig-eslint.json | 6 ++++++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 src/tsconfig-eslint.json diff --git a/src/.eslintrc.json b/src/.eslintrc.json index 358464aa498cc..52ffeff5ab499 100644 --- a/src/.eslintrc.json +++ b/src/.eslintrc.json @@ -2,7 +2,7 @@ "extends": "../.eslintrc.json", "parserOptions": { "tsconfigRootDir": "src", - "project": "./tsconfig-base.json" + "project": "./tsconfig-eslint.json" }, "rules": { "@typescript-eslint/no-unnecessary-type-assertion": "error", diff --git a/src/testRunner/_namespaces/Harness.ts b/src/testRunner/_namespaces/Harness.ts index a650370a94350..8ce2b8b171027 100644 --- a/src/testRunner/_namespaces/Harness.ts +++ b/src/testRunner/_namespaces/Harness.ts @@ -1,6 +1,3 @@ -// TODO(jakebailey): Why do random ts-eslint errors appear when this is removed? -/// - /* Generated file to emulate the Harness namespace. */ export * from "../../harness/_namespaces/Harness"; diff --git a/src/tsconfig-eslint.json b/src/tsconfig-eslint.json new file mode 100644 index 0000000000000..087b75ff7dc15 --- /dev/null +++ b/src/tsconfig-eslint.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig-base", + "compilerOptions": { + "types": ["node", "mocha", "chai"] + } +}