@testomatio/reporter 2.10.0 → 2.11.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/lib/bin/cli.js +10 -4
- package/lib/client.js +2 -2
- package/lib/junit-adapter/dart.d.ts +5 -0
- package/lib/junit-adapter/dart.js +101 -0
- package/lib/junit-adapter/index.js +4 -0
- package/lib/pipe/testomatio.js +8 -0
- package/lib/utils/utils.js +45 -2
- package/lib/xmlReader.js +2 -0
- package/package.json +1 -1
- package/src/bin/cli.js +11 -5
- package/src/client.js +2 -2
- package/src/junit-adapter/dart.js +103 -0
- package/src/junit-adapter/index.js +4 -0
- package/src/pipe/testomatio.js +7 -0
- package/src/utils/utils.js +48 -2
- package/src/xmlReader.js +1 -0
- package/types/types.d.ts +3 -0
package/lib/bin/cli.js
CHANGED
|
@@ -56,6 +56,7 @@ program
|
|
|
56
56
|
.option('--kind <type>', 'Specify run type: automated, manual, or mixed')
|
|
57
57
|
.option('--filter <filter>', 'Scope the prepared run to tests matching the filter (no execution)')
|
|
58
58
|
.option('--format <format>', 'Machine-readable output: print only the run id to stdout (e.g. --format id)')
|
|
59
|
+
.option('--warn', 'Exit 0 instead of 1 when the filter matches no tests (warn only)')
|
|
59
60
|
.action(async (opts) => {
|
|
60
61
|
(0, utils_js_1.cleanLatestRunId)();
|
|
61
62
|
log_js_1.log.info('Starting a new Run on Testomat.io...');
|
|
@@ -69,7 +70,8 @@ program
|
|
|
69
70
|
const tests = await client.prepareRun({ pipe, pipeOptions: optsArray.join(':') });
|
|
70
71
|
if (!tests || tests.length === 0) {
|
|
71
72
|
log_js_1.log.warn(picocolors_1.default.yellow('No tests found for the filter. Run not created.'));
|
|
72
|
-
|
|
73
|
+
// --warn treats an empty match as a normal outcome (e.g. a PR touching no mapped files)
|
|
74
|
+
process.exit(opts.warn ? 0 : 1);
|
|
73
75
|
}
|
|
74
76
|
createRunParams.configuration = {
|
|
75
77
|
tests: tests.filter(id => id.startsWith('T')).map(id => id.slice(1)),
|
|
@@ -98,8 +100,11 @@ program
|
|
|
98
100
|
console.log('Finishing Run on Testomat.io...');
|
|
99
101
|
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
|
|
100
102
|
const client = new client_js_1.default({ apiKey });
|
|
103
|
+
const finishParams = {};
|
|
104
|
+
if ((0, utils_js_1.transformEnvVarToBoolean)(process.env.TESTOMATIO_FINISH_SHARED_RUN))
|
|
105
|
+
finishParams.force_finish_shared_run = true;
|
|
101
106
|
// @ts-ignore
|
|
102
|
-
client.updateRunStatus(constants_js_1.STATUS.FINISHED).then(() => {
|
|
107
|
+
client.updateRunStatus(constants_js_1.STATUS.FINISHED, finishParams).then(() => {
|
|
103
108
|
process.exit(0);
|
|
104
109
|
});
|
|
105
110
|
});
|
|
@@ -114,6 +119,7 @@ program
|
|
|
114
119
|
.option('--kind <type>', 'Specify run type: automated, manual, or mixed')
|
|
115
120
|
.option('--remote <profile>', 'Trigger run on the named Testomat.io CI profile instead of executing locally')
|
|
116
121
|
.option('--remote-param <kv>', 'key=value pair forwarded to the CI profile config (repeat for multiple)', (value, prev) => prev.concat([value]), [])
|
|
122
|
+
.option('--warn', 'Exit 0 instead of 1 when the filter matches no tests (warn only)')
|
|
117
123
|
.action(async (command, opts) => {
|
|
118
124
|
if (opts.remote) {
|
|
119
125
|
if (opts.filterList) {
|
|
@@ -144,8 +150,8 @@ program
|
|
|
144
150
|
if (!tests || tests.length === 0) {
|
|
145
151
|
log_js_1.log.warn(picocolors_1.default.yellow('No tests found.'));
|
|
146
152
|
// Exit non-zero on --filter-list so scripts can detect "nothing to run"
|
|
147
|
-
// via $? and skip launching the runner.
|
|
148
|
-
if (opts.filterList)
|
|
153
|
+
// via $? and skip launching the runner. --warn downgrades it to 0.
|
|
154
|
+
if (opts.filterList && !opts.warn)
|
|
149
155
|
process.exit(1);
|
|
150
156
|
return;
|
|
151
157
|
}
|
package/lib/client.js
CHANGED
|
@@ -192,9 +192,9 @@ class Client {
|
|
|
192
192
|
title: 'Unknown test',
|
|
193
193
|
suite_title: 'Unknown suite',
|
|
194
194
|
};
|
|
195
|
-
// Add timestamp if not already present (
|
|
195
|
+
// Add timestamp if not already present (Unix seconds)
|
|
196
196
|
if (!testData.timestamp && !process.env.TESTOMATIO_NO_TIMESTAMP) {
|
|
197
|
-
testData.timestamp = Math.floor((performance.timeOrigin + performance.now())
|
|
197
|
+
testData.timestamp = Math.floor((performance.timeOrigin + performance.now()) / 1000);
|
|
198
198
|
}
|
|
199
199
|
/**
|
|
200
200
|
* @type {TestData}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const adapter_js_1 = __importDefault(require("./adapter.js"));
|
|
8
|
+
class DartAdapter extends adapter_js_1.default {
|
|
9
|
+
getFilePath(t) {
|
|
10
|
+
if (t.title.startsWith('runDartTest[')) {
|
|
11
|
+
// Android: runDartTest[tests.path.to.test Test name]
|
|
12
|
+
const fileName = namespaceToFileName(t.title.split('[')[1].split(' ')[0]);
|
|
13
|
+
return fileName;
|
|
14
|
+
}
|
|
15
|
+
// iOS: RunnerUITests tests.path.to.test Test name
|
|
16
|
+
const parts = t.title.split(' ');
|
|
17
|
+
const pathToken = parts.length > 1 ? parts[1] : parts[0];
|
|
18
|
+
return namespaceToFileName(pathToken);
|
|
19
|
+
}
|
|
20
|
+
formatTest(t) {
|
|
21
|
+
if (t.title.startsWith('runDartTest[')) {
|
|
22
|
+
// Android: runDartTest[<path> <name>]
|
|
23
|
+
// First space is between the path and the test name; strip up to and including it, remove trailing ']'
|
|
24
|
+
const spaceIndex = t.title.indexOf(' ');
|
|
25
|
+
if (spaceIndex > -1) {
|
|
26
|
+
const pathToken = t.title.slice('runDartTest['.length, spaceIndex);
|
|
27
|
+
t.file = namespaceToFileName(pathToken);
|
|
28
|
+
t.title = t.title.slice(spaceIndex + 1).replace(/\]$/, '');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// iOS: <ClassName> <test.path> <test name>
|
|
33
|
+
// Skip both the classname token and the dot-separated test path token
|
|
34
|
+
const parts = t.title.split(' ');
|
|
35
|
+
if (parts.length > 2 && parts[1] && parts[1].includes('.')) {
|
|
36
|
+
t.file = namespaceToFileName(parts[1]);
|
|
37
|
+
t.title = parts.slice(2).join(' ');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const spaceIndex = t.title.indexOf(' ');
|
|
41
|
+
if (spaceIndex > -1) {
|
|
42
|
+
t.title = t.title.slice(spaceIndex + 1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// classname: cut everything after the last dot (inclusive)
|
|
47
|
+
if (t.suite_title && t.suite_title.includes('.')) {
|
|
48
|
+
const lastDot = t.suite_title.lastIndexOf('.');
|
|
49
|
+
t.suite_title = t.suite_title.slice(0, lastDot);
|
|
50
|
+
}
|
|
51
|
+
if (!t.file) {
|
|
52
|
+
t.file = namespaceToFileName(t.suite_title || '');
|
|
53
|
+
}
|
|
54
|
+
// detect params
|
|
55
|
+
const paramMatches = t.title.match(/\[(.*?)\]/g);
|
|
56
|
+
if (paramMatches) {
|
|
57
|
+
const params = paramMatches.map((_match, index) => `param${index + 1}`);
|
|
58
|
+
if (params.length === 1)
|
|
59
|
+
params[0] = 'param';
|
|
60
|
+
let paramIndex = 0;
|
|
61
|
+
t.title = t.title.replace(/\[(.*?)\]/g, () => {
|
|
62
|
+
if (params.length < 2)
|
|
63
|
+
return `\${param}`;
|
|
64
|
+
const paramName = params[paramIndex] || `param${paramIndex + 1}`;
|
|
65
|
+
paramIndex++;
|
|
66
|
+
return `\${${paramName}}`;
|
|
67
|
+
});
|
|
68
|
+
const example = {};
|
|
69
|
+
paramMatches.forEach((match, index) => {
|
|
70
|
+
example[params[index]] = match.replace(/[[\]]/g, '');
|
|
71
|
+
});
|
|
72
|
+
t.example = example;
|
|
73
|
+
}
|
|
74
|
+
return t;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function namespaceToFileName(fileName) {
|
|
78
|
+
let testName = fileName;
|
|
79
|
+
// If it's already an extracted test name (contains dots but no runDartTest prefix)
|
|
80
|
+
if (fileName.includes('.') && !fileName.startsWith('runDartTest')) {
|
|
81
|
+
// Take only the first part before any spaces (the actual test path)
|
|
82
|
+
testName = fileName.split(' ')[0];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// Legacy handling for full runDartTest[...] format
|
|
86
|
+
const dartMatch = fileName.match(/runDartTest\[(.+?) /);
|
|
87
|
+
if (dartMatch) {
|
|
88
|
+
testName = dartMatch[1];
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const parts = fileName.split(' ');
|
|
92
|
+
if (parts.length > 1) {
|
|
93
|
+
testName = parts[1];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const fileParts = testName.split('.');
|
|
98
|
+
fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
|
|
99
|
+
return `${fileParts.join(path_1.default.sep)}.dart`;
|
|
100
|
+
}
|
|
101
|
+
module.exports = DartAdapter;
|
|
@@ -10,6 +10,7 @@ const python_js_1 = __importDefault(require("./python.js"));
|
|
|
10
10
|
const ruby_js_1 = __importDefault(require("./ruby.js"));
|
|
11
11
|
const csharp_js_1 = __importDefault(require("./csharp.js"));
|
|
12
12
|
const kotlin_js_1 = __importDefault(require("./kotlin.js"));
|
|
13
|
+
const dart_js_1 = __importDefault(require("./dart.js"));
|
|
13
14
|
function AdapterFactory(lang, opts) {
|
|
14
15
|
if (lang === 'java') {
|
|
15
16
|
return new java_js_1.default(opts);
|
|
@@ -29,6 +30,9 @@ function AdapterFactory(lang, opts) {
|
|
|
29
30
|
if (lang === 'kotlin') {
|
|
30
31
|
return new kotlin_js_1.default(opts);
|
|
31
32
|
}
|
|
33
|
+
if (lang === 'dart') {
|
|
34
|
+
return new dart_js_1.default(opts);
|
|
35
|
+
}
|
|
32
36
|
return new adapter_js_1.default(opts);
|
|
33
37
|
}
|
|
34
38
|
module.exports = AdapterFactory;
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -147,6 +147,13 @@ class TestomatioPipe {
|
|
|
147
147
|
// add test ID + run ID
|
|
148
148
|
if (data.rid)
|
|
149
149
|
data.rid = `${this.runId}-${data.rid}`;
|
|
150
|
+
// convert timestamp to seconds
|
|
151
|
+
if (data.timestamp > 1e11) {
|
|
152
|
+
if (data.timestamp > 1e14)
|
|
153
|
+
data.timestamp = Math.floor(data.timestamp / 1e6); // convert microseconds
|
|
154
|
+
else if (data.timestamp > 1e11)
|
|
155
|
+
data.timestamp = Math.floor(data.timestamp / 1e3); // convert milliseconds
|
|
156
|
+
}
|
|
150
157
|
if (!process.env.TESTOMATIO_STACK_PASSED && data.status === constants_js_1.STATUS.PASSED) {
|
|
151
158
|
data.stack = null;
|
|
152
159
|
}
|
|
@@ -522,6 +529,7 @@ class TestomatioPipe {
|
|
|
522
529
|
status_event,
|
|
523
530
|
detach: params.detach,
|
|
524
531
|
tests: params.tests,
|
|
532
|
+
...(params.force_finish_shared_run && { force_finish_shared_run: true }),
|
|
525
533
|
},
|
|
526
534
|
});
|
|
527
535
|
if (this.runUrl) {
|
package/lib/utils/utils.js
CHANGED
|
@@ -303,6 +303,24 @@ const fetchIdFromOutput = output => {
|
|
|
303
303
|
return output.match(TID_FULL_PATTERN)?.[2];
|
|
304
304
|
};
|
|
305
305
|
exports.fetchIdFromOutput = fetchIdFromOutput;
|
|
306
|
+
const findDartTestLine = (lines, expectedTitle) => {
|
|
307
|
+
const testFunctions = ['patrolTest', 'testWidgets'];
|
|
308
|
+
const quotedTitles = [`'${expectedTitle}',`, `"${expectedTitle}",`, `r'${expectedTitle}',`, `r"${expectedTitle}",`];
|
|
309
|
+
return lines.findIndex((_line, index) => {
|
|
310
|
+
const declaration = lines
|
|
311
|
+
.slice(index, index + 5)
|
|
312
|
+
.map(line => line.trim())
|
|
313
|
+
.join(' ');
|
|
314
|
+
const functionName = testFunctions.find(name => declaration.startsWith(name));
|
|
315
|
+
if (!functionName)
|
|
316
|
+
return false;
|
|
317
|
+
const argumentsList = declaration.slice(functionName.length).trimStart();
|
|
318
|
+
if (!argumentsList.startsWith('('))
|
|
319
|
+
return false;
|
|
320
|
+
const firstArgument = argumentsList.slice(1).trimStart();
|
|
321
|
+
return quotedTitles.some(title => firstArgument.startsWith(title));
|
|
322
|
+
});
|
|
323
|
+
};
|
|
306
324
|
const fetchSourceCode = (contents, opts = {}) => {
|
|
307
325
|
if (!opts.title && !opts.line)
|
|
308
326
|
return '';
|
|
@@ -387,6 +405,31 @@ const fetchSourceCode = (contents, opts = {}) => {
|
|
|
387
405
|
}
|
|
388
406
|
}
|
|
389
407
|
}
|
|
408
|
+
else if (opts.lang === 'dart') {
|
|
409
|
+
// For Dart, locate the specific patrolTest/testWidgets block by title first —
|
|
410
|
+
// otherwise every test sharing the same main() gets the same @T comment.
|
|
411
|
+
const rawTitle = opts.title || '';
|
|
412
|
+
let dartTestTitle = '';
|
|
413
|
+
if (rawTitle.startsWith('runDartTest[')) {
|
|
414
|
+
// Android: runDartTest[<path> <test name>]
|
|
415
|
+
const spaceIndex = rawTitle.indexOf(' ');
|
|
416
|
+
if (spaceIndex > -1) {
|
|
417
|
+
dartTestTitle = rawTitle.slice(spaceIndex + 1).replace(/\]$/, '');
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
// iOS: <ClassName> <test.path> <test name>
|
|
422
|
+
const parts = rawTitle.split(' ');
|
|
423
|
+
if (parts.length > 2 && parts[1] && parts[1].includes('.')) {
|
|
424
|
+
dartTestTitle = parts.slice(2).join(' ');
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
let testLineIndex = -1;
|
|
428
|
+
if (dartTestTitle) {
|
|
429
|
+
testLineIndex = findDartTestLine(lines, dartTestTitle);
|
|
430
|
+
}
|
|
431
|
+
lineIndex = testLineIndex;
|
|
432
|
+
}
|
|
390
433
|
else {
|
|
391
434
|
lineIndex = lines.findIndex(l => l.includes(title));
|
|
392
435
|
}
|
|
@@ -401,8 +444,8 @@ const fetchSourceCode = (contents, opts = {}) => {
|
|
|
401
444
|
for (let i = lineIndex; i < lineIndex + limit; i++) {
|
|
402
445
|
if (lines[i] === undefined)
|
|
403
446
|
continue;
|
|
404
|
-
// Track brace depth for C# to stop after method closes
|
|
405
|
-
if (opts.lang === 'csharp') {
|
|
447
|
+
// Track brace depth for C# and Dart to stop after method/main closes
|
|
448
|
+
if (opts.lang === 'csharp' || opts.lang === 'dart') {
|
|
406
449
|
const line = lines[i];
|
|
407
450
|
// Count opening and closing braces
|
|
408
451
|
const openBraces = (line.match(/\{/g) || []).length;
|
package/lib/xmlReader.js
CHANGED
|
@@ -405,6 +405,8 @@ class XmlReader {
|
|
|
405
405
|
this.stats.language = 'ts';
|
|
406
406
|
if (file.endsWith('.cs'))
|
|
407
407
|
this.stats.language = 'csharp';
|
|
408
|
+
if (file.endsWith('.dart'))
|
|
409
|
+
this.stats.language = 'dart';
|
|
408
410
|
}
|
|
409
411
|
if (!fs_1.default.existsSync(file)) {
|
|
410
412
|
debug('Failed to open file with the source code', file);
|
package/package.json
CHANGED
package/src/bin/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import TestomatClient from '../client.js';
|
|
|
8
8
|
import XmlReader from '../xmlReader.js';
|
|
9
9
|
import AllureReader from '../allureReader.js';
|
|
10
10
|
import { APP_PREFIX, STATUS, DEBUG_FILE, BATCH_MODE } from '../constants.js';
|
|
11
|
-
import { cleanLatestRunId, getPackageVersion, applyFilter } from '../utils/utils.js';
|
|
11
|
+
import { cleanLatestRunId, getPackageVersion, applyFilter, transformEnvVarToBoolean } from '../utils/utils.js';
|
|
12
12
|
import { config } from '../config.js';
|
|
13
13
|
import { readLatestRunId } from '../utils/utils.js';
|
|
14
14
|
import pc from 'picocolors';
|
|
@@ -54,6 +54,7 @@ program
|
|
|
54
54
|
.option('--kind <type>', 'Specify run type: automated, manual, or mixed')
|
|
55
55
|
.option('--filter <filter>', 'Scope the prepared run to tests matching the filter (no execution)')
|
|
56
56
|
.option('--format <format>', 'Machine-readable output: print only the run id to stdout (e.g. --format id)')
|
|
57
|
+
.option('--warn', 'Exit 0 instead of 1 when the filter matches no tests (warn only)')
|
|
57
58
|
.action(async opts => {
|
|
58
59
|
cleanLatestRunId();
|
|
59
60
|
|
|
@@ -69,7 +70,8 @@ program
|
|
|
69
70
|
const tests = await client.prepareRun({ pipe, pipeOptions: optsArray.join(':') });
|
|
70
71
|
if (!tests || tests.length === 0) {
|
|
71
72
|
log.warn(pc.yellow('No tests found for the filter. Run not created.'));
|
|
72
|
-
|
|
73
|
+
// --warn treats an empty match as a normal outcome (e.g. a PR touching no mapped files)
|
|
74
|
+
process.exit(opts.warn ? 0 : 1);
|
|
73
75
|
}
|
|
74
76
|
createRunParams.configuration = {
|
|
75
77
|
tests: tests.filter(id => id.startsWith('T')).map(id => id.slice(1)),
|
|
@@ -105,8 +107,11 @@ program
|
|
|
105
107
|
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
|
|
106
108
|
const client = new TestomatClient({ apiKey });
|
|
107
109
|
|
|
110
|
+
const finishParams = {};
|
|
111
|
+
if (transformEnvVarToBoolean(process.env.TESTOMATIO_FINISH_SHARED_RUN)) finishParams.force_finish_shared_run = true;
|
|
112
|
+
|
|
108
113
|
// @ts-ignore
|
|
109
|
-
client.updateRunStatus(STATUS.FINISHED).then(() => {
|
|
114
|
+
client.updateRunStatus(STATUS.FINISHED, finishParams).then(() => {
|
|
110
115
|
process.exit(0);
|
|
111
116
|
});
|
|
112
117
|
});
|
|
@@ -127,6 +132,7 @@ program
|
|
|
127
132
|
(value, prev) => prev.concat([value]),
|
|
128
133
|
[],
|
|
129
134
|
)
|
|
135
|
+
.option('--warn', 'Exit 0 instead of 1 when the filter matches no tests (warn only)')
|
|
130
136
|
.action(async (command, opts) => {
|
|
131
137
|
if (opts.remote) {
|
|
132
138
|
if (opts.filterList) {
|
|
@@ -162,8 +168,8 @@ program
|
|
|
162
168
|
if (!tests || tests.length === 0) {
|
|
163
169
|
log.warn( pc.yellow('No tests found.'));
|
|
164
170
|
// Exit non-zero on --filter-list so scripts can detect "nothing to run"
|
|
165
|
-
// via $? and skip launching the runner.
|
|
166
|
-
if (opts.filterList) process.exit(1);
|
|
171
|
+
// via $? and skip launching the runner. --warn downgrades it to 0.
|
|
172
|
+
if (opts.filterList && !opts.warn) process.exit(1);
|
|
167
173
|
return;
|
|
168
174
|
}
|
|
169
175
|
|
package/src/client.js
CHANGED
|
@@ -206,9 +206,9 @@ class Client {
|
|
|
206
206
|
suite_title: 'Unknown suite',
|
|
207
207
|
};
|
|
208
208
|
|
|
209
|
-
// Add timestamp if not already present (
|
|
209
|
+
// Add timestamp if not already present (Unix seconds)
|
|
210
210
|
if (!testData.timestamp && !process.env.TESTOMATIO_NO_TIMESTAMP) {
|
|
211
|
-
testData.timestamp = Math.floor((performance.timeOrigin + performance.now())
|
|
211
|
+
testData.timestamp = Math.floor((performance.timeOrigin + performance.now()) / 1000);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import Adapter from './adapter.js';
|
|
3
|
+
|
|
4
|
+
class DartAdapter extends Adapter {
|
|
5
|
+
|
|
6
|
+
getFilePath(t) {
|
|
7
|
+
if (t.title.startsWith('runDartTest[')) {
|
|
8
|
+
// Android: runDartTest[tests.path.to.test Test name]
|
|
9
|
+
const fileName = namespaceToFileName(t.title.split('[')[1].split(' ')[0]);
|
|
10
|
+
return fileName;
|
|
11
|
+
}
|
|
12
|
+
// iOS: RunnerUITests tests.path.to.test Test name
|
|
13
|
+
const parts = t.title.split(' ');
|
|
14
|
+
const pathToken = parts.length > 1 ? parts[1] : parts[0];
|
|
15
|
+
return namespaceToFileName(pathToken);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
formatTest(t) {
|
|
19
|
+
if (t.title.startsWith('runDartTest[')) {
|
|
20
|
+
// Android: runDartTest[<path> <name>]
|
|
21
|
+
// First space is between the path and the test name; strip up to and including it, remove trailing ']'
|
|
22
|
+
const spaceIndex = t.title.indexOf(' ');
|
|
23
|
+
if (spaceIndex > -1) {
|
|
24
|
+
const pathToken = t.title.slice('runDartTest['.length, spaceIndex);
|
|
25
|
+
t.file = namespaceToFileName(pathToken);
|
|
26
|
+
t.title = t.title.slice(spaceIndex + 1).replace(/\]$/, '');
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
// iOS: <ClassName> <test.path> <test name>
|
|
30
|
+
// Skip both the classname token and the dot-separated test path token
|
|
31
|
+
const parts = t.title.split(' ');
|
|
32
|
+
if (parts.length > 2 && parts[1] && parts[1].includes('.')) {
|
|
33
|
+
t.file = namespaceToFileName(parts[1]);
|
|
34
|
+
t.title = parts.slice(2).join(' ');
|
|
35
|
+
} else {
|
|
36
|
+
const spaceIndex = t.title.indexOf(' ');
|
|
37
|
+
if (spaceIndex > -1) {
|
|
38
|
+
t.title = t.title.slice(spaceIndex + 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// classname: cut everything after the last dot (inclusive)
|
|
44
|
+
if (t.suite_title && t.suite_title.includes('.')) {
|
|
45
|
+
const lastDot = t.suite_title.lastIndexOf('.');
|
|
46
|
+
t.suite_title = t.suite_title.slice(0, lastDot);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!t.file) {
|
|
50
|
+
t.file = namespaceToFileName(t.suite_title || '');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// detect params
|
|
54
|
+
const paramMatches = t.title.match(/\[(.*?)\]/g);
|
|
55
|
+
|
|
56
|
+
if (paramMatches) {
|
|
57
|
+
const params = paramMatches.map((_match, index) => `param${index + 1}`);
|
|
58
|
+
if (params.length === 1) params[0] = 'param';
|
|
59
|
+
let paramIndex = 0;
|
|
60
|
+
|
|
61
|
+
t.title = t.title.replace(/\[(.*?)\]/g, () => {
|
|
62
|
+
if (params.length < 2) return `\${param}`;
|
|
63
|
+
const paramName = params[paramIndex] || `param${paramIndex + 1}`;
|
|
64
|
+
paramIndex++;
|
|
65
|
+
return `\${${paramName}}`;
|
|
66
|
+
});
|
|
67
|
+
const example = {};
|
|
68
|
+
paramMatches.forEach((match, index) => {
|
|
69
|
+
example[params[index]] = match.replace(/[[\]]/g, '');
|
|
70
|
+
});
|
|
71
|
+
t.example = example;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return t;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function namespaceToFileName(fileName) {
|
|
79
|
+
let testName = fileName;
|
|
80
|
+
|
|
81
|
+
// If it's already an extracted test name (contains dots but no runDartTest prefix)
|
|
82
|
+
if (fileName.includes('.') && !fileName.startsWith('runDartTest')) {
|
|
83
|
+
// Take only the first part before any spaces (the actual test path)
|
|
84
|
+
testName = fileName.split(' ')[0];
|
|
85
|
+
} else {
|
|
86
|
+
// Legacy handling for full runDartTest[...] format
|
|
87
|
+
const dartMatch = fileName.match(/runDartTest\[(.+?) /);
|
|
88
|
+
if (dartMatch) {
|
|
89
|
+
testName = dartMatch[1];
|
|
90
|
+
} else {
|
|
91
|
+
const parts = fileName.split(' ');
|
|
92
|
+
if (parts.length > 1) {
|
|
93
|
+
testName = parts[1];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const fileParts = testName.split('.');
|
|
99
|
+
fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
|
|
100
|
+
return `${fileParts.join(path.sep)}.dart`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default DartAdapter;
|
|
@@ -5,6 +5,7 @@ import PythonAdapter from './python.js';
|
|
|
5
5
|
import RubyAdapter from './ruby.js';
|
|
6
6
|
import CSharpAdapter from './csharp.js';
|
|
7
7
|
import KotlinAdapter from './kotlin.js';
|
|
8
|
+
import DartAdapter from './dart.js';
|
|
8
9
|
|
|
9
10
|
function AdapterFactory(lang, opts) {
|
|
10
11
|
if (lang === 'java') {
|
|
@@ -25,6 +26,9 @@ function AdapterFactory(lang, opts) {
|
|
|
25
26
|
if (lang === 'kotlin') {
|
|
26
27
|
return new KotlinAdapter(opts);
|
|
27
28
|
}
|
|
29
|
+
if (lang === 'dart') {
|
|
30
|
+
return new DartAdapter(opts);
|
|
31
|
+
}
|
|
28
32
|
|
|
29
33
|
return new Adapter(opts);
|
|
30
34
|
}
|
package/src/pipe/testomatio.js
CHANGED
|
@@ -167,6 +167,12 @@ class TestomatioPipe {
|
|
|
167
167
|
// add test ID + run ID
|
|
168
168
|
if (data.rid) data.rid = `${this.runId}-${data.rid}`;
|
|
169
169
|
|
|
170
|
+
// convert timestamp to seconds
|
|
171
|
+
if (data.timestamp > 1e11) {
|
|
172
|
+
if (data.timestamp > 1e14) data.timestamp = Math.floor(data.timestamp / 1e6); // convert microseconds
|
|
173
|
+
else if (data.timestamp > 1e11) data.timestamp = Math.floor(data.timestamp / 1e3); // convert milliseconds
|
|
174
|
+
}
|
|
175
|
+
|
|
170
176
|
if (!process.env.TESTOMATIO_STACK_PASSED && data.status === STATUS.PASSED) {
|
|
171
177
|
data.stack = null;
|
|
172
178
|
}
|
|
@@ -569,6 +575,7 @@ class TestomatioPipe {
|
|
|
569
575
|
status_event,
|
|
570
576
|
detach: params.detach,
|
|
571
577
|
tests: params.tests,
|
|
578
|
+
...(params.force_finish_shared_run && { force_finish_shared_run: true }),
|
|
572
579
|
},
|
|
573
580
|
});
|
|
574
581
|
|
package/src/utils/utils.js
CHANGED
|
@@ -271,6 +271,26 @@ const fetchIdFromOutput = output => {
|
|
|
271
271
|
return output.match(TID_FULL_PATTERN)?.[2];
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
+
const findDartTestLine = (lines, expectedTitle) => {
|
|
275
|
+
const testFunctions = ['patrolTest', 'testWidgets'];
|
|
276
|
+
const quotedTitles = [`'${expectedTitle}',`, `"${expectedTitle}",`, `r'${expectedTitle}',`, `r"${expectedTitle}",`];
|
|
277
|
+
|
|
278
|
+
return lines.findIndex((_line, index) => {
|
|
279
|
+
const declaration = lines
|
|
280
|
+
.slice(index, index + 5)
|
|
281
|
+
.map(line => line.trim())
|
|
282
|
+
.join(' ');
|
|
283
|
+
const functionName = testFunctions.find(name => declaration.startsWith(name));
|
|
284
|
+
if (!functionName) return false;
|
|
285
|
+
|
|
286
|
+
const argumentsList = declaration.slice(functionName.length).trimStart();
|
|
287
|
+
if (!argumentsList.startsWith('(')) return false;
|
|
288
|
+
|
|
289
|
+
const firstArgument = argumentsList.slice(1).trimStart();
|
|
290
|
+
return quotedTitles.some(title => firstArgument.startsWith(title));
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
|
|
274
294
|
const fetchSourceCode = (contents, opts = {}) => {
|
|
275
295
|
if (!opts.title && !opts.line) return '';
|
|
276
296
|
|
|
@@ -354,6 +374,32 @@ const fetchSourceCode = (contents, opts = {}) => {
|
|
|
354
374
|
}
|
|
355
375
|
}
|
|
356
376
|
}
|
|
377
|
+
} else if (opts.lang === 'dart') {
|
|
378
|
+
// For Dart, locate the specific patrolTest/testWidgets block by title first —
|
|
379
|
+
// otherwise every test sharing the same main() gets the same @T comment.
|
|
380
|
+
const rawTitle = opts.title || '';
|
|
381
|
+
let dartTestTitle = '';
|
|
382
|
+
|
|
383
|
+
if (rawTitle.startsWith('runDartTest[')) {
|
|
384
|
+
// Android: runDartTest[<path> <test name>]
|
|
385
|
+
const spaceIndex = rawTitle.indexOf(' ');
|
|
386
|
+
if (spaceIndex > -1) {
|
|
387
|
+
dartTestTitle = rawTitle.slice(spaceIndex + 1).replace(/\]$/, '');
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
// iOS: <ClassName> <test.path> <test name>
|
|
391
|
+
const parts = rawTitle.split(' ');
|
|
392
|
+
if (parts.length > 2 && parts[1] && parts[1].includes('.')) {
|
|
393
|
+
dartTestTitle = parts.slice(2).join(' ');
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let testLineIndex = -1;
|
|
398
|
+
if (dartTestTitle) {
|
|
399
|
+
testLineIndex = findDartTestLine(lines, dartTestTitle);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
lineIndex = testLineIndex;
|
|
357
403
|
} else {
|
|
358
404
|
lineIndex = lines.findIndex(l => l.includes(title));
|
|
359
405
|
}
|
|
@@ -371,8 +417,8 @@ const fetchSourceCode = (contents, opts = {}) => {
|
|
|
371
417
|
for (let i = lineIndex; i < lineIndex + limit; i++) {
|
|
372
418
|
if (lines[i] === undefined) continue;
|
|
373
419
|
|
|
374
|
-
// Track brace depth for C# to stop after method closes
|
|
375
|
-
if (opts.lang === 'csharp') {
|
|
420
|
+
// Track brace depth for C# and Dart to stop after method/main closes
|
|
421
|
+
if (opts.lang === 'csharp' || opts.lang === 'dart') {
|
|
376
422
|
const line = lines[i];
|
|
377
423
|
// Count opening and closing braces
|
|
378
424
|
const openBraces = (line.match(/\{/g) || []).length;
|
package/src/xmlReader.js
CHANGED
|
@@ -472,6 +472,7 @@ class XmlReader {
|
|
|
472
472
|
if (file.endsWith('.js')) this.stats.language = 'js';
|
|
473
473
|
if (file.endsWith('.ts')) this.stats.language = 'ts';
|
|
474
474
|
if (file.endsWith('.cs')) this.stats.language = 'csharp';
|
|
475
|
+
if (file.endsWith('.dart')) this.stats.language = 'dart';
|
|
475
476
|
}
|
|
476
477
|
|
|
477
478
|
if (!fs.existsSync(file)) {
|
package/types/types.d.ts
CHANGED
|
@@ -274,6 +274,9 @@ export interface RunData {
|
|
|
274
274
|
* An array of `TestData` objects representing the individual test cases in the test run.
|
|
275
275
|
* Used for JUNit report when we don't send the tests in realtime but in a batch as a part of final result */
|
|
276
276
|
tests?: TestData[];
|
|
277
|
+
|
|
278
|
+
/** Force-finish a shared run even if other participants haven't finished yet. Set via `TESTOMATIO_FINISH_SHARED_RUN`. */
|
|
279
|
+
force_finish_shared_run?: boolean;
|
|
277
280
|
}
|
|
278
281
|
|
|
279
282
|
export enum TestStatus {
|