dd-trace 6.8.0 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ci/diagnose.js +27 -25
- package/ci/init.js +6 -6
- package/ci/runbook.md +114 -20
- package/ci/test-optimization-validation/approval-artifacts.js +36 -3
- package/ci/test-optimization-validation/approval.js +78 -22
- package/ci/test-optimization-validation/blocker-category.js +24 -0
- package/ci/test-optimization-validation/ci-discovery.js +23 -17
- package/ci/test-optimization-validation/ci-package-scripts.js +34 -6
- package/ci/test-optimization-validation/ci-remediation.js +1 -1
- package/ci/test-optimization-validation/cli.js +280 -52
- package/ci/test-optimization-validation/command-blocker.js +159 -20
- package/ci/test-optimization-validation/command-output-policy.js +9 -3
- package/ci/test-optimization-validation/command-runner.js +9 -7
- package/ci/test-optimization-validation/environment.js +4 -2
- package/ci/test-optimization-validation/executable.js +15 -13
- package/ci/test-optimization-validation/execution-lock.js +70 -0
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +3 -0
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +657 -5
- package/ci/test-optimization-validation/framework-adapters/vitest.js +517 -0
- package/ci/test-optimization-validation/generated-files.js +38 -28
- package/ci/test-optimization-validation/generated-test-contract.js +8 -4
- package/ci/test-optimization-validation/generated-verifier.js +24 -17
- package/ci/test-optimization-validation/literal-glob.js +52 -0
- package/ci/test-optimization-validation/manifest-loader.js +3 -0
- package/ci/test-optimization-validation/manifest-scaffold.js +300 -50
- package/ci/test-optimization-validation/manifest-schema.js +80 -17
- package/ci/test-optimization-validation/offline-fixtures.js +13 -4
- package/ci/test-optimization-validation/package-check.js +94 -0
- package/ci/test-optimization-validation/plan-writer.js +183 -10
- package/ci/test-optimization-validation/preflight-runner.js +110 -31
- package/ci/test-optimization-validation/project-build-artifact.js +31 -0
- package/ci/test-optimization-validation/redaction.js +18 -27
- package/ci/test-optimization-validation/report-writer.js +182 -48
- package/ci/test-optimization-validation/result-semantics.js +20 -3
- package/ci/test-optimization-validation/runner-command.js +40 -20
- package/ci/test-optimization-validation/runner-contract.js +79 -43
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +59 -5
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +141 -35
- package/ci/test-optimization-validation/scenarios/helpers.js +30 -6
- package/ci/test-optimization-validation/static-diagnosis.js +10 -3
- package/ci/test-optimization-validation/test-output.js +2 -1
- package/ci/test-optimization-validation/validation-blocker.js +21 -0
- package/ci/vitest-no-worker-init-setup.mjs +30 -34
- package/index.d.ts +98 -1
- package/init.js +1 -17
- package/initialize.mjs +11 -0
- package/loader-hook.mjs +6 -4
- package/package.json +5 -3
- package/packages/datadog-core/src/utils/src/parse-tags.js +0 -1
- package/packages/datadog-esbuild/src/utils.js +16 -1
- package/packages/datadog-instrumentations/src/ai.js +61 -34
- package/packages/datadog-instrumentations/src/bluebird.js +6 -6
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +81 -5
- package/packages/datadog-instrumentations/src/cucumber.js +124 -47
- package/packages/datadog-instrumentations/src/dns.js +21 -2
- package/packages/datadog-instrumentations/src/electron.js +1 -0
- package/packages/datadog-instrumentations/src/fastify.js +3 -1
- package/packages/datadog-instrumentations/src/grpc/client.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +33 -9
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +118 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +20 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +32 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +61 -0
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +37 -6
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +979 -233
- package/packages/datadog-instrumentations/src/mocha/main.js +107 -9
- package/packages/datadog-instrumentations/src/mocha/utils.js +64 -42
- package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +25 -0
- package/packages/datadog-instrumentations/src/mocha/worker.js +12 -18
- package/packages/datadog-instrumentations/src/mysql.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +155 -23
- package/packages/datadog-instrumentations/src/openai.js +14 -0
- package/packages/datadog-instrumentations/src/pg.js +180 -6
- package/packages/datadog-instrumentations/src/playwright.js +173 -79
- package/packages/datadog-instrumentations/src/promise-js.js +4 -4
- package/packages/datadog-instrumentations/src/promise.js +3 -3
- package/packages/datadog-instrumentations/src/router.js +195 -19
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +43 -10
- package/packages/datadog-instrumentations/src/vitest-main.js +360 -56
- package/packages/datadog-instrumentations/src/vitest-util.js +42 -7
- package/packages/datadog-instrumentations/src/vitest-worker.js +234 -17
- package/packages/datadog-instrumentations/src/webdriverio.js +194 -18
- package/packages/datadog-instrumentations/src/when.js +3 -3
- package/packages/datadog-instrumentations/src/ws.js +5 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +59 -48
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -3
- package/packages/datadog-plugin-cucumber/src/index.js +5 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -46
- package/packages/datadog-plugin-cypress/src/support.js +7 -4
- package/packages/datadog-plugin-electron/src/net.js +10 -4
- package/packages/datadog-plugin-http/src/client.js +1 -1
- package/packages/datadog-plugin-http2/src/client.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +1 -18
- package/packages/datadog-plugin-jest/src/util.js +2 -0
- package/packages/datadog-plugin-kafkajs/src/producer.js +2 -1
- package/packages/datadog-plugin-mocha/src/index.js +318 -1
- package/packages/datadog-plugin-next/src/index.js +57 -9
- package/packages/datadog-plugin-openai/src/tracing.js +4 -0
- package/packages/datadog-plugin-pg/src/index.js +65 -1
- package/packages/datadog-plugin-playwright/src/index.js +1 -1
- package/packages/datadog-plugin-vitest/src/index.js +95 -7
- package/packages/datadog-shimmer/src/shimmer.js +6 -2
- package/packages/dd-trace/src/aiguard/sdk.js +3 -0
- package/packages/dd-trace/src/appsec/{blocking.js → blocking/index.js} +26 -6
- package/packages/dd-trace/src/appsec/handlers/auth.js +62 -0
- package/packages/dd-trace/src/appsec/handlers/http-request.js +215 -0
- package/packages/dd-trace/src/appsec/handlers/http-response.js +78 -0
- package/packages/dd-trace/src/appsec/handlers/http-shared.js +24 -0
- package/packages/dd-trace/src/appsec/handlers/payments.js +104 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +48 -476
- package/packages/dd-trace/src/appsec/sdk/track_event.js +9 -0
- package/packages/dd-trace/src/ci-visibility/coverage-report-discovery.js +46 -14
- package/packages/dd-trace/src/ci-visibility/efd-retry-policy.js +89 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +27 -13
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +17 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +21 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +22 -7
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +21 -5
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +5 -1
- package/packages/dd-trace/src/config/generated-config-types.d.ts +2 -0
- package/packages/dd-trace/src/config/helper.js +2 -0
- package/packages/dd-trace/src/config/index.js +16 -5
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +8 -0
- package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -1
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +0 -1
- package/packages/dd-trace/src/guardrails/apply-pm2-env.js +16 -0
- package/packages/dd-trace/src/guardrails/log.js +1 -10
- package/packages/dd-trace/src/llmobs/eval-metric.js +249 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +33 -25
- package/packages/dd-trace/src/llmobs/experiments/util.js +4 -2
- package/packages/dd-trace/src/llmobs/noop.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +5 -5
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +149 -68
- package/packages/dd-trace/src/llmobs/telemetry.js +18 -0
- package/packages/dd-trace/src/llmobs/writers/base.js +3 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +2 -0
- package/packages/dd-trace/src/log/channels.js +1 -9
- package/packages/dd-trace/src/log/levels.js +12 -0
- package/packages/dd-trace/src/openfeature/writers/exposures.js +1 -1
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -1
- package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +8 -4
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +1 -1
- package/packages/dd-trace/src/opentelemetry/span.js +4 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +21 -5
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/util/ci.js +6 -0
- package/packages/dd-trace/src/plugins/util/git.js +6 -4
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +2 -2
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +1 -1
- package/packages/dd-trace/src/plugins/util/stacktrace.js +3 -0
- package/packages/dd-trace/src/plugins/util/test.js +319 -75
- package/packages/dd-trace/src/plugins/util/url.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +23 -1
- package/packages/dd-trace/src/profiler.js +1 -1
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -2
- package/packages/dd-trace/src/proxy.js +1 -0
- package/packages/dd-trace/src/ritm.js +5 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +4 -2
- package/packages/dd-trace/src/sampling_rule.js +4 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +1 -1
- package/packages/dd-trace/src/telemetry/logs/index.js +3 -0
- package/packages/dd-trace/src/telemetry/telemetry.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/version.js +10 -8
- /package/packages/dd-trace/src/appsec/{blocked_templates.js → blocking/templates.js} +0 -0
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const fs = require('node:fs')
|
|
4
3
|
const path = require('node:path')
|
|
5
4
|
const { fileURLToPath } = require('node:url')
|
|
6
5
|
const { MessagePort } = require('node:worker_threads')
|
|
7
6
|
|
|
8
7
|
const shimmer = require('../../datadog-shimmer')
|
|
9
8
|
const log = require('../../dd-trace/src/log')
|
|
9
|
+
const { EMPTY_EFD_RETRY_POLICY } = require('../../dd-trace/src/ci-visibility/efd-retry-policy')
|
|
10
10
|
const {
|
|
11
11
|
VITEST_WORKER_TRACE_PAYLOAD_CODE,
|
|
12
|
+
VITEST_WORKER_COVERAGE_PAYLOAD_CODE,
|
|
12
13
|
VITEST_WORKER_LOGS_PAYLOAD_CODE,
|
|
13
|
-
|
|
14
|
+
VITEST_WORKER_TELEMETRY_PAYLOAD_CODE,
|
|
14
15
|
collectTestOptimizationSummariesFromTraces,
|
|
15
16
|
logTestOptimizationSummary,
|
|
17
|
+
TEST_IMPACT_ANALYSIS_ALL_TESTS_SKIPPED_MESSAGE,
|
|
16
18
|
getTestOptimizationRequestResults,
|
|
17
19
|
getTestSuitePath,
|
|
18
20
|
isModifiedTest,
|
|
21
|
+
recordTestManagementExecution,
|
|
22
|
+
recordAttemptToFixExecution,
|
|
19
23
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
24
|
+
const { isMarkedAsUnskippable } = require('../../datadog-plugin-jest/src/util')
|
|
20
25
|
const { getChannelPromise } = require('./helpers/channel')
|
|
21
|
-
const { addHook } = require('./helpers/instrument')
|
|
26
|
+
const { addHook, channel } = require('./helpers/instrument')
|
|
22
27
|
const noWorkerInit = require('./vitest-main-no-worker-init')
|
|
23
28
|
const {
|
|
24
29
|
testStartCh,
|
|
@@ -37,8 +42,11 @@ const {
|
|
|
37
42
|
testManagementTestsCh,
|
|
38
43
|
modifiedFilesCh,
|
|
39
44
|
workerReportTraceCh,
|
|
45
|
+
workerReportCoverageCh,
|
|
40
46
|
workerReportLogsCh,
|
|
47
|
+
workerReportTelemetryCh,
|
|
41
48
|
codeCoverageReportCh,
|
|
49
|
+
realpath,
|
|
42
50
|
findExportByName,
|
|
43
51
|
getTypeTasks,
|
|
44
52
|
getWorkspaceProject,
|
|
@@ -52,33 +60,46 @@ const workerProcesses = new WeakSet()
|
|
|
52
60
|
const mainProcessSetupStates = new WeakMap()
|
|
53
61
|
const coverageWrappedProviders = new WeakSet()
|
|
54
62
|
const finishWrappedContexts = new WeakSet()
|
|
63
|
+
const runFilesWrappedPrototypes = new WeakSet()
|
|
64
|
+
const activeRunFilesContexts = new WeakSet()
|
|
55
65
|
let isFlakyTestRetriesEnabled = false
|
|
56
66
|
let flakyTestRetriesCount = 0
|
|
57
67
|
let isEarlyFlakeDetectionEnabled = false
|
|
58
|
-
let
|
|
59
|
-
let earlyFlakeDetectionSlowTestRetries = {}
|
|
68
|
+
let earlyFlakeDetectionRetryPolicy = EMPTY_EFD_RETRY_POLICY
|
|
60
69
|
let isEarlyFlakeDetectionFaulty = false
|
|
61
70
|
let isKnownTestsEnabled = false
|
|
62
71
|
let isTestManagementTestsEnabled = false
|
|
63
72
|
let isImpactedTestsEnabled = false
|
|
73
|
+
let isCodeCoverageEnabled = false
|
|
74
|
+
let isSuitesSkippingEnabled = false
|
|
75
|
+
let isSessionCodeCoverageEnabled = false
|
|
76
|
+
let isSessionSuitesSkippingEnabled = false
|
|
64
77
|
let testManagementAttemptToFixRetries = 0
|
|
65
78
|
let isDiEnabled = false
|
|
66
79
|
let testCodeCoverageLinesTotal
|
|
67
80
|
let coverageRootDir
|
|
68
81
|
let requestErrorTags = {}
|
|
69
82
|
let isSessionStarted = false
|
|
83
|
+
let isTestImpactAnalysisDisabled = false
|
|
70
84
|
let isVitestNoWorkerInitActive = false
|
|
71
85
|
let isVitestBrowserModeActive = false
|
|
72
86
|
let vitestPool = null
|
|
73
87
|
let isMessagePortWrapped = false
|
|
88
|
+
let skippableSuites = []
|
|
89
|
+
let skippedSuites = []
|
|
90
|
+
let unskippableSuites = {}
|
|
91
|
+
let forcedToRunSuites = {}
|
|
92
|
+
let hasUnskippableSuites = false
|
|
93
|
+
let hasForcedToRunSuites = false
|
|
94
|
+
let areAllSuitesSkipped = false
|
|
95
|
+
let hasLoggedAllTestsSkippedMessage = false
|
|
96
|
+
let hasRunnableSuites = false
|
|
97
|
+
let hasSelectedSuites = false
|
|
98
|
+
let itrCorrelationId
|
|
99
|
+
let tiaRepositoryRoot = process.cwd()
|
|
74
100
|
const tinyPoolClassWrappers = new WeakMap()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!slowTestRetries || !Object.keys(slowTestRetries).length) {
|
|
78
|
-
return fallbackRetryCount
|
|
79
|
-
}
|
|
80
|
-
return getMaxEfdRetryCount(slowTestRetries)
|
|
81
|
-
}
|
|
101
|
+
const itrSkippedSuitesCh = channel('ci:vitest:itr:skipped-suites')
|
|
102
|
+
const skippableSuitesCh = channel('ci:vitest:test-suite:skippable')
|
|
82
103
|
|
|
83
104
|
function getTestCommand () {
|
|
84
105
|
return `vitest ${process.argv.slice(2).join(' ')}`
|
|
@@ -202,18 +223,168 @@ function getNormalizedTestSuitePath (testFilepath, repositoryRoot) {
|
|
|
202
223
|
return getTestSuitePath(realpath(testSuiteAbsolutePath), realpath(repositoryRoot))
|
|
203
224
|
}
|
|
204
225
|
|
|
226
|
+
function resetSuiteSkippingRunState () {
|
|
227
|
+
skippableSuites = []
|
|
228
|
+
resetAppliedSuiteSkippingState()
|
|
229
|
+
itrCorrelationId = undefined
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function resetAppliedSuiteSkippingState () {
|
|
233
|
+
unskippableSuites = {}
|
|
234
|
+
forcedToRunSuites = {}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function resetSessionSuiteSkippingState () {
|
|
238
|
+
skippedSuites = []
|
|
239
|
+
hasUnskippableSuites = false
|
|
240
|
+
hasForcedToRunSuites = false
|
|
241
|
+
areAllSuitesSkipped = false
|
|
242
|
+
hasLoggedAllTestsSkippedMessage = false
|
|
243
|
+
hasRunnableSuites = false
|
|
244
|
+
hasSelectedSuites = false
|
|
245
|
+
isSessionCodeCoverageEnabled = false
|
|
246
|
+
isSessionSuitesSkippingEnabled = false
|
|
247
|
+
isTestImpactAnalysisDisabled = false
|
|
248
|
+
}
|
|
249
|
+
|
|
205
250
|
/**
|
|
206
|
-
*
|
|
251
|
+
* Returns the file path from Vitest's version-dependent test specification shape.
|
|
207
252
|
*
|
|
208
|
-
* @param {
|
|
209
|
-
* @returns {string}
|
|
253
|
+
* @param {unknown} testSpecification
|
|
254
|
+
* @returns {string|undefined}
|
|
210
255
|
*/
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
256
|
+
function getTestSpecificationFilepath (testSpecification) {
|
|
257
|
+
const testFile = Array.isArray(testSpecification) ? testSpecification[1] : testSpecification
|
|
258
|
+
return testFile?.moduleId || testFile?.filepath || (typeof testFile === 'string' ? testFile : undefined)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Returns the normalized suite path and absolute path for a Vitest test specification.
|
|
263
|
+
*
|
|
264
|
+
* @param {unknown} testSpecification
|
|
265
|
+
* @returns {{ testSuite: string, testSuiteAbsolutePath: string }|undefined}
|
|
266
|
+
*/
|
|
267
|
+
function getTestSpecificationSuite (testSpecification) {
|
|
268
|
+
const testFilepath = getTestSpecificationFilepath(testSpecification)
|
|
269
|
+
if (!testFilepath) return
|
|
270
|
+
|
|
271
|
+
const testSuiteAbsolutePath = path.isAbsolute(testFilepath)
|
|
272
|
+
? realpath(testFilepath)
|
|
273
|
+
: realpath(path.join(tiaRepositoryRoot, testFilepath))
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
testSuite: getTestSuitePath(testSuiteAbsolutePath, tiaRepositoryRoot),
|
|
277
|
+
testSuiteAbsolutePath,
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Returns suites that Vitest selected for typechecking.
|
|
283
|
+
*
|
|
284
|
+
* @param {unknown[]} testSpecifications
|
|
285
|
+
* @returns {Set<string>}
|
|
286
|
+
*/
|
|
287
|
+
function getTypecheckTestSuites (testSpecifications) {
|
|
288
|
+
const typecheckTestSuites = new Set()
|
|
289
|
+
|
|
290
|
+
for (const testSpecification of testSpecifications) {
|
|
291
|
+
if (getTestSpecificationPool(testSpecification) !== 'typescript') continue
|
|
292
|
+
|
|
293
|
+
const testSuite = getTestSpecificationSuite(testSpecification)?.testSuite
|
|
294
|
+
if (testSuite) {
|
|
295
|
+
typecheckTestSuites.add(testSuite)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return typecheckTestSuites
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Removes suites selected by TIA and propagates suite metadata to Vitest workers.
|
|
304
|
+
*
|
|
305
|
+
* @param {object} ctx
|
|
306
|
+
* @param {unknown[]} testSpecifications
|
|
307
|
+
* @param {string} frameworkVersion
|
|
308
|
+
* @returns {unknown[]}
|
|
309
|
+
*/
|
|
310
|
+
function applySuiteSkipping (ctx, testSpecifications, frameworkVersion) {
|
|
311
|
+
if (!Array.isArray(testSpecifications)) {
|
|
312
|
+
setProvidedContext(ctx, {
|
|
313
|
+
_ddIsCodeCoverageEnabled: isCodeCoverageEnabled,
|
|
314
|
+
}, 'Could not send TIA configuration to workers.')
|
|
315
|
+
return testSpecifications
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (testSpecifications.length > 0) {
|
|
319
|
+
hasSelectedSuites = true
|
|
320
|
+
}
|
|
321
|
+
if (!isSuitesSkippingEnabled) {
|
|
322
|
+
if (testSpecifications.length > 0) {
|
|
323
|
+
hasRunnableSuites = true
|
|
324
|
+
}
|
|
325
|
+
areAllSuitesSkipped = hasSelectedSuites && !hasRunnableSuites
|
|
326
|
+
setProvidedContext(ctx, {
|
|
327
|
+
_ddIsCodeCoverageEnabled: isCodeCoverageEnabled,
|
|
328
|
+
}, 'Could not send TIA configuration to workers.')
|
|
329
|
+
return testSpecifications
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
resetAppliedSuiteSkippingState()
|
|
333
|
+
const skippableSuiteSet = new Set(skippableSuites.map(testSuite => testSuite.replaceAll('\\', '/')))
|
|
334
|
+
const typecheckTestSuites = getTypecheckTestSuites(testSpecifications)
|
|
335
|
+
const currentSkippedSuites = []
|
|
336
|
+
const testSpecificationsToRun = []
|
|
337
|
+
|
|
338
|
+
for (const testSpecification of testSpecifications) {
|
|
339
|
+
const testSpecificationSuite = getTestSpecificationSuite(testSpecification)
|
|
340
|
+
if (!testSpecificationSuite) {
|
|
341
|
+
testSpecificationsToRun.push(testSpecification)
|
|
342
|
+
continue
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const { testSuite, testSuiteAbsolutePath } = testSpecificationSuite
|
|
346
|
+
const shouldSkip = !typecheckTestSuites.has(testSuite) && skippableSuiteSet.has(testSuite)
|
|
347
|
+
const isUnskippable = isMarkedAsUnskippable({ path: testSuiteAbsolutePath })
|
|
348
|
+
|
|
349
|
+
if (isUnskippable) {
|
|
350
|
+
unskippableSuites[testSuite] = true
|
|
351
|
+
hasUnskippableSuites = true
|
|
352
|
+
if (shouldSkip) {
|
|
353
|
+
forcedToRunSuites[testSuite] = true
|
|
354
|
+
hasForcedToRunSuites = true
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (shouldSkip && !isUnskippable) {
|
|
359
|
+
skippedSuites.push(testSuite)
|
|
360
|
+
currentSkippedSuites.push(testSuite)
|
|
361
|
+
} else {
|
|
362
|
+
testSpecificationsToRun.push(testSpecification)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
setProvidedContext(ctx, {
|
|
367
|
+
_ddIsCodeCoverageEnabled: isCodeCoverageEnabled,
|
|
368
|
+
_ddItrCorrelationId: itrCorrelationId,
|
|
369
|
+
_ddUnskippableSuites: unskippableSuites,
|
|
370
|
+
_ddForcedToRunSuites: forcedToRunSuites,
|
|
371
|
+
}, 'Could not send TIA configuration to workers.')
|
|
372
|
+
|
|
373
|
+
if (currentSkippedSuites.length) {
|
|
374
|
+
itrSkippedSuitesCh.publish({ skippedSuites: currentSkippedSuites, frameworkVersion })
|
|
375
|
+
}
|
|
376
|
+
if (testSpecificationsToRun.length > 0) {
|
|
377
|
+
hasRunnableSuites = true
|
|
378
|
+
}
|
|
379
|
+
areAllSuitesSkipped = hasSelectedSuites && !hasRunnableSuites
|
|
380
|
+
if (testSpecifications.length > 0 && testSpecificationsToRun.length === 0) {
|
|
381
|
+
const config = safeConfig(ctx)
|
|
382
|
+
if (config) {
|
|
383
|
+
config.passWithNoTests = true
|
|
384
|
+
}
|
|
216
385
|
}
|
|
386
|
+
|
|
387
|
+
return testSpecificationsToRun
|
|
217
388
|
}
|
|
218
389
|
|
|
219
390
|
/**
|
|
@@ -371,13 +542,14 @@ function resetLibraryConfig () {
|
|
|
371
542
|
isFlakyTestRetriesEnabled = false
|
|
372
543
|
flakyTestRetriesCount = 0
|
|
373
544
|
isEarlyFlakeDetectionEnabled = false
|
|
374
|
-
|
|
375
|
-
earlyFlakeDetectionSlowTestRetries = {}
|
|
545
|
+
earlyFlakeDetectionRetryPolicy = EMPTY_EFD_RETRY_POLICY
|
|
376
546
|
isEarlyFlakeDetectionFaulty = false
|
|
377
547
|
isDiEnabled = false
|
|
378
548
|
isKnownTestsEnabled = false
|
|
379
549
|
isTestManagementTestsEnabled = false
|
|
380
550
|
isImpactedTestsEnabled = false
|
|
551
|
+
isCodeCoverageEnabled = false
|
|
552
|
+
isSuitesSkippingEnabled = false
|
|
381
553
|
testManagementAttemptToFixRetries = 0
|
|
382
554
|
}
|
|
383
555
|
|
|
@@ -385,22 +557,22 @@ function applyLibraryConfig (libraryConfig) {
|
|
|
385
557
|
isFlakyTestRetriesEnabled = libraryConfig.isFlakyTestRetriesEnabled
|
|
386
558
|
flakyTestRetriesCount = libraryConfig.flakyTestRetriesCount
|
|
387
559
|
isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
388
|
-
|
|
389
|
-
earlyFlakeDetectionSlowTestRetries = libraryConfig.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
560
|
+
earlyFlakeDetectionRetryPolicy = libraryConfig.earlyFlakeDetectionRetryPolicy ?? EMPTY_EFD_RETRY_POLICY
|
|
390
561
|
isEarlyFlakeDetectionFaulty = false
|
|
391
562
|
isDiEnabled = libraryConfig.isDiEnabled
|
|
392
563
|
isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
393
564
|
isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
394
565
|
testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
|
|
395
566
|
isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
|
|
567
|
+
isCodeCoverageEnabled = libraryConfig.isItrEnabled && libraryConfig.isCodeCoverageEnabled
|
|
568
|
+
isSuitesSkippingEnabled = libraryConfig.isItrEnabled && libraryConfig.isSuitesSkippingEnabled
|
|
396
569
|
}
|
|
397
570
|
|
|
398
571
|
function resetMainProcessProvidedContext (ctx) {
|
|
399
572
|
setProvidedContext(ctx, {
|
|
400
573
|
_ddIsDiEnabled: false,
|
|
401
574
|
_ddIsEarlyFlakeDetectionEnabled: false,
|
|
402
|
-
|
|
403
|
-
_ddEarlyFlakeDetectionSlowTestRetries: {},
|
|
575
|
+
_ddEarlyFlakeDetectionRetryPolicy: EMPTY_EFD_RETRY_POLICY,
|
|
404
576
|
_ddIsFlakyTestRetriesEnabled: false,
|
|
405
577
|
_ddFlakyTestRetriesCount: 0,
|
|
406
578
|
_ddFlakyTestRetriesIncludesUnnamedProject: false,
|
|
@@ -410,6 +582,10 @@ function resetMainProcessProvidedContext (ctx) {
|
|
|
410
582
|
_ddIsTestManagementTestsEnabled: false,
|
|
411
583
|
_ddTestManagementAttemptToFixRetries: 0,
|
|
412
584
|
_ddTestPropertiesByFilepath: {},
|
|
585
|
+
_ddIsCodeCoverageEnabled: false,
|
|
586
|
+
_ddItrCorrelationId: undefined,
|
|
587
|
+
_ddUnskippableSuites: {},
|
|
588
|
+
_ddForcedToRunSuites: {},
|
|
413
589
|
}, 'Could not reset Test Optimization context for workers.')
|
|
414
590
|
}
|
|
415
591
|
|
|
@@ -432,13 +608,17 @@ async function runMainProcessSetup (
|
|
|
432
608
|
frameworkVersion,
|
|
433
609
|
testSpecifications,
|
|
434
610
|
shouldInstallNoWorkerInit,
|
|
435
|
-
shouldInstallBrowserReporter
|
|
611
|
+
shouldInstallBrowserReporter,
|
|
612
|
+
disableTestImpactAnalysis
|
|
436
613
|
) {
|
|
437
614
|
if (!testSessionFinishCh.hasSubscribers) {
|
|
438
615
|
return
|
|
439
616
|
}
|
|
440
617
|
|
|
618
|
+
resetSuiteSkippingRunState()
|
|
441
619
|
isVitestBrowserModeActive ||= shouldInstallBrowserReporter
|
|
620
|
+
isTestImpactAnalysisDisabled =
|
|
621
|
+
disableTestImpactAnalysis || shouldInstallNoWorkerInit || isVitestBrowserModeActive
|
|
442
622
|
let repositoryRoot = process.cwd()
|
|
443
623
|
let testSessionConfiguration
|
|
444
624
|
let testFilepaths
|
|
@@ -464,6 +644,7 @@ async function runMainProcessSetup (
|
|
|
464
644
|
requestErrorTags: receivedRequestErrorTags = {},
|
|
465
645
|
} = await getChannelPromise(libraryConfigurationCh, {
|
|
466
646
|
frameworkVersion,
|
|
647
|
+
disableTestImpactAnalysis: isTestImpactAnalysisDisabled,
|
|
467
648
|
isVitestNoWorkerInitActive: shouldInstallNoWorkerInit || isVitestBrowserModeActive,
|
|
468
649
|
})
|
|
469
650
|
requestErrorTags = receivedRequestErrorTags
|
|
@@ -476,6 +657,8 @@ async function runMainProcessSetup (
|
|
|
476
657
|
requestErrorTags = {}
|
|
477
658
|
resetLibraryConfig()
|
|
478
659
|
}
|
|
660
|
+
isSessionCodeCoverageEnabled ||= isCodeCoverageEnabled
|
|
661
|
+
isSessionSuitesSkippingEnabled ||= isSuitesSkippingEnabled
|
|
479
662
|
|
|
480
663
|
resetMainProcessProvidedContext(ctx)
|
|
481
664
|
|
|
@@ -503,19 +686,33 @@ async function runMainProcessSetup (
|
|
|
503
686
|
}, 'Could not send test session configuration to workers.')
|
|
504
687
|
}
|
|
505
688
|
}
|
|
689
|
+
tiaRepositoryRoot = realpath(repositoryRoot)
|
|
506
690
|
|
|
507
691
|
const {
|
|
508
692
|
knownTestsResponse,
|
|
693
|
+
skippableSuitesResponse,
|
|
509
694
|
testManagementTestsResponse,
|
|
510
695
|
} = await getTestOptimizationRequestResults({
|
|
511
696
|
isKnownTestsEnabled,
|
|
697
|
+
isSuitesSkippingEnabled,
|
|
512
698
|
isTestManagementTestsEnabled,
|
|
513
699
|
getKnownTests: () => getChannelPromise(knownTestsCh),
|
|
700
|
+
getSkippableSuites: () => getChannelPromise(skippableSuitesCh),
|
|
514
701
|
getTestManagementTests: () => getChannelPromise(testManagementTestsCh),
|
|
515
702
|
})
|
|
516
703
|
mergeRequestErrorTags(knownTestsResponse)
|
|
704
|
+
mergeRequestErrorTags(skippableSuitesResponse)
|
|
517
705
|
mergeRequestErrorTags(testManagementTestsResponse)
|
|
518
706
|
|
|
707
|
+
if (isSuitesSkippingEnabled) {
|
|
708
|
+
const currentSkippableSuitesResponse = skippableSuitesResponse ||
|
|
709
|
+
await getChannelPromise(skippableSuitesCh)
|
|
710
|
+
if (!currentSkippableSuitesResponse?.err) {
|
|
711
|
+
skippableSuites = currentSkippableSuitesResponse.skippableSuites || []
|
|
712
|
+
itrCorrelationId = currentSkippableSuitesResponse.itrCorrelationId
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
519
716
|
const flakyTestRetriesConfiguration = configureFlakyTestRetries(ctx, testSpecifications)
|
|
520
717
|
if (flakyTestRetriesConfiguration) {
|
|
521
718
|
setProvidedContext(ctx, {
|
|
@@ -552,9 +749,7 @@ async function runMainProcessSetup (
|
|
|
552
749
|
setProvidedContext(ctx, {
|
|
553
750
|
_ddIsKnownTestsEnabled: isKnownTestsEnabled,
|
|
554
751
|
_ddIsEarlyFlakeDetectionEnabled: isEarlyFlakeDetectionEnabled,
|
|
555
|
-
|
|
556
|
-
getConfiguredEfdRetryCount(earlyFlakeDetectionSlowTestRetries, earlyFlakeDetectionNumRetries),
|
|
557
|
-
_ddEarlyFlakeDetectionSlowTestRetries: earlyFlakeDetectionSlowTestRetries,
|
|
752
|
+
_ddEarlyFlakeDetectionRetryPolicy: earlyFlakeDetectionRetryPolicy,
|
|
558
753
|
}, 'Could not send known tests to workers so Early Flake Detection will not work.')
|
|
559
754
|
}
|
|
560
755
|
}
|
|
@@ -637,7 +832,6 @@ async function runMainProcessSetup (
|
|
|
637
832
|
testPropertiesByFilepath: testPropertiesByFilepath || {},
|
|
638
833
|
testSessionConfiguration,
|
|
639
834
|
}, {
|
|
640
|
-
getConfiguredEfdRetryCount,
|
|
641
835
|
shouldReportTestModule: shouldInstallBrowserReporter ? isBrowserTestModule : undefined,
|
|
642
836
|
state: getNoWorkerInitState(),
|
|
643
837
|
})
|
|
@@ -651,8 +845,7 @@ async function runMainProcessSetup (
|
|
|
651
845
|
function getNoWorkerInitState () {
|
|
652
846
|
return {
|
|
653
847
|
attemptToFixExecutions,
|
|
654
|
-
|
|
655
|
-
earlyFlakeDetectionSlowTestRetries,
|
|
848
|
+
earlyFlakeDetectionRetryPolicy,
|
|
656
849
|
isEarlyFlakeDetectionEnabled,
|
|
657
850
|
isEarlyFlakeDetectionFaulty,
|
|
658
851
|
isFlakyTestRetriesEnabled,
|
|
@@ -663,10 +856,20 @@ function getNoWorkerInitState () {
|
|
|
663
856
|
}
|
|
664
857
|
}
|
|
665
858
|
|
|
666
|
-
function ensureMainProcessSetup (
|
|
859
|
+
function ensureMainProcessSetup (
|
|
860
|
+
ctx,
|
|
861
|
+
frameworkVersion,
|
|
862
|
+
testSpecifications,
|
|
863
|
+
shouldDeactivateOnFallback = false,
|
|
864
|
+
forceDisableTestImpactAnalysis = false
|
|
865
|
+
) {
|
|
667
866
|
const shouldInstallNoWorkerInit = shouldUseNoWorkerInit(ctx, frameworkVersion, testSpecifications)
|
|
668
867
|
const shouldInstallBrowserReporter = shouldUseBrowserReporter(frameworkVersion, testSpecifications)
|
|
669
868
|
const shouldInstallMainReporter = shouldInstallNoWorkerInit || shouldInstallBrowserReporter
|
|
869
|
+
const disableTestImpactAnalysis =
|
|
870
|
+
forceDisableTestImpactAnalysis ||
|
|
871
|
+
safeConfig(ctx)?.watch === true ||
|
|
872
|
+
hasOnlyTypecheckTestSpecifications(testSpecifications)
|
|
670
873
|
const specificationsKey = getTestSpecificationsKey(testSpecifications)
|
|
671
874
|
let setupState = mainProcessSetupStates.get(ctx)
|
|
672
875
|
if (shouldDeactivateOnFallback && setupState?.shouldInstallMainReporter && !shouldInstallMainReporter) {
|
|
@@ -676,7 +879,8 @@ function ensureMainProcessSetup (ctx, frameworkVersion, testSpecifications, shou
|
|
|
676
879
|
!setupState ||
|
|
677
880
|
setupState.specificationsKey !== specificationsKey ||
|
|
678
881
|
setupState.shouldInstallNoWorkerInit !== shouldInstallNoWorkerInit ||
|
|
679
|
-
setupState.shouldInstallBrowserReporter !== shouldInstallBrowserReporter
|
|
882
|
+
setupState.shouldInstallBrowserReporter !== shouldInstallBrowserReporter ||
|
|
883
|
+
setupState.disableTestImpactAnalysis !== disableTestImpactAnalysis
|
|
680
884
|
) {
|
|
681
885
|
setupState = {
|
|
682
886
|
setupPromise: runMainProcessSetup(
|
|
@@ -684,8 +888,10 @@ function ensureMainProcessSetup (ctx, frameworkVersion, testSpecifications, shou
|
|
|
684
888
|
frameworkVersion,
|
|
685
889
|
testSpecifications,
|
|
686
890
|
shouldInstallNoWorkerInit,
|
|
687
|
-
shouldInstallBrowserReporter
|
|
891
|
+
shouldInstallBrowserReporter,
|
|
892
|
+
disableTestImpactAnalysis
|
|
688
893
|
),
|
|
894
|
+
disableTestImpactAnalysis,
|
|
689
895
|
shouldInstallBrowserReporter,
|
|
690
896
|
shouldInstallMainReporter,
|
|
691
897
|
shouldInstallNoWorkerInit,
|
|
@@ -850,7 +1056,11 @@ function safeWorkspaceProject (ctx) {
|
|
|
850
1056
|
|
|
851
1057
|
function getSortWrapper (sort, frameworkVersion) {
|
|
852
1058
|
return async function () {
|
|
853
|
-
|
|
1059
|
+
if (!activeRunFilesContexts.has(this.ctx)) {
|
|
1060
|
+
const testSpecifications = arguments[0]
|
|
1061
|
+
await ensureMainProcessSetup(this.ctx, frameworkVersion, testSpecifications)
|
|
1062
|
+
arguments[0] = applySuiteSkipping(this.ctx, testSpecifications, frameworkVersion)
|
|
1063
|
+
}
|
|
854
1064
|
return sort.apply(this, arguments)
|
|
855
1065
|
}
|
|
856
1066
|
}
|
|
@@ -874,18 +1084,30 @@ function getFinishWrapper (exitOrClose) {
|
|
|
874
1084
|
}
|
|
875
1085
|
|
|
876
1086
|
const flushPromise = getChannelPromise(testSessionFinishCh, {
|
|
877
|
-
status: getSessionStatus(this.state),
|
|
1087
|
+
status: areAllSuitesSkipped ? 'skip' : getSessionStatus(this.state),
|
|
878
1088
|
testCodeCoverageLinesTotal,
|
|
879
1089
|
error,
|
|
880
1090
|
isEarlyFlakeDetectionEnabled,
|
|
881
1091
|
isEarlyFlakeDetectionFaulty,
|
|
882
1092
|
isTestManagementTestsEnabled,
|
|
1093
|
+
isCodeCoverageEnabled: isSessionCodeCoverageEnabled,
|
|
1094
|
+
isSuitesSkippingEnabled: isSessionSuitesSkippingEnabled,
|
|
1095
|
+
isSuitesSkipped: skippedSuites.length > 0,
|
|
1096
|
+
numSkippedSuites: skippedSuites.length,
|
|
1097
|
+
hasUnskippableSuites,
|
|
1098
|
+
hasForcedToRunSuites,
|
|
883
1099
|
requestErrorTags,
|
|
884
1100
|
vitestPool,
|
|
885
1101
|
isVitestNoWorkerInitActive: isVitestNoWorkerInitActive || isVitestBrowserModeActive,
|
|
886
1102
|
})
|
|
887
1103
|
|
|
888
|
-
|
|
1104
|
+
const shouldLogAllTestsSkippedMessage = areAllSuitesSkipped && !hasLoggedAllTestsSkippedMessage
|
|
1105
|
+
hasLoggedAllTestsSkippedMessage ||= shouldLogAllTestsSkippedMessage
|
|
1106
|
+
logTestOptimizationSummary({
|
|
1107
|
+
attemptToFixExecutions,
|
|
1108
|
+
newTestsWithDynamicNames,
|
|
1109
|
+
extraSections: shouldLogAllTestsSkippedMessage ? [TEST_IMPACT_ANALYSIS_ALL_TESTS_SKIPPED_MESSAGE] : [],
|
|
1110
|
+
})
|
|
889
1111
|
|
|
890
1112
|
await flushPromise
|
|
891
1113
|
|
|
@@ -905,6 +1127,7 @@ function getCliOrStartVitestWrapper (frameworkVersion) {
|
|
|
905
1127
|
return oldCliOrStartVitest.apply(this, args)
|
|
906
1128
|
}
|
|
907
1129
|
isSessionStarted = true
|
|
1130
|
+
resetSessionSuiteSkippingState()
|
|
908
1131
|
testSessionStartCh.publish({ command: getTestCommand(), frameworkVersion })
|
|
909
1132
|
return oldCliOrStartVitest.apply(this, args)
|
|
910
1133
|
}
|
|
@@ -953,6 +1176,21 @@ function getTestSpecificationPool (testSpecification) {
|
|
|
953
1176
|
testSpecification?.pool
|
|
954
1177
|
}
|
|
955
1178
|
|
|
1179
|
+
/**
|
|
1180
|
+
* Detect whether Vitest selected only TypeScript typecheck specifications.
|
|
1181
|
+
*
|
|
1182
|
+
* @param {unknown} testSpecifications
|
|
1183
|
+
* @returns {boolean}
|
|
1184
|
+
*/
|
|
1185
|
+
function hasOnlyTypecheckTestSpecifications (testSpecifications) {
|
|
1186
|
+
if (!Array.isArray(testSpecifications) || testSpecifications.length === 0) return false
|
|
1187
|
+
|
|
1188
|
+
for (const testSpecification of testSpecifications) {
|
|
1189
|
+
if (getTestSpecificationPool(testSpecification) !== 'typescript') return false
|
|
1190
|
+
}
|
|
1191
|
+
return true
|
|
1192
|
+
}
|
|
1193
|
+
|
|
956
1194
|
function isBrowserTestSpecification (testSpecification) {
|
|
957
1195
|
return getTestSpecificationPool(testSpecification) === 'browser' ||
|
|
958
1196
|
isBrowserProject(getTestSpecificationProject(testSpecification))
|
|
@@ -1003,14 +1241,26 @@ function markVitestWorkerEnv (ctx, testSpecifications, shouldSkipWorkerInit = fa
|
|
|
1003
1241
|
}
|
|
1004
1242
|
|
|
1005
1243
|
function wrapVitestRunFiles (Vitest, frameworkVersion) {
|
|
1006
|
-
if (!Vitest?.prototype?.runFiles) {
|
|
1244
|
+
if (!Vitest?.prototype?.runFiles || runFilesWrappedPrototypes.has(Vitest.prototype)) {
|
|
1007
1245
|
return
|
|
1008
1246
|
}
|
|
1247
|
+
runFilesWrappedPrototypes.add(Vitest.prototype)
|
|
1009
1248
|
|
|
1010
1249
|
shimmer.wrap(Vitest.prototype, 'runFiles', runFiles => async function (testSpecifications) {
|
|
1250
|
+
if (activeRunFilesContexts.has(this)) {
|
|
1251
|
+
return runFiles.apply(this, arguments)
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1011
1254
|
const shouldSkipWorkerInit = await ensureMainProcessSetup(this, frameworkVersion, testSpecifications, true)
|
|
1012
|
-
|
|
1013
|
-
|
|
1255
|
+
const testSpecificationsToRun = applySuiteSkipping(this, testSpecifications, frameworkVersion)
|
|
1256
|
+
arguments[0] = testSpecificationsToRun
|
|
1257
|
+
markVitestWorkerEnv(this, testSpecificationsToRun, shouldSkipWorkerInit)
|
|
1258
|
+
activeRunFilesContexts.add(this)
|
|
1259
|
+
try {
|
|
1260
|
+
return await runFiles.apply(this, arguments)
|
|
1261
|
+
} finally {
|
|
1262
|
+
activeRunFilesContexts.delete(this)
|
|
1263
|
+
}
|
|
1014
1264
|
})
|
|
1015
1265
|
|
|
1016
1266
|
if (Vitest.prototype.collectTests) {
|
|
@@ -1219,13 +1469,34 @@ function reportTypecheckTest (task, testSuiteAbsolutePath, providedContext) {
|
|
|
1219
1469
|
const isModified = testProperties.isModified === true
|
|
1220
1470
|
const isSkippedByTestManagement = !isAttemptToFix && isDisabled
|
|
1221
1471
|
const status = getTypecheckTaskStatus(task)
|
|
1472
|
+
const summaryStatus = isSkippedByTestManagement ? 'skip' : status
|
|
1473
|
+
|
|
1474
|
+
recordTestManagementExecution({
|
|
1475
|
+
testSuite: testProperties.testSuite,
|
|
1476
|
+
testName,
|
|
1477
|
+
status: summaryStatus,
|
|
1478
|
+
isAttemptToFix,
|
|
1479
|
+
isDisabled,
|
|
1480
|
+
isQuarantined,
|
|
1481
|
+
})
|
|
1482
|
+
if (isAttemptToFix) {
|
|
1483
|
+
recordAttemptToFixExecution(attemptToFixExecutions, {
|
|
1484
|
+
testSuite: testProperties.testSuite,
|
|
1485
|
+
testName,
|
|
1486
|
+
status: summaryStatus,
|
|
1487
|
+
isDisabled,
|
|
1488
|
+
isQuarantined,
|
|
1489
|
+
})
|
|
1490
|
+
}
|
|
1222
1491
|
|
|
1223
1492
|
if (status === 'skip' || isSkippedByTestManagement) {
|
|
1224
1493
|
testSkipCh.publish({
|
|
1225
1494
|
testName,
|
|
1226
1495
|
testSuiteAbsolutePath,
|
|
1227
1496
|
isNew: testProperties.isNew,
|
|
1497
|
+
isAttemptToFix,
|
|
1228
1498
|
isDisabled,
|
|
1499
|
+
isQuarantined,
|
|
1229
1500
|
})
|
|
1230
1501
|
updateTypecheckTaskResultForTestManagement(task, status, { isAttemptToFix, isDisabled, isQuarantined })
|
|
1231
1502
|
return
|
|
@@ -1272,6 +1543,7 @@ async function reportTypecheckFile (file, sessionConfiguration, frameworkVersion
|
|
|
1272
1543
|
testCommand: sessionConfiguration.testCommand,
|
|
1273
1544
|
repositoryRoot: sessionConfiguration.repositoryRoot,
|
|
1274
1545
|
codeOwnersEntries: sessionConfiguration.codeOwnersEntries,
|
|
1546
|
+
disableTestImpactAnalysis: isTestImpactAnalysisDisabled,
|
|
1275
1547
|
}
|
|
1276
1548
|
testSuiteStartCh.runStores(testSuiteCtx, () => {})
|
|
1277
1549
|
|
|
@@ -1297,8 +1569,18 @@ async function reportTypecheckResults (result, frameworkVersion, ctx, typechecke
|
|
|
1297
1569
|
if (!testSuiteFinishCh.hasSubscribers) return
|
|
1298
1570
|
if (!Array.isArray(result?.files)) return
|
|
1299
1571
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1572
|
+
const setupState = ctx && mainProcessSetupStates.get(ctx)
|
|
1573
|
+
if (
|
|
1574
|
+
ctx &&
|
|
1575
|
+
(!setupState || setupState.shouldInstallMainReporter || setupState.disableTestImpactAnalysis)
|
|
1576
|
+
) {
|
|
1577
|
+
await ensureMainProcessSetup(
|
|
1578
|
+
ctx,
|
|
1579
|
+
frameworkVersion,
|
|
1580
|
+
result.files,
|
|
1581
|
+
false,
|
|
1582
|
+
!setupState || setupState.disableTestImpactAnalysis
|
|
1583
|
+
)
|
|
1302
1584
|
}
|
|
1303
1585
|
const providedContext = getMainProcessProvidedContext(ctx)
|
|
1304
1586
|
const sessionConfiguration = testSessionConfigurationCh.hasSubscribers
|
|
@@ -1489,11 +1771,21 @@ function handleWorkerReport (interprocessCode, data) {
|
|
|
1489
1771
|
return true
|
|
1490
1772
|
}
|
|
1491
1773
|
|
|
1774
|
+
if (interprocessCode === VITEST_WORKER_COVERAGE_PAYLOAD_CODE) {
|
|
1775
|
+
workerReportCoverageCh.publish(data)
|
|
1776
|
+
return true
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1492
1779
|
if (interprocessCode === VITEST_WORKER_LOGS_PAYLOAD_CODE) {
|
|
1493
1780
|
workerReportLogsCh.publish(data)
|
|
1494
1781
|
return true
|
|
1495
1782
|
}
|
|
1496
1783
|
|
|
1784
|
+
if (interprocessCode === VITEST_WORKER_TELEMETRY_PAYLOAD_CODE) {
|
|
1785
|
+
workerReportTelemetryCh.publish(data)
|
|
1786
|
+
return true
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1497
1789
|
return false
|
|
1498
1790
|
}
|
|
1499
1791
|
|
|
@@ -1557,9 +1849,9 @@ addHook({
|
|
|
1557
1849
|
name: 'vitest',
|
|
1558
1850
|
versions: ['>=1.6.0 <2.0.0'],
|
|
1559
1851
|
filePattern: 'dist/vendor/index.*',
|
|
1560
|
-
}, (vitestPackage) => {
|
|
1852
|
+
}, (vitestPackage, frameworkVersion) => {
|
|
1561
1853
|
if (isReporterPackage(vitestPackage)) {
|
|
1562
|
-
shimmer.wrap(vitestPackage.B.prototype, 'sort', getSortWrapper)
|
|
1854
|
+
shimmer.wrap(vitestPackage.B.prototype, 'sort', sort => getSortWrapper(sort, frameworkVersion))
|
|
1563
1855
|
}
|
|
1564
1856
|
|
|
1565
1857
|
return vitestPackage
|
|
@@ -1569,9 +1861,9 @@ addHook({
|
|
|
1569
1861
|
name: 'vitest',
|
|
1570
1862
|
versions: ['>=2.0.0 <2.0.5'],
|
|
1571
1863
|
filePattern: 'dist/vendor/index.*',
|
|
1572
|
-
}, (vitestPackage) => {
|
|
1864
|
+
}, (vitestPackage, frameworkVersion) => {
|
|
1573
1865
|
if (isReporterPackageNew(vitestPackage)) {
|
|
1574
|
-
shimmer.wrap(vitestPackage.e.prototype, 'sort', getSortWrapper)
|
|
1866
|
+
shimmer.wrap(vitestPackage.e.prototype, 'sort', sort => getSortWrapper(sort, frameworkVersion))
|
|
1575
1867
|
}
|
|
1576
1868
|
|
|
1577
1869
|
return vitestPackage
|
|
@@ -1581,9 +1873,9 @@ addHook({
|
|
|
1581
1873
|
name: 'vitest',
|
|
1582
1874
|
versions: ['>=2.0.5 <2.1.0'],
|
|
1583
1875
|
filePattern: 'dist/chunks/index.*',
|
|
1584
|
-
}, (vitestPackage) => {
|
|
1876
|
+
}, (vitestPackage, frameworkVersion) => {
|
|
1585
1877
|
if (isReporterPackageNewest(vitestPackage)) {
|
|
1586
|
-
shimmer.wrap(vitestPackage.h.prototype, 'sort', getSortWrapper)
|
|
1878
|
+
shimmer.wrap(vitestPackage.h.prototype, 'sort', sort => getSortWrapper(sort, frameworkVersion))
|
|
1587
1879
|
}
|
|
1588
1880
|
|
|
1589
1881
|
return vitestPackage
|
|
@@ -1605,8 +1897,12 @@ addHook({
|
|
|
1605
1897
|
name: 'vitest',
|
|
1606
1898
|
versions: ['>=2.1.0 <3.0.0'],
|
|
1607
1899
|
filePattern: 'dist/chunks/RandomSequencer.*',
|
|
1608
|
-
}, (randomSequencerPackage) => {
|
|
1609
|
-
shimmer.wrap(
|
|
1900
|
+
}, (randomSequencerPackage, frameworkVersion) => {
|
|
1901
|
+
shimmer.wrap(
|
|
1902
|
+
randomSequencerPackage.B.prototype,
|
|
1903
|
+
'sort',
|
|
1904
|
+
sort => getSortWrapper(sort, frameworkVersion)
|
|
1905
|
+
)
|
|
1610
1906
|
return randomSequencerPackage
|
|
1611
1907
|
})
|
|
1612
1908
|
|
|
@@ -1614,10 +1910,14 @@ addHook({
|
|
|
1614
1910
|
name: 'vitest',
|
|
1615
1911
|
versions: ['>=3.0.9'],
|
|
1616
1912
|
filePattern: 'dist/chunks/coverage.*',
|
|
1617
|
-
}, (coveragePackage) => {
|
|
1913
|
+
}, (coveragePackage, frameworkVersion) => {
|
|
1618
1914
|
const baseSequencer = getBaseSequencerExport(coveragePackage)
|
|
1619
1915
|
if (baseSequencer) {
|
|
1620
|
-
shimmer.wrap(
|
|
1916
|
+
shimmer.wrap(
|
|
1917
|
+
baseSequencer.value.prototype,
|
|
1918
|
+
'sort',
|
|
1919
|
+
sort => getSortWrapper(sort, frameworkVersion)
|
|
1920
|
+
)
|
|
1621
1921
|
}
|
|
1622
1922
|
return coveragePackage
|
|
1623
1923
|
})
|
|
@@ -1626,8 +1926,12 @@ addHook({
|
|
|
1626
1926
|
name: 'vitest',
|
|
1627
1927
|
versions: ['>=3.0.0 <3.0.9'],
|
|
1628
1928
|
filePattern: 'dist/chunks/resolveConfig.*',
|
|
1629
|
-
}, (resolveConfigPackage) => {
|
|
1630
|
-
shimmer.wrap(
|
|
1929
|
+
}, (resolveConfigPackage, frameworkVersion) => {
|
|
1930
|
+
shimmer.wrap(
|
|
1931
|
+
resolveConfigPackage.B.prototype,
|
|
1932
|
+
'sort',
|
|
1933
|
+
sort => getSortWrapper(sort, frameworkVersion)
|
|
1934
|
+
)
|
|
1631
1935
|
return resolveConfigPackage
|
|
1632
1936
|
})
|
|
1633
1937
|
|