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

Remove the '--experimental-debug' feature #7681

Merged
merged 12 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
21 changes: 0 additions & 21 deletions .github/workflows/test-functional-local-debug-1.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/test-functional-local-debug-2.yml

This file was deleted.

14 changes: 0 additions & 14 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const {
TESTS_GLOB,
LEGACY_TESTS_GLOB,
MULTIPLE_WINDOWS_TESTS_GLOB,
DEBUG_GLOB_1,
DEBUG_GLOB_2,
HEADED_CHROME_FIREFOX_TESTS_GLOB,
} = require('./gulp/constants/functional-test-globs');

Expand Down Expand Up @@ -460,18 +458,6 @@ gulp.step('test-functional-local-chrome-firefox-headed-run', () => {

gulp.task('test-functional-local-chrome-firefox-headed', gulp.series('prepare-tests', 'test-functional-local-chrome-firefox-headed-run'));

gulp.step('test-functional-local-debug-run-1', () => {
return testFunctional(DEBUG_GLOB_1, functionalTestConfig.testingEnvironmentNames.localHeadlessChrome, { experimentalDebug: true });
});

gulp.step('test-functional-local-debug-run-2', () => {
return testFunctional(DEBUG_GLOB_2, functionalTestConfig.testingEnvironmentNames.localHeadlessChrome, { experimentalDebug: true });
});

gulp.task('test-functional-local-debug-1', gulp.series('prepare-tests', 'test-functional-local-debug-run-1'));

gulp.task('test-functional-local-debug-2', gulp.series('prepare-tests', 'test-functional-local-debug-run-2'));

gulp.step('test-functional-local-native-automation-run', () => {
return testFunctional(TESTS_GLOB, functionalTestConfig.testingEnvironmentNames.localHeadlessChrome, { nativeAutomation: true });
});
Expand Down
26 changes: 10 additions & 16 deletions bin/testcafe-with-v8-flag-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@ const path = require('path');
const url = require('url');
const v8FlagsFilter = require('@devexpress/bin-v8-flags-filter');

const EXPERIMENTAL_DEBUG_OPTION = '--experimental-debug';
const ESM_OPTION = '--esm';
const ESM_OPTION = '--esm';

if (process.argv.slice(2).includes(EXPERIMENTAL_DEBUG_OPTION))
require('../lib/cli');
const forcedArgs = [];

else {
const forcedArgs = [];

if (process.argv.slice(2).includes(ESM_OPTION)) {
forcedArgs.push('--no-warnings');
forcedArgs.push(`--experimental-loader=${url.pathToFileURL(path.join(__dirname, '../lib/compiler/esm-loader.js')).href}`);
}

v8FlagsFilter(path.join(__dirname, '../lib/cli'), {
useShutdownMessage: true,
forcedArgs,
});
if (process.argv.slice(2).includes(ESM_OPTION)) {
forcedArgs.push('--no-warnings');
forcedArgs.push(`--experimental-loader=${url.pathToFileURL(path.join(__dirname, '../lib/compiler/esm-loader.js')).href}`);
}

v8FlagsFilter(path.join(__dirname, '../lib/cli'), {
useShutdownMessage: true,
forcedArgs,
});
15 changes: 0 additions & 15 deletions gulp/constants/functional-test-globs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,12 @@ const TESTS_GLOB = [
`!${COMPILER_SERVICE_TESTS_GLOB}`,
];

const DEBUG_GLOB_1 = [
MULTIPLE_WINDOWS_TESTS_GLOB,
'test/functional/fixtures/regression/**/test.js',
'test/functional/fixtures/api/es-next/selector/test.js',
'test/functional/fixtures/api/raw/**/test.js',
];

const DEBUG_GLOB_2 = [
BASIC_TESTS_GLOB,
...DEBUG_GLOB_1.map(glob => `!${glob}`),
...SCREENSHOT_TESTS_GLOB.map(glob => `!${glob}`),
];

module.exports = {
TESTS_GLOB,
LEGACY_TESTS_GLOB,
MULTIPLE_WINDOWS_TESTS_GLOB,
BASIC_TESTS_GLOB,
COMPILER_SERVICE_TESTS_GLOB,
DEBUG_GLOB_1,
DEBUG_GLOB_2,
SCREENSHOT_TESTS_GLOB,
HEADED_CHROME_FIREFOX_TESTS_GLOB,
};
5 changes: 1 addition & 4 deletions gulp/helpers/test-functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ function getGroupOfTests (tests, groupNumber, groupsCount) {
return tests.slice(testFragmentStartIndex, testFragmentEndIndex);
}

module.exports = async function testFunctional (src, testingEnvironmentName, { experimentalDebug, nativeAutomation } = {}) {
module.exports = async function testFunctional (src, testingEnvironmentName, { nativeAutomation } = {}) {
process.env.TESTING_ENVIRONMENT = testingEnvironmentName;
process.env.BROWSERSTACK_USE_AUTOMATE = 1;

if (experimentalDebug)
process.env.EXPERIMENTAL_DEBUG = 'true';

if (nativeAutomation)
process.env.NATIVE_AUTOMATION = 'true';

Expand Down
2 changes: 1 addition & 1 deletion src/api/exportable-lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const exportableLib = {
if (global[TEST_FILE_TEMP_VARIABLE_NAME]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, TEST_FILE_TEMP_VARIABLE_NAME is needed only for the compiler service mode. So, you can remove this if-else block.

const { testFile, baseUrl } = global[TEST_FILE_TEMP_VARIABLE_NAME];

addExportAPI(testFile, exportableLib, { isCompilerServiceMode: true, baseUrl });
addExportAPI(testFile, exportableLib, { baseUrl });

delete global[TEST_FILE_TEMP_VARIABLE_NAME];
}
Expand Down
19 changes: 3 additions & 16 deletions src/api/structure/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import ClientScriptInit from '../../custom-client-scripts/client-script-init';
import { SPECIAL_BLANK_PAGE } from 'testcafe-hammerhead';
import { TestTimeouts } from './interfaces';
import TestTimeout from './test-timeout';
import ESM_RUNTIME_HOLDER_NAME from '../../services/compiler/esm-runtime-holder-name';

interface TestInitOptions {
testFile: TestFile;
baseUrl?: string;
isCompilerServiceMode?: boolean;
}

export default class Test extends TestingUnit {
Expand All @@ -31,10 +29,8 @@ export default class Test extends TestingUnit {
public globalBeforeFn: Function | null;
public globalAfterFn: Function | null;
public timeouts: TestTimeouts | null;
private readonly _isCompilerService: boolean;
public readonly esmRuntime: string;

public constructor (testFile: TestFile, isCompilerServiceMode = false, baseUrl?: string, returnApiOrigin = true) {
public constructor (testFile: TestFile, baseUrl?: string, returnApiOrigin = true) {
// NOTE: 'fixture' directive can be missing
const fixture = testFile.currentFixture as Fixture;
const pageUrl = fixture?.pageUrl || SPECIAL_BLANK_PAGE;
Expand All @@ -49,20 +45,14 @@ export default class Test extends TestingUnit {
this.globalAfterFn = null;
this.timeouts = null;

this._isCompilerService = isCompilerServiceMode;

this._initFixture(testFile);

// NOTE: This is internal data of 'esm' module
// @ts-ignore
this.esmRuntime = global[ESM_RUNTIME_HOLDER_NAME] || null;

if (returnApiOrigin)
return this.apiOrigin as unknown as Test;
}

public static init ({ testFile, baseUrl, isCompilerServiceMode }: TestInitOptions): Test {
return TestingUnit.init(Test, testFile, isCompilerServiceMode, baseUrl) as unknown as Test;
public static init ({ testFile, baseUrl }: TestInitOptions): Test {
return TestingUnit.init(Test, testFile, baseUrl) as unknown as Test;
}

private _initFixture (testFile: TestFile): void {
Expand All @@ -78,9 +68,6 @@ export default class Test extends TestingUnit {
}

protected _add (name: string, fn: Function): Function {
if (this._isCompilerService && !this.fixture)
this._initFixture(this.testFile);

assertType(is.string, 'apiOrigin', 'The test name', name);
assertType(is.function, 'apiOrigin', 'The test body', fn);
assertType(is.nonNullObject, 'apiOrigin', `The fixture of '${name}' test`, this.fixture);
Expand Down
3 changes: 1 addition & 2 deletions src/api/test-controller/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import TestRun from '../../test-run';
import TestRunProxy from '../../services/compiler/test-run-proxy';
import WarningLog from '../../notifications/warning-log';
import { CommandBase } from '../../test-run/commands/base';
import { CallsiteRecord } from 'callsite-record';

export default class TestController {
public browser: string;
public constructor (testRun: TestRun | TestRunProxy);
public constructor (testRun: TestRun);
public testRun: TestRun;
public warningLog: WarningLog;
public enqueueCommand (CmdCtor: unknown, cmdArgs: object, validateCommand: Function, callsite?: CallsiteRecord): () => Promise<unknown>;
Expand Down
15 changes: 2 additions & 13 deletions src/api/test-controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
assign,
isNil as isNullOrUndefined,
flattenDeep,
noop,
castArray,
} from 'lodash';

Expand Down Expand Up @@ -71,7 +70,6 @@ import {
import { WaitCommand, DebugCommand } from '../../test-run/commands/observation';
import { createExecutionContext as createContext } from './execution-context';
import { isSelector } from '../../client-functions/types';
import TestRunProxy from '../../services/compiler/test-run-proxy';

import {
MultipleWindowsModeIsDisabledError,
Expand Down Expand Up @@ -281,7 +279,7 @@ export default class TestController {
const controller = this;
const callsite = getCallsiteForMethod(RequestCommand.methodName);

if (!controller.testRun || controller.testRun instanceof TestRunProxy)
if (!controller.testRun)
throw new RequestRuntimeError(callsite, RUNTIME_ERRORS.requestCannotResolveTestRun);

return function (...args) {
Expand Down Expand Up @@ -601,7 +599,7 @@ export default class TestController {
// NOTE: do not need to enqueue the Debug command if we are in debugging mode.
// The Debug command will be executed by CDP.
// Also, we are forced to add empty function to the execution chain to preserve it.
return this.isCompilerServiceMode() ? this._enqueueTask(DebugCommand.methodName, noop) : this.enqueueCommand(DebugCommand);
return this.enqueueCommand(DebugCommand);
}

[delegatedAPI(SetTestSpeedCommand.methodName)] (speed) {
Expand Down Expand Up @@ -647,10 +645,6 @@ export default class TestController {
}

shouldStop (command) {
// NOTE: should never stop in not compliler debugging mode
if (!this.isCompilerServiceMode())
return false;

// NOTE: should always stop on Debug command
if (command === 'debug')
return true;
Expand All @@ -664,11 +658,6 @@ export default class TestController {

return false;
}

isCompilerServiceMode () {
return this.testRun instanceof TestRunProxy;
}

}

TestController.API_LIST = getDelegatedAPIList(TestController.prototype);
Expand Down
7 changes: 3 additions & 4 deletions src/api/test-run-tracker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import getStackFrames from 'callsite';
import { EventEmitter } from 'events';
import TestRun from '../test-run';
import TestRunProxy from '../services/compiler/test-run-proxy';

const TRACKING_MARK_RE = /^\$\$testcafe_test_run\$\$(\S+)\$\$$/;
const STACK_CAPACITY = 5000;

class TestRunTracker extends EventEmitter {
private enabled: boolean;
public activeTestRuns: { [id: string]: TestRun | TestRunProxy };
public activeTestRuns: { [id: string]: TestRun };

public constructor () {
super();
Expand Down Expand Up @@ -103,7 +102,7 @@ class TestRunTracker extends EventEmitter {
return null;
}

public resolveContextTestRun (): TestRun | TestRunProxy | null {
public resolveContextTestRun (): TestRun | null {
const testRunId = this.getContextTestRunId();

if (testRunId)
Expand All @@ -112,7 +111,7 @@ class TestRunTracker extends EventEmitter {
return null;
}

public addActiveTestRun (testRun: TestRun | TestRunProxy): void {
public addActiveTestRun (testRun: TestRun): void {
this.activeTestRuns[testRun.id] = testRun;

testRun.onAny((eventName: string, eventData: unknown) => this.emit(eventName, { testRun, data: eventData }));
Expand Down
14 changes: 1 addition & 13 deletions src/assertions/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import ReExecutablePromise from '../utils/re-executable-promise';
import getFn from './get-fn';
import { AssertionCommand } from '../test-run/commands/assertion';
import { CallsiteRecord } from 'callsite-record';
import { FUNCTION_MARKER_DESCRIPTION } from '../services/serialization/replicator/transforms/function-marker-transform/marker';
import { PROMISE_MARKER_DESCRIPTION } from '../services/serialization/replicator/transforms/promise-marker-transform/marker';

const ASSERTION_DELAY = 200;

Expand Down Expand Up @@ -43,8 +41,7 @@ export default class AssertionExecutor extends EventEmitter {
}

private _isPromise (val: unknown): boolean {
return isThennable(val) ||
val === Symbol.for(PROMISE_MARKER_DESCRIPTION);
return isThennable(val);
}

private _getTimeLeft (): number {
Expand Down Expand Up @@ -86,16 +83,7 @@ export default class AssertionExecutor extends EventEmitter {
};
}

private _onBeforeRun (): void {
if (this.command.actual !== Symbol.for(FUNCTION_MARKER_DESCRIPTION))
return;

this.emit('non-serializable-actual-value', this);
}

public async run (): Promise<void> {
this._onBeforeRun();

this.startTime = new Date().getTime();

try {
Expand Down
1 change: 0 additions & 1 deletion src/cli/argument-parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ export default class CLIArgumentParser {
.option('--no-color', 'disable text color formatting in the CLI')

// NOTE: Temporarily exclude experimental options from --help output
.addOption(new Option('--experimental-debug', 'enable experimental the debug mode').hideHelp())
.addOption(new Option('--disable-cross-domain', 'experimental').hideHelp())
.action((opts: CommandLineOptions) => {
this.opts = opts;
Expand Down
2 changes: 0 additions & 2 deletions src/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ async function runTests (argParser) {
hostname,
ssl,
dev,
experimentalDebug,
retryTestPages,
cache,
disableHttp2,
Expand All @@ -97,7 +96,6 @@ async function runTests (argParser) {
port1,
port2,
ssl,
experimentalDebug,
retryTestPages,
cache,
configFile,
Expand Down
Loading