sxy-test-runner 2.5.0 → 2.5.2

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.
Files changed (62) hide show
  1. package/AGENTS.md +9 -1
  2. package/dist/cli/cliTypes.d.ts +1 -0
  3. package/dist/cli/cliTypes.js.map +1 -1
  4. package/dist/cli/init.js +3 -0
  5. package/dist/cli/init.js.map +1 -1
  6. package/dist/cli/lib/addBasePath.js +1 -1
  7. package/dist/cli/lib/addBasePath.js.map +1 -1
  8. package/dist/cli/lib/buildDependencyTrees.d.ts +1 -1
  9. package/dist/cli/lib/buildDependencyTrees.js +2 -2
  10. package/dist/cli/lib/buildDependencyTrees.js.map +1 -1
  11. package/dist/cli/lib/defaultConfig.js +1 -0
  12. package/dist/cli/lib/defaultConfig.js.map +1 -1
  13. package/dist/cli/lib/failureEntries.js +6 -3
  14. package/dist/cli/lib/failureEntries.js.map +1 -1
  15. package/dist/cli/lib/filter.js +2 -2
  16. package/dist/cli/lib/filter.js.map +1 -1
  17. package/dist/cli/lib/findTestFiles.js +1 -1
  18. package/dist/cli/lib/findTestFiles.js.map +1 -1
  19. package/dist/cli/lib/parseCommandLineArguments.js +20 -8
  20. package/dist/cli/lib/parseCommandLineArguments.js.map +1 -1
  21. package/dist/cli/lib/parseDescribe.js +1 -1
  22. package/dist/cli/lib/parseDescribe.js.map +1 -1
  23. package/dist/cli/lib/runDescribe.js +1 -1
  24. package/dist/cli/lib/runDescribe.js.map +1 -1
  25. package/dist/cli/lib/runDescribeRun.js +1 -1
  26. package/dist/cli/lib/runDescribeRun.js.map +1 -1
  27. package/dist/cli/lib/runIt.js +1 -1
  28. package/dist/cli/lib/runIt.js.map +1 -1
  29. package/dist/cli/lib/runTests.js +9 -188
  30. package/dist/cli/lib/runTests.js.map +1 -1
  31. package/dist/cli/lib/showFailuresColorized.d.ts +2 -0
  32. package/dist/cli/lib/showFailuresColorized.js +52 -0
  33. package/dist/cli/lib/showFailuresColorized.js.map +1 -0
  34. package/dist/cli/lib/showTestFileResult.d.ts +7 -0
  35. package/dist/cli/lib/{showTestResult.js → showTestFileResult.js} +15 -9
  36. package/dist/cli/lib/showTestFileResult.js.map +1 -0
  37. package/dist/cli/lib/showTestResultsSummary.d.ts +8 -0
  38. package/dist/cli/lib/showTestResultsSummary.js +213 -0
  39. package/dist/cli/lib/showTestResultsSummary.js.map +1 -0
  40. package/dist/cli/lib/timeProfiler.d.ts +3 -0
  41. package/dist/cli/lib/{timeProfier.js → timeProfiler.js} +1 -1
  42. package/dist/cli/lib/timeProfiler.js.map +1 -0
  43. package/dist/cli/lib/validateConfig.js +3 -0
  44. package/dist/cli/lib/validateConfig.js.map +1 -1
  45. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +3 -3
  46. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js.map +1 -1
  47. package/dist/cli/lib/watchFilesNodeWatch.js +3 -3
  48. package/dist/cli/lib/watchFilesNodeWatch.js.map +1 -1
  49. package/dist/cli/once.js +4 -2
  50. package/dist/cli/once.js.map +1 -1
  51. package/dist/cli/watch.d.ts +1 -1
  52. package/dist/cli/watch.js +8 -5
  53. package/dist/cli/watch.js.map +1 -1
  54. package/dist/packages/timeProfiler.d.ts +1 -1
  55. package/dist/packages/timeProfiler.js.map +1 -1
  56. package/dist/types.d.ts +1 -0
  57. package/dist/types.js.map +1 -1
  58. package/package.json +2 -3
  59. package/dist/cli/lib/showTestResult.d.ts +0 -4
  60. package/dist/cli/lib/showTestResult.js.map +0 -1
  61. package/dist/cli/lib/timeProfier.d.ts +0 -3
  62. package/dist/cli/lib/timeProfier.js.map +0 -1
@@ -0,0 +1,213 @@
1
+ import { count } from 'sxy-lib/objects.js';
2
+ import chalk from '../../packages/chalk.js';
3
+ import figures from '../../packages/figures.js';
4
+ import { agentDone, agentFailure } from './agentReport.js';
5
+ import { failureEntries } from './failureEntries.js';
6
+ import { failureLines } from './failureLines.js';
7
+ //import { showFailures } from './showFailures.js'
8
+ import { showTestFileResult } from './showTestFileResult.js';
9
+ import { showTestLoadingError } from './showTestLoadingError.js';
10
+ import { writeStatusFile, statusCodes } from './statusFile.js';
11
+ import { out as mainOut } from '../../output.js';
12
+ import { timeProfile } from './timeProfiler.js';
13
+ // the summary lines, minus the colouring, for the status file
14
+ function joinPlain(...parts) {
15
+ return parts.filter(part => part !== '').join(' ');
16
+ }
17
+ function plural(count, noun, verb) {
18
+ if (count < 1)
19
+ return '';
20
+ return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`;
21
+ }
22
+ export function showTestResultsSummary(runTestResults, erroringTests, runStartTime, config, runNumber, state, stop, filters, customOut) {
23
+ return timeProfile('show test run result summary', () => {
24
+ const out = customOut ?? mainOut;
25
+ const testsResultsSummary = {
26
+ total: 0,
27
+ passes: 0,
28
+ invalid: 0,
29
+ describesTotal: 0,
30
+ describesPasses: 0,
31
+ describesInvalid: 0,
32
+ itsTotal: 0,
33
+ itsPasses: 0
34
+ // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)
35
+ };
36
+ let describesThrownCount = 0;
37
+ for (const testFile in runTestResults) {
38
+ const runTestResult = runTestResults[testFile];
39
+ if (!runTestResult)
40
+ continue;
41
+ testsResultsSummary.total += +(runTestResult.success !== null);
42
+ testsResultsSummary.passes += +(runTestResult.success ?? false);
43
+ testsResultsSummary.invalid += +(runTestResult.success === null);
44
+ testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total;
45
+ testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes;
46
+ testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid;
47
+ testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal;
48
+ testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses;
49
+ describesThrownCount += runTestResult.describeResults
50
+ .filter(describeResult => describeResult.error !== undefined)
51
+ .length;
52
+ }
53
+ const failedToLoadCount = count(erroringTests);
54
+ testsResultsSummary.total += failedToLoadCount;
55
+ if ((filters.describe !== undefined || filters.it !== undefined)
56
+ && testsResultsSummary.itsTotal === 0
57
+ && failedToLoadCount === 0
58
+ && describesThrownCount === 0) {
59
+ out(chalk.orange('No tests matched the describe/test filters.'));
60
+ const durationMs = new Date().getTime() - runStartTime;
61
+ writeStatusFile(config, statusCodes.couldNotRun, 'no tests matched the describe/test filters', [], durationMs);
62
+ agentDone(config, runNumber, statusCodes.couldNotRun, 'no tests matched the describe/test filters', testsResultsSummary, durationMs, state.failedTestFiles.size);
63
+ return null;
64
+ }
65
+ const allPassed = (testsResultsSummary.passes === testsResultsSummary.total
66
+ && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal
67
+ && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal);
68
+ const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses;
69
+ // a file that would not load, or a describe that threw, has no tests in itsTotal -
70
+ // each counts as one unit on both sides
71
+ const failuresN = failedTestsCount + describesThrownCount + failedToLoadCount;
72
+ const unitsN = testsResultsSummary.itsTotal + describesThrownCount + failedToLoadCount;
73
+ // the originals may have scrolled away on a long run, but past a point repeating
74
+ // them buries the tallies - and when everything failed, they are the whole output already
75
+ const showFailuresSection = config.restateFailures && failuresN > 0 && failuresN < unitsN
76
+ && (failuresN <= 10 || failuresN <= 1.7 * unitsN ** 0.58);
77
+ // the rule is separation enough, without the tallies' wider gap
78
+ out((config.compact || showFailuresSection) ? '' : '\n');
79
+ if (allPassed) {
80
+ out(chalk.mediumgreen(`${figures.tick}`));
81
+ }
82
+ else {
83
+ //showFailures(out, Object.values(runTestResults), erroringTests)
84
+ if (showFailuresSection) {
85
+ const hr = '='.repeat((process.stdout.columns ?? 41) - 1);
86
+ out(hr);
87
+ out('Failures:');
88
+ out(hr);
89
+ for (const test of Object.values(erroringTests))
90
+ showTestLoadingError(config, test, out);
91
+ for (const testResult of Object.values(runTestResults)) {
92
+ if (testResult.success !== false)
93
+ continue;
94
+ showTestFileResult(config, testResult, out, { failuresOnly: true });
95
+ }
96
+ out(config.compact ? '' : '\n');
97
+ }
98
+ out(chalk.mediumred(`${figures.cross}`));
99
+ }
100
+ // number of tests successful
101
+ const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`;
102
+ if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {
103
+ if (testsResultsSummary.itsTotal === 0) {
104
+ out(chalk.grey(`${testsText}`));
105
+ }
106
+ else {
107
+ out(chalk.mediumgreen(`${testsText}`));
108
+ }
109
+ }
110
+ else {
111
+ out(chalk.mediumred(`${testsText}`));
112
+ }
113
+ // number of items successful
114
+ const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`;
115
+ const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)
116
+ ? (testsResultsSummary.describesInvalid === 1)
117
+ ? '(+1 describe without tests)'
118
+ : `(+${testsResultsSummary.describesInvalid} describes without tests)`
119
+ : '';
120
+ const describesThrownPlain = (describesThrownCount >= 1)
121
+ ? (describesThrownCount === 1)
122
+ ? '(1 describe errored)'
123
+ : `(${describesThrownCount} describes errored)`
124
+ : '';
125
+ const describesDetailsText = [
126
+ chalk.mediumred(describesThrownPlain), chalk.grey(invalidDescribesPlain)
127
+ ]
128
+ .filter(text => text !== '')
129
+ .join(' ');
130
+ const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`;
131
+ if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {
132
+ if (testsResultsSummary.describesTotal === 0) {
133
+ out(chalk.grey(`${describesText}`) + describesDetailsSuffix);
134
+ }
135
+ else {
136
+ out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix);
137
+ }
138
+ }
139
+ else {
140
+ out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix);
141
+ }
142
+ // number of test files successful
143
+ const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`;
144
+ const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)
145
+ ? (testsResultsSummary.invalid === 1)
146
+ ? '(+1 file without tests)'
147
+ : `(+${testsResultsSummary.invalid} files without tests)`
148
+ : '';
149
+ const failedToLoadPlain = (failedToLoadCount >= 1)
150
+ ? (failedToLoadCount === 1)
151
+ ? '(1 file failed to load, or errored)'
152
+ : `(${failedToLoadCount} files failed to load, or errored)`
153
+ : '';
154
+ const testFilesDetailsText = [
155
+ chalk.mediumred(failedToLoadPlain), chalk.grey(invalidTestFilesPlain)
156
+ ]
157
+ .filter(text => text !== '')
158
+ .join(' ');
159
+ const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`;
160
+ if (testsResultsSummary.passes === testsResultsSummary.total) {
161
+ if (testsResultsSummary.describesTotal === 0) {
162
+ out(chalk.grey(`${testFilesText}`) + testFilesDetailsSuffix);
163
+ }
164
+ else {
165
+ out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix);
166
+ }
167
+ }
168
+ else {
169
+ out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix);
170
+ }
171
+ // the tallies only cover what ran, so say the run was cut short - otherwise
172
+ // "Tests: 0/1" reads as a one test suite
173
+ const stoppedPlain = (stop.stopped)
174
+ ? 'stopped at the first failure (failFast)'
175
+ : '';
176
+ if (stoppedPlain !== '')
177
+ out(chalk.orange(stoppedPlain));
178
+ const summaryLines = [
179
+ testsText,
180
+ joinPlain(describesText, describesThrownPlain, invalidDescribesPlain),
181
+ joinPlain(testFilesText, failedToLoadPlain, invalidTestFilesPlain),
182
+ ...(stoppedPlain === '') ? [] : [stoppedPlain]
183
+ ];
184
+ const durationMs = new Date().getTime() - runStartTime;
185
+ if (allPassed) {
186
+ writeStatusFile(config, statusCodes.passed, 'all tests passed', summaryLines, durationMs);
187
+ agentDone(config, runNumber, statusCodes.passed, 'all tests passed', testsResultsSummary, durationMs, state.failedTestFiles.size);
188
+ }
189
+ else {
190
+ const abortedFiles = Object.keys(erroringTests);
191
+ // a file that would not load, or a describe that threw, means the run died
192
+ // partway - a different problem from tests that ran and failed
193
+ const aborted = abortedFiles.length > 0 || describesThrownCount > 0;
194
+ const description = ([
195
+ plural(abortedFiles.length, 'test file', 'failed to load or errored'),
196
+ plural(describesThrownCount, 'describe', 'errored'),
197
+ plural(failedTestsCount, 'test', 'failed')
198
+ ].filter(part => part !== '').join(', ') || 'test run failed')
199
+ + ((stop.stopped) ? ', stopped at the first failure' : '');
200
+ const code = (aborted) ? statusCodes.aborted : statusCodes.failed;
201
+ const failures = failureEntries(Object.values(runTestResults), erroringTests);
202
+ writeStatusFile(config, code, description, [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)], durationMs);
203
+ // failures first, so the done line is a complete end of run marker
204
+ for (const failure of failures)
205
+ agentFailure(config, runNumber, failure);
206
+ agentDone(config, runNumber, code, description, testsResultsSummary, durationMs, state.failedTestFiles.size);
207
+ }
208
+ // full success?
209
+ // true/false gets returned to the caller of runTests()
210
+ return allPassed;
211
+ });
212
+ }
213
+ //# sourceMappingURL=showTestResultsSummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"showTestResultsSummary.js","sourceRoot":"","sources":["../../../src/cli/lib/showTestResultsSummary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAS1C,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,kDAAkD;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBA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;gBAAE,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;YACxE,SAAS,CACL,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EACrE,KAAK,CAAC,eAAe,CAAC,IAAI,CAC7B,CAAA;QACL,CAAC;QAED,gBAAgB;QAChB,uDAAuD;QACvD,OAAO,SAAS,CAAA;IACpB,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["\r\nimport { count } from 'sxy-lib/objects.js'\r\n\r\nimport type { FinalConfig, OutFn } from '../../types.js'\r\nimport type { TestExecutionFilters } from '../cliTypes.js'\r\nimport type { TestFile } from './loadTestFile.js'\r\nimport type { ReRunManageState } from './makeWatchRunState.js'\r\nimport type { TestResult } from './runTest.js'\r\nimport type { TestsResultsSummary } from './runTests.js'\r\nimport type { StopSignal } from './stopSignal.js'\r\nimport chalk from '../../packages/chalk.js'\r\nimport figures from '../../packages/figures.js'\r\nimport { agentDone, agentFailure } from './agentReport.js'\r\nimport { failureEntries } from './failureEntries.js'\r\nimport { failureLines } from './failureLines.js'\r\n//import { showFailures } from './showFailures.js'\r\nimport { showTestFileResult } from './showTestFileResult.js'\r\nimport { showTestLoadingError } from './showTestLoadingError.js'\r\nimport { writeStatusFile, statusCodes } from './statusFile.js'\r\nimport { out as mainOut } from '../../output.js'\r\nimport { timeProfile } from './timeProfiler.js'\r\n\r\n\r\n// the summary lines, minus the colouring, for the status file\r\nfunction joinPlain(...parts: string[]): string {\r\n return parts.filter(part => part !== '').join(' ')\r\n}\r\n\r\nfunction plural(count: number, noun: string, verb: string): string {\r\n if (count < 1) return ''\r\n return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`\r\n}\r\n\r\nexport function showTestResultsSummary(\r\n runTestResults: Record<string, TestResult>,\r\n erroringTests: Record<string, TestFile>,\r\n runStartTime: number,\r\n config: FinalConfig,\r\n runNumber: number,\r\n state: ReRunManageState,\r\n stop: StopSignal,\r\n filters: TestExecutionFilters,\r\n customOut?: OutFn,\r\n) {\r\n return timeProfile('show test run result summary', () => {\r\n \r\n const out = customOut ?? mainOut\r\n\r\n const testsResultsSummary: TestsResultsSummary = {\r\n total: 0,\r\n passes: 0,\r\n invalid: 0,\r\n describesTotal: 0,\r\n describesPasses: 0,\r\n describesInvalid: 0,\r\n itsTotal: 0,\r\n itsPasses: 0\r\n // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)\r\n }\r\n let describesThrownCount = 0\r\n\r\n for (const testFile in runTestResults) {\r\n const runTestResult = runTestResults[testFile]\r\n if (!runTestResult) continue\r\n\r\n testsResultsSummary.total += +(runTestResult.success !== null)\r\n testsResultsSummary.passes += +(runTestResult.success ?? false)\r\n testsResultsSummary.invalid += +(runTestResult.success === null)\r\n testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total\r\n testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes\r\n testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid\r\n testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal\r\n testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses\r\n describesThrownCount += runTestResult.describeResults\r\n .filter(describeResult => describeResult.error !== undefined)\r\n .length\r\n }\r\n\r\n const failedToLoadCount = count(erroringTests)\r\n testsResultsSummary.total += failedToLoadCount\r\n\r\n if (\r\n (filters.describe !== undefined || filters.it !== undefined)\r\n && testsResultsSummary.itsTotal === 0\r\n && failedToLoadCount === 0\r\n && describesThrownCount === 0\r\n ) {\r\n out(chalk.orange('No tests matched the describe/test filters.'))\r\n const durationMs = new Date().getTime() - runStartTime\r\n writeStatusFile(\r\n config,\r\n statusCodes.couldNotRun,\r\n 'no tests matched the describe/test filters',\r\n [],\r\n durationMs\r\n )\r\n agentDone(\r\n config, runNumber, statusCodes.couldNotRun,\r\n 'no tests matched the describe/test filters', testsResultsSummary, durationMs,\r\n state.failedTestFiles.size\r\n )\r\n return null\r\n }\r\n\r\n const allPassed = (\r\n testsResultsSummary.passes === testsResultsSummary.total\r\n && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal\r\n && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal\r\n )\r\n\r\n const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses\r\n\r\n // a file that would not load, or a describe that threw, has no tests in itsTotal -\r\n // each counts as one unit on both sides\r\n const failuresN = failedTestsCount + describesThrownCount + failedToLoadCount\r\n const unitsN = testsResultsSummary.itsTotal + describesThrownCount + failedToLoadCount\r\n\r\n // the originals may have scrolled away on a long run, but past a point repeating\r\n // them buries the tallies - and when everything failed, they are the whole output already\r\n const showFailuresSection = config.restateFailures && failuresN > 0 && failuresN < unitsN\r\n && (failuresN <= 10 || failuresN <= 1.7 * unitsN ** 0.58)\r\n\r\n // the rule is separation enough, without the tallies' wider gap\r\n out((config.compact || showFailuresSection) ? '' : '\\n')\r\n\r\n if (allPassed) {\r\n out(chalk.mediumgreen(`${figures.tick}`))\r\n } else {\r\n //showFailures(out, Object.values(runTestResults), erroringTests)\r\n if (showFailuresSection) {\r\n \r\n const hr = '='.repeat((process.stdout.columns ?? 41) - 1)\r\n out(hr)\r\n out('Failures:')\r\n out(hr)\r\n\r\n for (const test of Object.values(erroringTests)) showTestLoadingError(config, test, out)\r\n for (const testResult of Object.values(runTestResults)) {\r\n if (testResult.success !== false) continue\r\n showTestFileResult(config, testResult, out, { failuresOnly: true })\r\n }\r\n out(config.compact ? '' : '\\n')\r\n }\r\n out(chalk.mediumred(`${figures.cross}`))\r\n }\r\n\r\n // number of tests successful\r\n const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`\r\n if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {\r\n if (testsResultsSummary.itsTotal === 0) {\r\n out(chalk.grey(`${testsText}`))\r\n } else {\r\n out(chalk.mediumgreen(`${testsText}`))\r\n }\r\n } else {\r\n out(chalk.mediumred(`${testsText}`))\r\n }\r\n\r\n // number of items successful\r\n const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`\r\n const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)\r\n ? (testsResultsSummary.describesInvalid === 1)\r\n ? '(+1 describe without tests)'\r\n : `(+${testsResultsSummary.describesInvalid} describes without tests)`\r\n : ''\r\n const describesThrownPlain = (describesThrownCount >= 1)\r\n ? (describesThrownCount === 1)\r\n ? '(1 describe errored)'\r\n : `(${describesThrownCount} describes errored)`\r\n : ''\r\n const describesDetailsText = [\r\n chalk.mediumred(describesThrownPlain), chalk.grey(invalidDescribesPlain)\r\n ]\r\n .filter(text => text !== '')\r\n .join(' ')\r\n const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`\r\n if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {\r\n if (testsResultsSummary.describesTotal === 0) {\r\n out(chalk.grey(`${describesText}`) + describesDetailsSuffix)\r\n } else {\r\n out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix)\r\n }\r\n } else {\r\n out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix)\r\n }\r\n\r\n // number of test files successful\r\n const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`\r\n const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)\r\n ? (testsResultsSummary.invalid === 1)\r\n ? '(+1 file without tests)'\r\n : `(+${testsResultsSummary.invalid} files without tests)`\r\n : ''\r\n const failedToLoadPlain = (failedToLoadCount >= 1)\r\n ? (failedToLoadCount === 1)\r\n ? '(1 file failed to load, or errored)'\r\n : `(${failedToLoadCount} files failed to load, or errored)`\r\n : ''\r\n const testFilesDetailsText = [\r\n chalk.mediumred(failedToLoadPlain), chalk.grey(invalidTestFilesPlain)\r\n ]\r\n .filter(text => text !== '')\r\n .join(' ')\r\n const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`\r\n if (testsResultsSummary.passes === testsResultsSummary.total) {\r\n if (testsResultsSummary.describesTotal === 0) {\r\n out(chalk.grey(`${testFilesText}`) + testFilesDetailsSuffix)\r\n } else {\r\n out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix)\r\n }\r\n } else {\r\n out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix)\r\n }\r\n\r\n // the tallies only cover what ran, so say the run was cut short - otherwise\r\n // \"Tests: 0/1\" reads as a one test suite\r\n const stoppedPlain = (stop.stopped)\r\n ? 'stopped at the first failure (failFast)'\r\n : ''\r\n if (stoppedPlain !== '') out(chalk.orange(stoppedPlain))\r\n\r\n const summaryLines = [\r\n testsText,\r\n joinPlain(describesText, describesThrownPlain, invalidDescribesPlain),\r\n joinPlain(testFilesText, failedToLoadPlain, invalidTestFilesPlain),\r\n ...(stoppedPlain === '') ? [] : [stoppedPlain]\r\n ]\r\n\r\n const durationMs = new Date().getTime() - runStartTime\r\n\r\n if (allPassed) {\r\n writeStatusFile(\r\n config, statusCodes.passed, 'all tests passed', summaryLines, durationMs\r\n )\r\n agentDone(\r\n config, runNumber, statusCodes.passed, 'all tests passed',\r\n testsResultsSummary, durationMs, state.failedTestFiles.size\r\n )\r\n } else {\r\n const abortedFiles = Object.keys(erroringTests)\r\n\r\n // a file that would not load, or a describe that threw, means the run died\r\n // partway - a different problem from tests that ran and failed\r\n const aborted = abortedFiles.length > 0 || describesThrownCount > 0\r\n\r\n const description = ([\r\n plural(abortedFiles.length, 'test file', 'failed to load or errored'),\r\n plural(describesThrownCount, 'describe', 'errored'),\r\n plural(failedTestsCount, 'test', 'failed')\r\n ].filter(part => part !== '').join(', ') || 'test run failed')\r\n + ((stop.stopped) ? ', stopped at the first failure' : '')\r\n\r\n const code = (aborted) ? statusCodes.aborted : statusCodes.failed\r\n const failures = failureEntries(Object.values(runTestResults), erroringTests)\r\n\r\n writeStatusFile(\r\n config,\r\n code,\r\n description,\r\n [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)],\r\n durationMs\r\n )\r\n\r\n // failures first, so the done line is a complete end of run marker\r\n for (const failure of failures) agentFailure(config, runNumber, failure)\r\n agentDone(\r\n config, runNumber, code, description, testsResultsSummary, durationMs,\r\n state.failedTestFiles.size\r\n )\r\n }\r\n\r\n // full success?\r\n // true/false gets returned to the caller of runTests()\r\n return allPassed\r\n })\r\n}\r\n"]}
@@ -0,0 +1,3 @@
1
+ declare const timeProfile: <T>(name: string, task: () => T) => T, timeProfileAsync: <T>(name: string, task: () => Promise<T>) => Promise<T>;
2
+ export { timeProfile, timeProfileAsync };
3
+ //# sourceMappingURL=timeProfiler.d.ts.map
@@ -2,4 +2,4 @@ import { createTimeProfiler } from '../../packages/timeProfiler.js';
2
2
  import { showTimeProfiling } from '../../config.js';
3
3
  const { timeProfile, timeProfileAsync } = createTimeProfiler(showTimeProfiling);
4
4
  export { timeProfile, timeProfileAsync };
5
- //# sourceMappingURL=timeProfier.js.map
5
+ //# sourceMappingURL=timeProfiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeProfiler.js","sourceRoot":"","sources":["../../../src/cli/lib/timeProfiler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGnD,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAE/E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA","sourcesContent":["\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\n\n\nconst { timeProfile, timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport { timeProfile, timeProfileAsync }\n"]}
@@ -8,6 +8,9 @@ export function validateConfig(config, customOut) {
8
8
  if (typeof config.compact !== 'boolean') {
9
9
  doError('Config error, config.compact should be a boolean');
10
10
  }
11
+ if (typeof config.restateFailures !== 'boolean') {
12
+ doError('Config error, config.restateFailures should be a boolean');
13
+ }
11
14
  if (typeof config.agent !== 'boolean') {
12
15
  doError('Config error, config.agent should be a boolean');
13
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validateConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/validateConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAGhD,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,SAAiB;IACjE,MAAM,GAAG,GAAG,SAAS,IAAI,OAAO,CAAA;IAEhC,SAAS,OAAO,CAAC,OAAe;QAC5B,GAAG,CAAC,OAAO,CAAC,CAAA;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,CAAC,kDAAkD,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,CAAC,gDAAgD,CAAC,CAAA;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,+CAA+C,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;QAC3F,OAAO,CAAC,mFAAmF,CAAC,CAAA;IAChG,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAA;IAC1C,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,CAAC,EAAE,CAAC;QAChF,OAAO,CAAC,sEAAsE,CAAC,CAAA;IACnF,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;AACL,CAAC","sourcesContent":["\nimport type { FinalConfig, OutFn } from '../../types.js'\nimport { out as mainOut } from '../../output.js'\n\n\nexport function validateConfig(config: FinalConfig, customOut?: OutFn): void {\n const out = customOut ?? mainOut\n\n function doError(message: string): never {\n out(message)\n throw new Error(message)\n }\n\n if (typeof config.compact !== 'boolean') {\n doError('Config error, config.compact should be a boolean')\n }\n\n if (typeof config.agent !== 'boolean') {\n doError('Config error, config.agent should be a boolean')\n }\n\n if (config.execution === undefined) {\n doError('Config error, config.execution is not defined')\n }\n\n if (config.execution.files !== 'parallel' && config.execution.files !== 'sequential') {\n doError('Config error, config.execution.files should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.describes !== 'parallel' && config.execution.describes !== 'sequential') {\n doError('Config error, config.execution.describes should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.tests !== 'parallel' && config.execution.tests !== 'sequential') {\n doError('Config error, config.execution.tests should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (typeof config.watch.ttyActionsOnKeypress !== 'boolean') {\n doError('Config error, config.watch.ttyActionsOnKeypress should be a boolean')\n }\n\n const statusFile = config.watch.statusFile\n if (statusFile !== false && (typeof statusFile !== 'string' || statusFile === '')) {\n doError('Config error, config.watch.statusFile should be false or a file path')\n }\n\n if (typeof config.watch.dependencyEvaluation !== 'boolean') {\n doError('Config error, config.watch.dependencyEvaluation should be a boolean')\n }\n}\n"]}
1
+ {"version":3,"file":"validateConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/validateConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAGhD,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,SAAiB;IACjE,MAAM,GAAG,GAAG,SAAS,IAAI,OAAO,CAAA;IAEhC,SAAS,OAAO,CAAC,OAAe;QAC5B,GAAG,CAAC,OAAO,CAAC,CAAA;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,CAAC,kDAAkD,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAC9C,OAAO,CAAC,0DAA0D,CAAC,CAAA;IACvE,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,CAAC,gDAAgD,CAAC,CAAA;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,+CAA+C,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;QAC3F,OAAO,CAAC,mFAAmF,CAAC,CAAA;IAChG,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAA;IAC1C,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,CAAC,EAAE,CAAC;QAChF,OAAO,CAAC,sEAAsE,CAAC,CAAA;IACnF,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;AACL,CAAC","sourcesContent":["\nimport type { FinalConfig, OutFn } from '../../types.js'\nimport { out as mainOut } from '../../output.js'\n\n\nexport function validateConfig(config: FinalConfig, customOut?: OutFn): void {\n const out = customOut ?? mainOut\n\n function doError(message: string): never {\n out(message)\n throw new Error(message)\n }\n\n if (typeof config.compact !== 'boolean') {\n doError('Config error, config.compact should be a boolean')\n }\n\n if (typeof config.restateFailures !== 'boolean') {\n doError('Config error, config.restateFailures should be a boolean')\n }\n\n if (typeof config.agent !== 'boolean') {\n doError('Config error, config.agent should be a boolean')\n }\n\n if (config.execution === undefined) {\n doError('Config error, config.execution is not defined')\n }\n\n if (config.execution.files !== 'parallel' && config.execution.files !== 'sequential') {\n doError('Config error, config.execution.files should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.describes !== 'parallel' && config.execution.describes !== 'sequential') {\n doError('Config error, config.execution.describes should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.tests !== 'parallel' && config.execution.tests !== 'sequential') {\n doError('Config error, config.execution.tests should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (typeof config.watch.ttyActionsOnKeypress !== 'boolean') {\n doError('Config error, config.watch.ttyActionsOnKeypress should be a boolean')\n }\n\n const statusFile = config.watch.statusFile\n if (statusFile !== false && (typeof statusFile !== 'string' || statusFile === '')) {\n doError('Config error, config.watch.statusFile should be false or a file path')\n }\n\n if (typeof config.watch.dependencyEvaluation !== 'boolean') {\n doError('Config error, config.watch.dependencyEvaluation should be a boolean')\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import minimatch from 'minimatch';
1
+ import { matchesGlob } from 'node:path';
2
2
  import chalk from '../../packages/chalk.js';
3
3
  import slash from '../../packages/slash.js';
4
4
  import { createTimeProfiler } from '../../packages/timeProfiler.js';
@@ -26,8 +26,8 @@ customOut, executionFilters = {}) {
26
26
  const testsIgnoreGlobs = addBasePath(config.testsBase, config.testsIgnore);
27
27
  // indentify a test file
28
28
  const testFilter = (file) => {
29
- return minimatch(file, globArgCombine(testsGlobs))
30
- && !minimatch(file, globArgCombine(testsIgnoreGlobs))
29
+ return matchesGlob(file, globArgCombine(testsGlobs))
30
+ && !matchesGlob(file, globArgCombine(testsIgnoreGlobs))
31
31
  && (config.testsFilter === undefined
32
32
  || config.testsFilter === ''
33
33
  || filter(config.testsBase, config.testsFilter, file));
@@ -1 +1 @@
1
- {"version":3,"file":"watchFilesAndRunTestsNodeWatch.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesAndRunTestsNodeWatch.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AAMjC,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAA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AA;wBACL,CAAC;oBACL,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACT,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAA;oBACjC,CAAC;gBACL,CAAC,CAAC,CAAA;YACN,CAAC,EAAE,UAAU,CAAC,CAAA;QAClB,CAAC,CAAC,qBAAqB;QAEvB,SAAS,UAAU,CAAC,QAAgB;YAChC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3B,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YAC5D,eAAe,CAAC,QAAQ,CAAC,GAAG,cAAc;iBACrC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;iBACrD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;QACpC,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,mFAAmF;IACnF,gFAAgF;IAChF,8EAA8E;IAC9E,qCAAqC;AACzC,CAAC","sourcesContent":["\nimport minimatch from 'minimatch'\n\nimport type { FinalConfig, DependencyTrees, OutFn } from '../../types.js'\nimport type { TestExecutionFilters } from '../cliTypes.js'\nimport type { ReRunManager } from './reRunManager.js'\nimport type { StopFn } from '../watch.js'\nimport chalk from '../../packages/chalk.js'\nimport slash from '../../packages/slash.js'\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport { out as mainOut, log, debug } from '../../output.js'\nimport { agentChange } from './agentReport.js'\nimport { runTests } from './runTests.js'\nimport { buildDependencyTree } from './buildDependencyTree.js'\nimport { globArgCombine } from './globArgCombine.js'\nimport { addBasePath } from './addBasePath.js'\nimport { watchFilesNodeWatch } from './watchFilesNodeWatch.js'\nimport { filter } from './filter.js'\n\n\nconst { timeProfile, timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport async function watchFilesAndRunTestsNodeWatch(\n config: FinalConfig,\n //testFiles: Set<string>,\n dependencyTrees: DependencyTrees,\n failingTests: string[],\n reRunManager: ReRunManager,\n //watchRunState: WatchRunState,\n customOut?: OutFn,\n executionFilters: TestExecutionFilters = {}\n): Promise<StopFn> {\n const projectDir = process.cwd()\n // agent mode passes a sink here, so its own change lines are the only ones printed\n const out = customOut ?? mainOut\n\n return timeProfileAsync('init watching', async () => {\n debug('failingTests', failingTests)\n\n const testsGlobs = addBasePath(config.testsBase, config.tests)\n const testsIgnoreGlobs = addBasePath(config.testsBase, config.testsIgnore)\n\n // indentify a test file\n const testFilter = (file: string): boolean => {\n return minimatch(file, globArgCombine(testsGlobs))\n && !minimatch(file, globArgCombine(testsIgnoreGlobs))\n && (\n config.testsFilter === undefined\n || config.testsFilter === ''\n || filter(config.testsBase, config.testsFilter, file)\n )\n }\n\n let changedFiles: Array<[string, string]> = []\n let timeout: ReturnType<typeof setTimeout> | null = null\n\n if (config.watch.watchFilesBase === '') {\n out('No config.watch.watchFilesBase provided, defaulting to \\'.\\'')\n config.watch.watchFilesBase = '.'\n }\n\n const watcher = await watchFilesNodeWatch(config, watchEvent)\n return () => {\n watcher.close()\n // a change seen just before stopping would otherwise still run its tests\n if (timeout) clearTimeout(timeout)\n }\n\n function watchEvent(filename: string, event: string): void {\n debug('handle watch event ', filename, event)\n\n filename = slash(filename)\n\n // remove dep tree for any tests that are deleted, avoiding trying to run it later\n if (event === 'remove') {\n debug('removing test', filename)\n reRunManager.state.withoutTests.delete(filename)\n if (filename in dependencyTrees) {\n reRunManager.state.allTestFiles.delete(filename)\n delete dependencyTrees[filename]\n } else if (!config.watch.dependencyEvaluation) {\n // without trees there is nothing to look the file up in\n reRunManager.state.allTestFiles.delete(filename)\n }\n }\n\n // info on the event found\n out(chalk.grey`change: ${filename} (${event})`)\n agentChange(config, filename, event)\n\n // add the file to changed files\n changedFiles.push([filename, event])\n\n // 33ms debounce\n const debounceMs = 33\n if (timeout) {\n clearTimeout(timeout)\n }\n timeout = setTimeout(() => {\n timeProfile('handle changed files', () => {\n debug('changedFiles', changedFiles)\n try {\n // build related test list\n //const tests: string[] = []\n const tests = new Set<string>\n for (const [file, fileEvent] of changedFiles) {\n debug('check', file)\n debug('1 tests', tests)\n if (fileEvent !== 'remove') { // only check if it's a test if it exists (has not just been removed)\n if (testFilter(file)) { // it is a test file itself, add to run list\n debug('its a test', file)\n //tests.push(file)\n tests.add(file)\n if (config.watch.dependencyEvaluation) {\n if (!(file in dependencyTrees)) { // if its a new test\n debug('try to add a new test', file)\n addNewTest(file)\n }\n } else {\n // no trees to record it in, so this is what makes a\n // newly created test part of the run set\n reRunManager.state.allTestFiles.add(file)\n }\n }\n }\n\n // with evaluation off there is nothing to map the change through:\n // any watched file could affect any test, so run the lot\n if (!config.watch.dependencyEvaluation) {\n for (const f of reRunManager.state.allTestFiles) tests.add(f)\n continue\n }\n\n debug('dtrees', dependencyTrees)\n debug('2 tests', tests)\n for (const f of Object.getOwnPropertyNames(dependencyTrees)) {\n debug('dep tree', f, dependencyTrees[f])\n if (dependencyTrees[f]?.some(dep => dep === file) === true) { // a test depends on this file\n debug('its a dependency', file)\n //tests.push(f)\n tests.add(f)\n }\n }\n }\n\n changedFiles = []\n\n debug('tests', tests)\n\n if (tests.size > 0) {\n timeProfile('build list of files to test and request a run',\n () => {\n debug('tests', tests)\n debug('reRunFailingTests', config.watch.reRunFailingTests)\n\n // changes accumulate here because an 'auto' request made while a\n // run is in flight is coalesced into the queued one - everything\n // edited in the meantime still has to be covered\n reRunManager.state.untestedFiles\n = reRunManager.state.untestedFiles.union(tests)\n\n void reRunManager.requestRun(\n 'auto',\n () => {\n // resolved when the run actually starts, not when it is\n // queued, so a coalesced request picks up the later edits\n const toTest = (config.watch.reRunFailingTests)\n ? reRunManager.state.untestedFiles\n .union(reRunManager.state.failedTestFiles)\n : new Set(reRunManager.state.untestedFiles)\n\n // consumed by this run - without this they are retested\n // on every later run for the rest of the session\n reRunManager.state.untestedFiles = new Set()\n\n debug('run tests on change')\n debug('toTest', toTest)\n\n return runTests(\n config,\n toTest,\n reRunManager,\n { limit: -1 },\n 'refresh',\n customOut,\n executionFilters\n )\n }\n )\n }\n )\n }\n } catch (e) {\n log('watch handler error', e)\n }\n })\n }, debounceMs)\n } // end of watch event\n\n function addNewTest(testFile: string): void {\n debug('new test', testFile)\n const dependencyTree = buildDependencyTree(config, testFile)\n dependencyTrees[testFile] = dependencyTree\n .map(file => slash(file).slice(projectDir.length + 1))\n .filter(f => f !== testFile)\n }\n })\n\n // NOTE: \"watching...\" is intentionally NOT printed here. watch() already emits it,\n // tied to a real milestone (the initial test run finishing, or no tests found).\n // Printing it again here produced a duplicate \"watching...\" on every startup.\n // out(chalk.brightblue`watching...`)\n}\n"]}
1
+ {"version":3,"file":"watchFilesAndRunTestsNodeWatch.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesAndRunTestsNodeWatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAMvC,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MA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C,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;iBACrD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;QACpC,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,mFAAmF;IACnF,gFAAgF;IAChF,8EAA8E;IAC9E,qCAAqC;AACzC,CAAC","sourcesContent":["\nimport { matchesGlob } from 'node:path'\n\nimport type { FinalConfig, DependencyTrees, OutFn } from '../../types.js'\nimport type { TestExecutionFilters } from '../cliTypes.js'\nimport type { ReRunManager } from './reRunManager.js'\nimport type { StopFn } from '../watch.js'\nimport chalk from '../../packages/chalk.js'\nimport slash from '../../packages/slash.js'\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport { out as mainOut, log, debug } from '../../output.js'\nimport { agentChange } from './agentReport.js'\nimport { runTests } from './runTests.js'\nimport { buildDependencyTree } from './buildDependencyTree.js'\nimport { globArgCombine } from './globArgCombine.js'\nimport { addBasePath } from './addBasePath.js'\nimport { watchFilesNodeWatch } from './watchFilesNodeWatch.js'\nimport { filter } from './filter.js'\n\n\nconst { timeProfile, timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport async function watchFilesAndRunTestsNodeWatch(\n config: FinalConfig,\n //testFiles: Set<string>,\n dependencyTrees: DependencyTrees,\n failingTests: string[],\n reRunManager: ReRunManager,\n //watchRunState: WatchRunState,\n customOut?: OutFn,\n executionFilters: TestExecutionFilters = {}\n): Promise<StopFn> {\n const projectDir = process.cwd()\n // agent mode passes a sink here, so its own change lines are the only ones printed\n const out = customOut ?? mainOut\n\n return timeProfileAsync('init watching', async () => {\n debug('failingTests', failingTests)\n\n const testsGlobs = addBasePath(config.testsBase, config.tests)\n const testsIgnoreGlobs = addBasePath(config.testsBase, config.testsIgnore)\n\n // indentify a test file\n const testFilter = (file: string): boolean => {\n return matchesGlob(file, globArgCombine(testsGlobs))\n && !matchesGlob(file, globArgCombine(testsIgnoreGlobs))\n && (\n config.testsFilter === undefined\n || config.testsFilter === ''\n || filter(config.testsBase, config.testsFilter, file)\n )\n }\n\n let changedFiles: Array<[string, string]> = []\n let timeout: ReturnType<typeof setTimeout> | null = null\n\n if (config.watch.watchFilesBase === '') {\n out('No config.watch.watchFilesBase provided, defaulting to \\'.\\'')\n config.watch.watchFilesBase = '.'\n }\n\n const watcher = await watchFilesNodeWatch(config, watchEvent)\n return () => {\n watcher.close()\n // a change seen just before stopping would otherwise still run its tests\n if (timeout) clearTimeout(timeout)\n }\n\n function watchEvent(filename: string, event: string): void {\n debug('handle watch event ', filename, event)\n\n filename = slash(filename)\n\n // remove dep tree for any tests that are deleted, avoiding trying to run it later\n if (event === 'remove') {\n debug('removing test', filename)\n reRunManager.state.withoutTests.delete(filename)\n if (filename in dependencyTrees) {\n reRunManager.state.allTestFiles.delete(filename)\n delete dependencyTrees[filename]\n } else if (!config.watch.dependencyEvaluation) {\n // without trees there is nothing to look the file up in\n reRunManager.state.allTestFiles.delete(filename)\n }\n }\n\n // info on the event found\n out(chalk.grey`change: ${filename} (${event})`)\n agentChange(config, filename, event)\n\n // add the file to changed files\n changedFiles.push([filename, event])\n\n // 33ms debounce\n const debounceMs = 33\n if (timeout) {\n clearTimeout(timeout)\n }\n timeout = setTimeout(() => {\n timeProfile('handle changed files', () => {\n debug('changedFiles', changedFiles)\n try {\n // build related test list\n //const tests: string[] = []\n const tests = new Set<string>\n for (const [file, fileEvent] of changedFiles) {\n debug('check', file)\n debug('1 tests', tests)\n if (fileEvent !== 'remove') { // only check if it's a test if it exists (has not just been removed)\n if (testFilter(file)) { // it is a test file itself, add to run list\n debug('its a test', file)\n //tests.push(file)\n tests.add(file)\n if (config.watch.dependencyEvaluation) {\n if (!(file in dependencyTrees)) { // if its a new test\n debug('try to add a new test', file)\n addNewTest(file)\n }\n } else {\n // no trees to record it in, so this is what makes a\n // newly created test part of the run set\n reRunManager.state.allTestFiles.add(file)\n }\n }\n }\n\n // with evaluation off there is nothing to map the change through:\n // any watched file could affect any test, so run the lot\n if (!config.watch.dependencyEvaluation) {\n for (const f of reRunManager.state.allTestFiles) tests.add(f)\n continue\n }\n\n debug('dtrees', dependencyTrees)\n debug('2 tests', tests)\n for (const f of Object.getOwnPropertyNames(dependencyTrees)) {\n debug('dep tree', f, dependencyTrees[f])\n if (dependencyTrees[f]?.some(dep => dep === file) === true) { // a test depends on this file\n debug('its a dependency', file)\n //tests.push(f)\n tests.add(f)\n }\n }\n }\n\n changedFiles = []\n\n debug('tests', tests)\n\n if (tests.size > 0) {\n timeProfile('build list of files to test and request a run',\n () => {\n debug('tests', tests)\n debug('reRunFailingTests', config.watch.reRunFailingTests)\n\n // changes accumulate here because an 'auto' request made while a\n // run is in flight is coalesced into the queued one - everything\n // edited in the meantime still has to be covered\n reRunManager.state.untestedFiles\n = reRunManager.state.untestedFiles.union(tests)\n\n void reRunManager.requestRun(\n 'auto',\n () => {\n // resolved when the run actually starts, not when it is\n // queued, so a coalesced request picks up the later edits\n const toTest = (config.watch.reRunFailingTests)\n ? reRunManager.state.untestedFiles\n .union(reRunManager.state.failedTestFiles)\n : new Set(reRunManager.state.untestedFiles)\n\n // consumed by this run - without this they are retested\n // on every later run for the rest of the session\n reRunManager.state.untestedFiles = new Set()\n\n debug('run tests on change')\n debug('toTest', toTest)\n\n return runTests(\n config,\n toTest,\n reRunManager,\n { limit: -1 },\n 'refresh',\n customOut,\n executionFilters\n )\n }\n )\n }\n )\n }\n } catch (e) {\n log('watch handler error', e)\n }\n })\n }, debounceMs)\n } // end of watch event\n\n function addNewTest(testFile: string): void {\n debug('new test', testFile)\n const dependencyTree = buildDependencyTree(config, testFile)\n dependencyTrees[testFile] = dependencyTree\n .map(file => slash(file).slice(projectDir.length + 1))\n .filter(f => f !== testFile)\n }\n })\n\n // NOTE: \"watching...\" is intentionally NOT printed here. watch() already emits it,\n // tied to a real milestone (the initial test run finishing, or no tests found).\n // Printing it again here produced a duplicate \"watching...\" on every startup.\n // out(chalk.brightblue`watching...`)\n}\n"]}
@@ -1,5 +1,5 @@
1
+ import { matchesGlob } from 'node:path';
1
2
  import * as nodeWatchNS from 'node-watch';
2
- import minimatch from 'minimatch';
3
3
  import { createTimeProfiler } from '../../packages/timeProfiler.js';
4
4
  import { showTimeProfiling } from '../../config.js';
5
5
  import slash from '../../packages/slash.js';
@@ -19,9 +19,9 @@ export function watchFilesNodeWatch(config, onEvent) {
19
19
  const watchGlobs = addBasePath(config.watch.watchFilesBase, config.watch.watchFiles);
20
20
  const watchIgnoreGlobs = addBasePath(config.watch.watchFilesBase, config.watch.watchFilesIgnore);
21
21
  // identify a file we should be watching and responding to
22
- const watchFilter = (file) => (watchGlobs.length === 0 || minimatch(slash(file), globArgCombine(watchGlobs)))
22
+ const watchFilter = (file) => (watchGlobs.length === 0 || matchesGlob(slash(file), globArgCombine(watchGlobs)))
23
23
  && (watchIgnoreGlobs.length === 0
24
- || !minimatch(slash(file), globArgCombine(watchIgnoreGlobs)));
24
+ || !matchesGlob(slash(file), globArgCombine(watchIgnoreGlobs)));
25
25
  const watcher = nodeWatch(config.watch.watchFilesBase, {
26
26
  recursive: true,
27
27
  filter: watchFilter
@@ -1 +1 @@
1
- {"version":3,"file":"watchFilesNodeWatch.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesNodeWatch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,YAAY,CAAA;AACzC,OAAO,SAAS,MAAM,WAAW,CAAA;AAGjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBA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AAC,QAAQ,CAAC,CAAA;YAC1B,KAAK,CAAC,aAAa,CAAC,CAAA;YACpB,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC,CACJ,CAAA;QAED,kCAAkC;QAClC,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;YAC9B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAChC,CAAC,CAAC,CAAA;QAEF,OAAO,OAAO,CAAA;IAClB,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["\nimport type { Watcher } from 'node-watch'\nimport * as nodeWatchNS from 'node-watch'\nimport minimatch from 'minimatch'\n\nimport type { FinalConfig } from '../../types.js'\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport slash from '../../packages/slash.js'\nimport { out, debug } from '../../output.js'\nimport { globArgCombine } from './globArgCombine.js'\nimport { addBasePath } from './addBasePath.js'\n\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\n// only the default export is mistyped, so the package's own Watcher type is usable as is\nexport type NodeWatchWatcher = Watcher\n\n// node-watch's shipped .d.ts mistypes the default export under NodeNext CJS interop\n// (resolves to the module namespace type, not the function) - cast at the call site.\ntype NodeWatchFn = (\n pathName: string,\n options: { recursive?: boolean; filter?: (file: string) => boolean },\n callback: (event: string, filename: string) => void\n) => NodeWatchWatcher\nconst nodeWatch = nodeWatchNS.default as unknown as NodeWatchFn // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion\n\nexport type WatchEvent = (filename: string, event: string) => void\n\nexport function watchFilesNodeWatch(\n config: FinalConfig,\n onEvent: WatchEvent\n): Promise<NodeWatchWatcher> {\n return timeProfileAsync('start watching', async () => {\n if (config.watch.watchFilesBase === '') {\n out('No config.watch.watchFilesBase provided, defaulting to \\'.\\'')\n config.watch.watchFilesBase = '.'\n }\n\n // watch globs are relative to watchFilesBase, but node-watch's filter is given\n // paths including the base, so bring the globs up to the same base\n const watchGlobs = addBasePath(config.watch.watchFilesBase, config.watch.watchFiles)\n const watchIgnoreGlobs = addBasePath(config.watch.watchFilesBase, config.watch.watchFilesIgnore)\n\n // identify a file we should be watching and responding to\n const watchFilter = (file: string): boolean =>\n (watchGlobs.length === 0 || minimatch(slash(file), globArgCombine(watchGlobs)))\n && (\n watchIgnoreGlobs.length === 0\n || !minimatch(slash(file), globArgCombine(watchIgnoreGlobs))\n )\n\n const watcher = nodeWatch(\n config.watch.watchFilesBase,\n {\n recursive: true,\n filter: watchFilter\n },\n (event, filename) => {\n filename = slash(filename)\n debug('watch event')\n onEvent(filename, event)\n }\n )\n\n // wait until the watcher is ready\n await new Promise<void>(resolve => {\n watcher.on('ready', resolve)\n })\n\n return watcher\n })\n}\n"]}
1
+ {"version":3,"file":"watchFilesNodeWatch.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesNodeWatch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,WAAW,MAAM,YAAY,CAAA;AAGzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAYlE,MAAM,SAAS,GAAG,WAAW,CAAC,OAAiC,CAAA,CAAC,kEAAkE;AAIlI,MAAM,UAAU,mBAAmB,CAC/B,MAAmB,EACnB,OAAmB;IAEnB,OAAO,gBAAgB,CAAC,gBAAgB,EAAE,KAAK,IAAI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AChC,CAAC,CAAC,CAAA;QAEF,OAAO,OAAO,CAAA;IAClB,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["\nimport type { Watcher } from 'node-watch'\nimport { matchesGlob } from 'node:path'\nimport * as nodeWatchNS from 'node-watch'\n\nimport type { FinalConfig } from '../../types.js'\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport slash from '../../packages/slash.js'\nimport { out, debug } from '../../output.js'\nimport { globArgCombine } from './globArgCombine.js'\nimport { addBasePath } from './addBasePath.js'\n\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\n// only the default export is mistyped, so the package's own Watcher type is usable as is\nexport type NodeWatchWatcher = Watcher\n\n// node-watch's shipped .d.ts mistypes the default export under NodeNext CJS interop\n// (resolves to the module namespace type, not the function) - cast at the call site.\ntype NodeWatchFn = (\n pathName: string,\n options: { recursive?: boolean; filter?: (file: string) => boolean },\n callback: (event: string, filename: string) => void\n) => NodeWatchWatcher\nconst nodeWatch = nodeWatchNS.default as unknown as NodeWatchFn // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion\n\nexport type WatchEvent = (filename: string, event: string) => void\n\nexport function watchFilesNodeWatch(\n config: FinalConfig,\n onEvent: WatchEvent\n): Promise<NodeWatchWatcher> {\n return timeProfileAsync('start watching', async () => {\n if (config.watch.watchFilesBase === '') {\n out('No config.watch.watchFilesBase provided, defaulting to \\'.\\'')\n config.watch.watchFilesBase = '.'\n }\n\n // watch globs are relative to watchFilesBase, but node-watch's filter is given\n // paths including the base, so bring the globs up to the same base\n const watchGlobs = addBasePath(config.watch.watchFilesBase, config.watch.watchFiles)\n const watchIgnoreGlobs = addBasePath(config.watch.watchFilesBase, config.watch.watchFilesIgnore)\n\n // identify a file we should be watching and responding to\n const watchFilter = (file: string): boolean =>\n (watchGlobs.length === 0 || matchesGlob(slash(file), globArgCombine(watchGlobs)))\n && (\n watchIgnoreGlobs.length === 0\n || !matchesGlob(slash(file), globArgCombine(watchIgnoreGlobs))\n )\n\n const watcher = nodeWatch(\n config.watch.watchFilesBase,\n {\n recursive: true,\n filter: watchFilter\n },\n (event, filename) => {\n filename = slash(filename)\n debug('watch event')\n onEvent(filename, event)\n }\n )\n\n // wait until the watcher is ready\n await new Promise<void>(resolve => {\n watcher.on('ready', resolve)\n })\n\n return watcher\n })\n}\n"]}
package/dist/cli/once.js CHANGED
@@ -17,11 +17,13 @@ export async function once() {
17
17
  },
18
18
  'test-files': {
19
19
  flag: 't',
20
- hasValue: true
20
+ hasValue: true,
21
+ isGlob: true
21
22
  },
22
23
  filter: {
23
24
  flag: 'f',
24
- hasValue: true
25
+ hasValue: true,
26
+ isGlob: true
25
27
  },
26
28
  'filter-it': {
27
29
  flag: 'i',
@@ -1 +1 @@
1
- {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAEtC,MAAM,EAAE,yBAAyB,EAAE,GAAG,MAAM,MAAM,CAAC,oCAAoC,CAAC,CAAA;IACxF,MAAM,kBAAkB,GAAqB;QACzC,MAAM,EAAE;YACJ,IAAI,E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AU,CAAA,kBAAkB,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAC9B,MAAM,EAAE,SAAS,EACjB,SAAS,EACT,WAAW,EACX,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACxC,OAAO,EACP;QACI,EAAE,EAAE,QAAQ;QACZ,QAAQ,EAAE,cAAc;KAC3B,CACJ,CAAA;IACD,kFAAkF;IAClF,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC,eAAe;QAC3B,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAA;IAE7D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAA,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAEpD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAClE,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;IAE5B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["\nimport type { OutFn } from '../types.js'\nimport type { AllowedArguments } from './cliTypes.js'\nimport type { Concurrency } from './lib/runTests.js'\nimport chalk from '../packages/chalk.js'\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { exitCodes } from './lib/exitCodes.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.js'\n\n\nexport async function once(): Promise<void> {\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n config: {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true\n },\n filter: {\n flag: 'f',\n hasValue: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'fail-fast': {\n flag: 'x',\n hasValue: false\n },\n 'agent': {\n hasValue: false\n },\n 'compact': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout: the usual per-test output is routed into a sink, leaving the\n // failures and the summary. Under the flag, announced before the config loads, as in watch mode.\n const agentFlag = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentFlag)\n // the config can still turn agent mode on, so this is settled once it has loaded\n let agentMode = agentFlag\n const agentOut: OutFn = (...texts) => { if (!agentMode) out(...texts) }\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n //console.log('Looking for tests using pattern: ' + testFilesPattern) // eslint-disable-line no-console\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n //console.log('Filtering tests using pattern: ' + filter) // eslint-disable-line no-console\n userConfig.testsFilter = filter\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n // the flag is the only source: assigned rather than or'd, so a config file cannot\n // silently truncate every run\n config.failFast = clArguments['fail-fast'] === true\n if (agentFlag) config.agent = true\n else if (config.agent) agentInit(true) // set by the config: announced once it has loaded\n agentMode = config.agent\n agentSetRunReason('once')\n const runsOut = (agentMode) ? agentSilentOut : undefined\n agentOut(chalk.brightblue`[${packageName}]...`)\n if (clArguments.compact === true) config.compact = true\n\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n //console.log('run setup')\n //console.log(util.inspect(config))\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n //console.log('ran setup')\n \n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n agentFound(config, testFiles.size)\n\n if (testFiles.size === 0) {\n agentOut(chalk.mediumred(`[${packageName}] Found no tests.`\n + '\\nCreate tests matching the patterns, '\n + `\\nor set new patterns in ${configFileNames.map(x => `${x}.js/cjs/mjs`).join(' or ')}`))\n\n const endTime = new Date().getTime()\n const time = endTime - startTime\n agentOut(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`))\n\n // reported as a run, so a reader waiting on a done line always gets one\n const { statusCodes } = await import('./lib/statusFile.js')\n const run = agentRunStart(config, 0)\n agentDone(config, run, statusCodes.couldNotRun, 'no test files found', null, time, 0)\n\n // setup has already run by this point, so teardown must run too, or its side\n // effects are left behind\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCodes.noTestFiles)\n }\n\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n const concurrency: Concurrency = { limit: -1 }\n\n process.setSourceMapsEnabled(true) // enable source mapping\n \n // testFiles.size is guaranteed non-zero here - the no-tests case exited above\n const { runTests } = await import('./lib/runTests.js')\n if (!agentMode) log(chalk.brightblue`running tests...`)\n const testsResult = await runTests(\n config, testFiles,\n undefined,\n concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // a distinct code from noTestFiles, so callers can tell \"no test file matched the\n // pattern\" from \"the files matched but the filters selected nothing in them\"\n const exitCode = (testsResult === null)\n ? exitCodes.noMatchingTests\n : (testsResult) ? exitCodes.passed : exitCodes.testErrors\n\n const time = new Date().getTime() - startTime\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms\\n`)\n\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCode)\n}\n"]}
1
+ {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAEtC,MAAM,EAAE,yBAAyB,EAAE,GAAG,MAAM,MAAM,CAAC,oCAAoC,CAAC,CAAA;IACxF,MAAM,kBAAkB,GAAqB;QACzC,MAAM,EAAE;YACJ,IAAI,EAAE,GAAG;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QAAE,GAAG,CAAC,KAAK,CAAC,UAAU,CAAA,kBAAkB,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAC9B,MAAM,EAAE,SAAS,EACjB,SAAS,EACT,WAAW,EACX,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACxC,OAAO,EACP;QACI,EAAE,EAAE,QAAQ;QACZ,QAAQ,EAAE,cAAc;KAC3B,CACJ,CAAA;IACD,kFAAkF;IAClF,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC,eAAe;QAC3B,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAA;IAE7D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAA,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAEpD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAClE,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;IAE5B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["\nimport type { OutFn } from '../types.js'\nimport type { AllowedArguments } from './cliTypes.js'\nimport type { Concurrency } from './lib/runTests.js'\nimport chalk from '../packages/chalk.js'\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { exitCodes } from './lib/exitCodes.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.js'\n\n\nexport async function once(): Promise<void> {\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n config: {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true,\n isGlob: true\n },\n filter: {\n flag: 'f',\n hasValue: true,\n isGlob: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'fail-fast': {\n flag: 'x',\n hasValue: false\n },\n 'agent': {\n hasValue: false\n },\n 'compact': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout: the usual per-test output is routed into a sink, leaving the\n // failures and the summary. Under the flag, announced before the config loads, as in watch mode.\n const agentFlag = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentFlag)\n // the config can still turn agent mode on, so this is settled once it has loaded\n let agentMode = agentFlag\n const agentOut: OutFn = (...texts) => { if (!agentMode) out(...texts) }\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n //console.log('Looking for tests using pattern: ' + testFilesPattern) // eslint-disable-line no-console\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n //console.log('Filtering tests using pattern: ' + filter) // eslint-disable-line no-console\n userConfig.testsFilter = filter\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n // the flag is the only source: assigned rather than or'd, so a config file cannot\n // silently truncate every run\n config.failFast = clArguments['fail-fast'] === true\n if (agentFlag) config.agent = true\n else if (config.agent) agentInit(true) // set by the config: announced once it has loaded\n agentMode = config.agent\n agentSetRunReason('once')\n const runsOut = (agentMode) ? agentSilentOut : undefined\n agentOut(chalk.brightblue`[${packageName}]...`)\n if (clArguments.compact === true) config.compact = true\n\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n //console.log('run setup')\n //console.log(util.inspect(config))\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n //console.log('ran setup')\n \n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n agentFound(config, testFiles.size)\n\n if (testFiles.size === 0) {\n agentOut(chalk.mediumred(`[${packageName}] Found no tests.`\n + '\\nCreate tests matching the patterns, '\n + `\\nor set new patterns in ${configFileNames.map(x => `${x}.js/cjs/mjs`).join(' or ')}`))\n\n const endTime = new Date().getTime()\n const time = endTime - startTime\n agentOut(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`))\n\n // reported as a run, so a reader waiting on a done line always gets one\n const { statusCodes } = await import('./lib/statusFile.js')\n const run = agentRunStart(config, 0)\n agentDone(config, run, statusCodes.couldNotRun, 'no test files found', null, time, 0)\n\n // setup has already run by this point, so teardown must run too, or its side\n // effects are left behind\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCodes.noTestFiles)\n }\n\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n const concurrency: Concurrency = { limit: -1 }\n\n process.setSourceMapsEnabled(true) // enable source mapping\n \n // testFiles.size is guaranteed non-zero here - the no-tests case exited above\n const { runTests } = await import('./lib/runTests.js')\n if (!agentMode) log(chalk.brightblue`running tests...`)\n const testsResult = await runTests(\n config, testFiles,\n undefined,\n concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // a distinct code from noTestFiles, so callers can tell \"no test file matched the\n // pattern\" from \"the files matched but the filters selected nothing in them\"\n const exitCode = (testsResult === null)\n ? exitCodes.noMatchingTests\n : (testsResult) ? exitCodes.passed : exitCodes.testErrors\n\n const time = new Date().getTime() - startTime\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms\\n`)\n\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCode)\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export type StopFn = () => void;
2
2
  export declare function watch(): Promise<void>;
3
- export declare function doWatch(): Promise<StopFn>;
3
+ export declare function doWatch(input?: NodeJS.ReadStream): Promise<StopFn>;
4
4
  //# sourceMappingURL=watch.d.ts.map
package/dist/cli/watch.js CHANGED
@@ -12,7 +12,8 @@ export async function watch() {
12
12
  await doWatch();
13
13
  await new Promise(() => { });
14
14
  }
15
- export async function doWatch() {
15
+ // input is injectable so tests never read the terminal their runner is also reading
16
+ export async function doWatch(input = process.stdin) {
16
17
  const startTime = new Date().getTime();
17
18
  const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js');
18
19
  const allowedClArguments = {
@@ -22,11 +23,13 @@ export async function doWatch() {
22
23
  },
23
24
  'test-files': {
24
25
  flag: 't',
25
- hasValue: true
26
+ hasValue: true,
27
+ isGlob: true
26
28
  },
27
29
  'filter': {
28
30
  flag: 'f',
29
- hasValue: true
31
+ hasValue: true,
32
+ isGlob: true
30
33
  },
31
34
  'filter-it': {
32
35
  flag: 'i',
@@ -148,7 +151,7 @@ export async function doWatch() {
148
151
  if (config.watch.dependencyEvaluation) {
149
152
  const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js');
150
153
  agentOut(chalk.brightblue `finding initial dependency trees...`);
151
- dependencyTrees = await buildDependencyTrees(config, testFiles);
154
+ dependencyTrees = buildDependencyTrees(config, testFiles);
152
155
  }
153
156
  }
154
157
  // live before the first test runs, for two reasons. A change landing during the initial
@@ -194,7 +197,7 @@ export async function doWatch() {
194
197
  const { listenToUser } = await import('./lib/listenToUser.js');
195
198
  const disposeTty = listenToUser(reRunManager, files => () => {
196
199
  return runTests(config, files, reRunManager, concurrency, 'refresh', runsOut, executionFilters);
197
- }, config.watch.ttyActionsOnKeypress, initialTestRun, process.stdin, runsOut);
200
+ }, config.watch.ttyActionsOnKeypress, initialTestRun, input, runsOut);
198
201
  stopFns.push(disposeTty);
199
202
  const dispose = () => {
200
203
  for (const stop of stopFns) {