@vitest/coverage-v8 2.1.0 → 2.1.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.
- package/dist/provider.d.ts +23 -5
- package/dist/provider.js +622 -584
- package/package.json +6 -6
package/dist/provider.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { existsSync, promises
|
2
|
-
import { pathToFileURL, fileURLToPath
|
1
|
+
import { existsSync, promises, readdirSync, writeFileSync } from 'node:fs';
|
2
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
3
3
|
import require$$0 from 'assert';
|
4
4
|
import require$$2 from 'util';
|
5
5
|
import require$$3 from 'path';
|
@@ -22,248 +22,253 @@ import { coverageConfigDefaults } from 'vitest/config';
|
|
22
22
|
import { BaseCoverageProvider } from 'vitest/coverage';
|
23
23
|
import _TestExclude from 'test-exclude';
|
24
24
|
|
25
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
26
|
-
|
27
25
|
function getDefaultExportFromCjs (x) {
|
28
26
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
29
27
|
}
|
30
28
|
|
31
|
-
var convertSourceMap
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
29
|
+
var convertSourceMap = {};
|
30
|
+
|
31
|
+
var hasRequiredConvertSourceMap;
|
32
|
+
|
33
|
+
function requireConvertSourceMap () {
|
34
|
+
if (hasRequiredConvertSourceMap) return convertSourceMap;
|
35
|
+
hasRequiredConvertSourceMap = 1;
|
36
|
+
(function (exports) {
|
37
|
+
|
38
|
+
Object.defineProperty(exports, 'commentRegex', {
|
39
|
+
get: function getCommentRegex () {
|
40
|
+
// Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
|
41
|
+
return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
|
46
|
+
Object.defineProperty(exports, 'mapFileCommentRegex', {
|
47
|
+
get: function getMapFileCommentRegex () {
|
48
|
+
// Matches sourceMappingURL in either // or /* comment styles.
|
49
|
+
return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
|
50
|
+
}
|
51
|
+
});
|
52
|
+
|
53
|
+
var decodeBase64;
|
54
|
+
if (typeof Buffer !== 'undefined') {
|
55
|
+
if (typeof Buffer.from === 'function') {
|
56
|
+
decodeBase64 = decodeBase64WithBufferFrom;
|
57
|
+
} else {
|
58
|
+
decodeBase64 = decodeBase64WithNewBuffer;
|
59
|
+
}
|
60
|
+
} else {
|
61
|
+
decodeBase64 = decodeBase64WithAtob;
|
62
|
+
}
|
63
|
+
|
64
|
+
function decodeBase64WithBufferFrom(base64) {
|
65
|
+
return Buffer.from(base64, 'base64').toString();
|
66
|
+
}
|
67
|
+
|
68
|
+
function decodeBase64WithNewBuffer(base64) {
|
69
|
+
if (typeof value === 'number') {
|
70
|
+
throw new TypeError('The value to decode must not be of type number.');
|
71
|
+
}
|
72
|
+
return new Buffer(base64, 'base64').toString();
|
73
|
+
}
|
74
|
+
|
75
|
+
function decodeBase64WithAtob(base64) {
|
76
|
+
return decodeURIComponent(escape(atob(base64)));
|
77
|
+
}
|
78
|
+
|
79
|
+
function stripComment(sm) {
|
80
|
+
return sm.split(',').pop();
|
81
|
+
}
|
82
|
+
|
83
|
+
function readFromFileMap(sm, read) {
|
84
|
+
var r = exports.mapFileCommentRegex.exec(sm);
|
85
|
+
// for some odd reason //# .. captures in 1 and /* .. */ in 2
|
86
|
+
var filename = r[1] || r[2];
|
87
|
+
|
88
|
+
try {
|
89
|
+
var sm = read(filename);
|
90
|
+
if (sm != null && typeof sm.catch === 'function') {
|
91
|
+
return sm.catch(throwError);
|
92
|
+
} else {
|
93
|
+
return sm;
|
94
|
+
}
|
95
|
+
} catch (e) {
|
96
|
+
throwError(e);
|
97
|
+
}
|
98
|
+
|
99
|
+
function throwError(e) {
|
100
|
+
throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
function Converter (sm, opts) {
|
105
|
+
opts = opts || {};
|
106
|
+
|
107
|
+
if (opts.hasComment) {
|
108
|
+
sm = stripComment(sm);
|
109
|
+
}
|
110
|
+
|
111
|
+
if (opts.encoding === 'base64') {
|
112
|
+
sm = decodeBase64(sm);
|
113
|
+
} else if (opts.encoding === 'uri') {
|
114
|
+
sm = decodeURIComponent(sm);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (opts.isJSON || opts.encoding) {
|
118
|
+
sm = JSON.parse(sm);
|
119
|
+
}
|
120
|
+
|
121
|
+
this.sourcemap = sm;
|
122
|
+
}
|
123
|
+
|
124
|
+
Converter.prototype.toJSON = function (space) {
|
125
|
+
return JSON.stringify(this.sourcemap, null, space);
|
126
|
+
};
|
127
|
+
|
128
|
+
if (typeof Buffer !== 'undefined') {
|
129
|
+
if (typeof Buffer.from === 'function') {
|
130
|
+
Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
|
131
|
+
} else {
|
132
|
+
Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
|
133
|
+
}
|
134
|
+
} else {
|
135
|
+
Converter.prototype.toBase64 = encodeBase64WithBtoa;
|
136
|
+
}
|
137
|
+
|
138
|
+
function encodeBase64WithBufferFrom() {
|
139
|
+
var json = this.toJSON();
|
140
|
+
return Buffer.from(json, 'utf8').toString('base64');
|
141
|
+
}
|
142
|
+
|
143
|
+
function encodeBase64WithNewBuffer() {
|
144
|
+
var json = this.toJSON();
|
145
|
+
if (typeof json === 'number') {
|
146
|
+
throw new TypeError('The json to encode must not be of type number.');
|
147
|
+
}
|
148
|
+
return new Buffer(json, 'utf8').toString('base64');
|
149
|
+
}
|
150
|
+
|
151
|
+
function encodeBase64WithBtoa() {
|
152
|
+
var json = this.toJSON();
|
153
|
+
return btoa(unescape(encodeURIComponent(json)));
|
154
|
+
}
|
155
|
+
|
156
|
+
Converter.prototype.toURI = function () {
|
157
|
+
var json = this.toJSON();
|
158
|
+
return encodeURIComponent(json);
|
159
|
+
};
|
160
|
+
|
161
|
+
Converter.prototype.toComment = function (options) {
|
162
|
+
var encoding, content, data;
|
163
|
+
if (options != null && options.encoding === 'uri') {
|
164
|
+
encoding = '';
|
165
|
+
content = this.toURI();
|
166
|
+
} else {
|
167
|
+
encoding = ';base64';
|
168
|
+
content = this.toBase64();
|
169
|
+
}
|
170
|
+
data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
|
171
|
+
return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
|
172
|
+
};
|
173
|
+
|
174
|
+
// returns copy instead of original
|
175
|
+
Converter.prototype.toObject = function () {
|
176
|
+
return JSON.parse(this.toJSON());
|
177
|
+
};
|
178
|
+
|
179
|
+
Converter.prototype.addProperty = function (key, value) {
|
180
|
+
if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
|
181
|
+
return this.setProperty(key, value);
|
182
|
+
};
|
183
|
+
|
184
|
+
Converter.prototype.setProperty = function (key, value) {
|
185
|
+
this.sourcemap[key] = value;
|
186
|
+
return this;
|
187
|
+
};
|
188
|
+
|
189
|
+
Converter.prototype.getProperty = function (key) {
|
190
|
+
return this.sourcemap[key];
|
191
|
+
};
|
192
|
+
|
193
|
+
exports.fromObject = function (obj) {
|
194
|
+
return new Converter(obj);
|
195
|
+
};
|
196
|
+
|
197
|
+
exports.fromJSON = function (json) {
|
198
|
+
return new Converter(json, { isJSON: true });
|
199
|
+
};
|
200
|
+
|
201
|
+
exports.fromURI = function (uri) {
|
202
|
+
return new Converter(uri, { encoding: 'uri' });
|
203
|
+
};
|
204
|
+
|
205
|
+
exports.fromBase64 = function (base64) {
|
206
|
+
return new Converter(base64, { encoding: 'base64' });
|
207
|
+
};
|
208
|
+
|
209
|
+
exports.fromComment = function (comment) {
|
210
|
+
var m, encoding;
|
211
|
+
comment = comment
|
212
|
+
.replace(/^\/\*/g, '//')
|
213
|
+
.replace(/\*\/$/g, '');
|
214
|
+
m = exports.commentRegex.exec(comment);
|
215
|
+
encoding = m && m[4] || 'uri';
|
216
|
+
return new Converter(comment, { encoding: encoding, hasComment: true });
|
217
|
+
};
|
218
|
+
|
219
|
+
function makeConverter(sm) {
|
220
|
+
return new Converter(sm, { isJSON: true });
|
221
|
+
}
|
222
|
+
|
223
|
+
exports.fromMapFileComment = function (comment, read) {
|
224
|
+
if (typeof read === 'string') {
|
225
|
+
throw new Error(
|
226
|
+
'String directory paths are no longer supported with `fromMapFileComment`\n' +
|
227
|
+
'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
|
228
|
+
)
|
229
|
+
}
|
230
|
+
|
231
|
+
var sm = readFromFileMap(comment, read);
|
232
|
+
if (sm != null && typeof sm.then === 'function') {
|
233
|
+
return sm.then(makeConverter);
|
234
|
+
} else {
|
235
|
+
return makeConverter(sm);
|
236
|
+
}
|
237
|
+
};
|
238
|
+
|
239
|
+
// Finds last sourcemap comment in file or returns null if none was found
|
240
|
+
exports.fromSource = function (content) {
|
241
|
+
var m = content.match(exports.commentRegex);
|
242
|
+
return m ? exports.fromComment(m.pop()) : null;
|
243
|
+
};
|
244
|
+
|
245
|
+
// Finds last sourcemap comment in file or returns null if none was found
|
246
|
+
exports.fromMapFileSource = function (content, read) {
|
247
|
+
if (typeof read === 'string') {
|
248
|
+
throw new Error(
|
249
|
+
'String directory paths are no longer supported with `fromMapFileSource`\n' +
|
250
|
+
'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
|
251
|
+
)
|
252
|
+
}
|
253
|
+
var m = content.match(exports.mapFileCommentRegex);
|
254
|
+
return m ? exports.fromMapFileComment(m.pop(), read) : null;
|
255
|
+
};
|
256
|
+
|
257
|
+
exports.removeComments = function (src) {
|
258
|
+
return src.replace(exports.commentRegex, '');
|
259
|
+
};
|
260
|
+
|
261
|
+
exports.removeMapFileComments = function (src) {
|
262
|
+
return src.replace(exports.mapFileCommentRegex, '');
|
263
|
+
};
|
264
|
+
|
265
|
+
exports.generateMapFileComment = function (file, options) {
|
266
|
+
var data = 'sourceMappingURL=' + file;
|
267
|
+
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
|
268
|
+
};
|
269
|
+
} (convertSourceMap));
|
270
|
+
return convertSourceMap;
|
271
|
+
}
|
267
272
|
|
268
273
|
var branch;
|
269
274
|
var hasRequiredBranch;
|
@@ -429,19 +434,21 @@ function requireRange () {
|
|
429
434
|
return range;
|
430
435
|
}
|
431
436
|
|
432
|
-
var traceMapping_umd = {exports: {}};
|
437
|
+
var traceMapping_umd$1 = {exports: {}};
|
438
|
+
|
439
|
+
var sourcemapCodec_umd$1 = {exports: {}};
|
433
440
|
|
434
|
-
var sourcemapCodec_umd =
|
441
|
+
var sourcemapCodec_umd = sourcemapCodec_umd$1.exports;
|
435
442
|
|
436
443
|
var hasRequiredSourcemapCodec_umd;
|
437
444
|
|
438
445
|
function requireSourcemapCodec_umd () {
|
439
|
-
if (hasRequiredSourcemapCodec_umd) return sourcemapCodec_umd.exports;
|
446
|
+
if (hasRequiredSourcemapCodec_umd) return sourcemapCodec_umd$1.exports;
|
440
447
|
hasRequiredSourcemapCodec_umd = 1;
|
441
448
|
(function (module, exports) {
|
442
449
|
(function (global, factory) {
|
443
450
|
factory(exports) ;
|
444
|
-
})(
|
451
|
+
})(sourcemapCodec_umd, (function (exports) {
|
445
452
|
const comma = ','.charCodeAt(0);
|
446
453
|
const semicolon = ';'.charCodeAt(0);
|
447
454
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
@@ -875,21 +882,23 @@ function requireSourcemapCodec_umd () {
|
|
875
882
|
|
876
883
|
}));
|
877
884
|
|
878
|
-
} (sourcemapCodec_umd, sourcemapCodec_umd.exports));
|
879
|
-
return sourcemapCodec_umd.exports;
|
885
|
+
} (sourcemapCodec_umd$1, sourcemapCodec_umd$1.exports));
|
886
|
+
return sourcemapCodec_umd$1.exports;
|
880
887
|
}
|
881
888
|
|
882
|
-
var resolveUri_umd = {exports: {}};
|
889
|
+
var resolveUri_umd$1 = {exports: {}};
|
890
|
+
|
891
|
+
var resolveUri_umd = resolveUri_umd$1.exports;
|
883
892
|
|
884
893
|
var hasRequiredResolveUri_umd;
|
885
894
|
|
886
895
|
function requireResolveUri_umd () {
|
887
|
-
if (hasRequiredResolveUri_umd) return resolveUri_umd.exports;
|
896
|
+
if (hasRequiredResolveUri_umd) return resolveUri_umd$1.exports;
|
888
897
|
hasRequiredResolveUri_umd = 1;
|
889
898
|
(function (module, exports) {
|
890
899
|
(function (global, factory) {
|
891
900
|
module.exports = factory() ;
|
892
|
-
})(
|
901
|
+
})(resolveUri_umd, (function () {
|
893
902
|
// Matches the scheme of a URL, eg "http://"
|
894
903
|
const schemeRegex = /^[\w+.-]+:\/\//;
|
895
904
|
/**
|
@@ -1134,19 +1143,21 @@ function requireResolveUri_umd () {
|
|
1134
1143
|
|
1135
1144
|
}));
|
1136
1145
|
|
1137
|
-
} (resolveUri_umd));
|
1138
|
-
return resolveUri_umd.exports;
|
1146
|
+
} (resolveUri_umd$1));
|
1147
|
+
return resolveUri_umd$1.exports;
|
1139
1148
|
}
|
1140
1149
|
|
1150
|
+
var traceMapping_umd = traceMapping_umd$1.exports;
|
1151
|
+
|
1141
1152
|
var hasRequiredTraceMapping_umd;
|
1142
1153
|
|
1143
1154
|
function requireTraceMapping_umd () {
|
1144
|
-
if (hasRequiredTraceMapping_umd) return traceMapping_umd.exports;
|
1155
|
+
if (hasRequiredTraceMapping_umd) return traceMapping_umd$1.exports;
|
1145
1156
|
hasRequiredTraceMapping_umd = 1;
|
1146
1157
|
(function (module, exports) {
|
1147
1158
|
(function (global, factory) {
|
1148
1159
|
factory(exports, requireSourcemapCodec_umd(), requireResolveUri_umd()) ;
|
1149
|
-
})(
|
1160
|
+
})(traceMapping_umd, (function (exports, sourcemapCodec, resolveUri) {
|
1150
1161
|
function resolve(input, base) {
|
1151
1162
|
// The base is always treated as a directory, if it's not empty.
|
1152
1163
|
// https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
|
@@ -1741,8 +1752,8 @@ function requireTraceMapping_umd () {
|
|
1741
1752
|
|
1742
1753
|
}));
|
1743
1754
|
|
1744
|
-
} (traceMapping_umd, traceMapping_umd.exports));
|
1745
|
-
return traceMapping_umd.exports;
|
1755
|
+
} (traceMapping_umd$1, traceMapping_umd$1.exports));
|
1756
|
+
return traceMapping_umd$1.exports;
|
1746
1757
|
}
|
1747
1758
|
|
1748
1759
|
var source;
|
@@ -2029,337 +2040,354 @@ function requireSource () {
|
|
2029
2040
|
return source;
|
2030
2041
|
}
|
2031
2042
|
|
2032
|
-
|
2033
|
-
|
2034
|
-
const convertSourceMap = convertSourceMap$1;
|
2035
|
-
const util = require$$2;
|
2036
|
-
const debuglog = util.debuglog('c8');
|
2037
|
-
const { dirname, isAbsolute: isAbsolute$1, join, resolve: resolve$1 } = require$$3;
|
2038
|
-
const { fileURLToPath } = require$$4;
|
2039
|
-
const CovBranch = requireBranch();
|
2040
|
-
const CovFunction = require_function();
|
2041
|
-
const CovSource = requireSource();
|
2042
|
-
const { sliceRange } = requireRange();
|
2043
|
-
const { readFileSync, promises } = require$$9;
|
2044
|
-
const readFile = promises.readFile;
|
2045
|
-
|
2046
|
-
const { TraceMap } = requireTraceMapping_umd();
|
2047
|
-
const isOlderNode10 = /^v10\.(([0-9]\.)|(1[0-5]\.))/u.test(process.version);
|
2048
|
-
const isNode8 = /^v8\./.test(process.version);
|
2049
|
-
|
2050
|
-
// Injected when Node.js is loading script into isolate pre Node 10.16.x.
|
2051
|
-
// see: https://github.com/nodejs/node/pull/21573.
|
2052
|
-
const cjsWrapperLength = isOlderNode10 ? require$$11.wrapper[0].length : 0;
|
2053
|
-
|
2054
|
-
var v8ToIstanbul$2 = class V8ToIstanbul {
|
2055
|
-
constructor (scriptPath, wrapperLength, sources, excludePath, excludeEmptyLines) {
|
2056
|
-
assert(typeof scriptPath === 'string', 'scriptPath must be a string');
|
2057
|
-
assert(!isNode8, 'This module does not support node 8 or lower, please upgrade to node 10');
|
2058
|
-
this.path = parsePath(scriptPath);
|
2059
|
-
this.wrapperLength = wrapperLength === undefined ? cjsWrapperLength : wrapperLength;
|
2060
|
-
this.excludePath = excludePath || (() => false);
|
2061
|
-
this.excludeEmptyLines = excludeEmptyLines === true;
|
2062
|
-
this.sources = sources || {};
|
2063
|
-
this.generatedLines = [];
|
2064
|
-
this.branches = {};
|
2065
|
-
this.functions = {};
|
2066
|
-
this.covSources = [];
|
2067
|
-
this.rawSourceMap = undefined;
|
2068
|
-
this.sourceMap = undefined;
|
2069
|
-
this.sourceTranspiled = undefined;
|
2070
|
-
// Indicate that this report was generated with placeholder data from
|
2071
|
-
// running --all:
|
2072
|
-
this.all = false;
|
2073
|
-
}
|
2043
|
+
var v8ToIstanbul$2;
|
2044
|
+
var hasRequiredV8ToIstanbul$1;
|
2074
2045
|
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2046
|
+
function requireV8ToIstanbul$1 () {
|
2047
|
+
if (hasRequiredV8ToIstanbul$1) return v8ToIstanbul$2;
|
2048
|
+
hasRequiredV8ToIstanbul$1 = 1;
|
2049
|
+
// Patch applied: https://github.com/istanbuljs/v8-to-istanbul/pull/244
|
2050
|
+
const assert = require$$0;
|
2051
|
+
const convertSourceMap = requireConvertSourceMap();
|
2052
|
+
const util = require$$2;
|
2053
|
+
const debuglog = util.debuglog('c8');
|
2054
|
+
const { dirname, isAbsolute, join, resolve } = require$$3;
|
2055
|
+
const { fileURLToPath } = require$$4;
|
2056
|
+
const CovBranch = requireBranch();
|
2057
|
+
const CovFunction = require_function();
|
2058
|
+
const CovSource = requireSource();
|
2059
|
+
const { sliceRange } = requireRange();
|
2060
|
+
const { readFileSync, promises } = require$$9;
|
2061
|
+
const readFile = promises.readFile;
|
2062
|
+
|
2063
|
+
const { TraceMap } = requireTraceMapping_umd();
|
2064
|
+
const isOlderNode10 = /^v10\.(([0-9]\.)|(1[0-5]\.))/u.test(process.version);
|
2065
|
+
const isNode8 = /^v8\./.test(process.version);
|
2066
|
+
|
2067
|
+
// Injected when Node.js is loading script into isolate pre Node 10.16.x.
|
2068
|
+
// see: https://github.com/nodejs/node/pull/21573.
|
2069
|
+
const cjsWrapperLength = isOlderNode10 ? require$$11.wrapper[0].length : 0;
|
2070
|
+
|
2071
|
+
v8ToIstanbul$2 = class V8ToIstanbul {
|
2072
|
+
constructor (scriptPath, wrapperLength, sources, excludePath, excludeEmptyLines) {
|
2073
|
+
assert(typeof scriptPath === 'string', 'scriptPath must be a string');
|
2074
|
+
assert(!isNode8, 'This module does not support node 8 or lower, please upgrade to node 10');
|
2075
|
+
this.path = parsePath(scriptPath);
|
2076
|
+
this.wrapperLength = wrapperLength === undefined ? cjsWrapperLength : wrapperLength;
|
2077
|
+
this.excludePath = excludePath || (() => false);
|
2078
|
+
this.excludeEmptyLines = excludeEmptyLines === true;
|
2079
|
+
this.sources = sources || {};
|
2080
|
+
this.generatedLines = [];
|
2081
|
+
this.branches = {};
|
2082
|
+
this.functions = {};
|
2083
|
+
this.covSources = [];
|
2084
|
+
this.rawSourceMap = undefined;
|
2085
|
+
this.sourceMap = undefined;
|
2086
|
+
this.sourceTranspiled = undefined;
|
2087
|
+
// Indicate that this report was generated with placeholder data from
|
2088
|
+
// running --all:
|
2089
|
+
this.all = false;
|
2090
|
+
}
|
2120
2091
|
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2092
|
+
async load () {
|
2093
|
+
const rawSource = this.sources.source || await readFile(this.path, 'utf8');
|
2094
|
+
this.rawSourceMap = this.sources.sourceMap ||
|
2095
|
+
// if we find a source-map (either inline, or a .map file) we load
|
2096
|
+
// both the transpiled and original source, both of which are used during
|
2097
|
+
// the backflips we perform to remap absolute to relative positions.
|
2098
|
+
convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, this._readFileFromDir.bind(this));
|
2099
|
+
|
2100
|
+
if (this.rawSourceMap) {
|
2101
|
+
if (this.rawSourceMap.sourcemap.sources.length > 1) {
|
2102
|
+
this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
|
2103
|
+
if (!this.sourceMap.sourcesContent) {
|
2104
|
+
this.sourceMap.sourcesContent = await this.sourcesContentFromSources();
|
2105
|
+
}
|
2106
|
+
this.covSources = this.sourceMap.sourcesContent.map((rawSource, i) => ({ source: new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null), path: this.sourceMap.sources[i] }));
|
2107
|
+
this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null);
|
2108
|
+
} else {
|
2109
|
+
const candidatePath = this.rawSourceMap.sourcemap.sources.length >= 1 ? this.rawSourceMap.sourcemap.sources[0] : this.rawSourceMap.sourcemap.file;
|
2110
|
+
this.path = this._resolveSource(this.rawSourceMap, candidatePath || this.path);
|
2111
|
+
this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
|
2112
|
+
|
2113
|
+
let originalRawSource;
|
2114
|
+
if (this.sources.sourceMap && this.sources.sourceMap.sourcemap && this.sources.sourceMap.sourcemap.sourcesContent && this.sources.sourceMap.sourcemap.sourcesContent.length === 1) {
|
2115
|
+
// If the sourcesContent field has been provided, return it rather than attempting
|
2116
|
+
// to load the original source from disk.
|
2117
|
+
// TODO: investigate whether there's ever a case where we hit this logic with 1:many sources.
|
2118
|
+
originalRawSource = this.sources.sourceMap.sourcemap.sourcesContent[0];
|
2119
|
+
} else if (this.sources.originalSource) {
|
2120
|
+
// Original source may be populated on the sources object.
|
2121
|
+
originalRawSource = this.sources.originalSource;
|
2122
|
+
} else if (this.sourceMap.sourcesContent && this.sourceMap.sourcesContent[0]) {
|
2123
|
+
// perhaps we loaded sourcesContent was populated by an inline source map, or .map file?
|
2124
|
+
// TODO: investigate whether there's ever a case where we hit this logic with 1:many sources.
|
2125
|
+
originalRawSource = this.sourceMap.sourcesContent[0];
|
2126
|
+
} else {
|
2127
|
+
// We fallback to reading the original source from disk.
|
2128
|
+
originalRawSource = await readFile(this.path, 'utf8');
|
2129
|
+
}
|
2130
|
+
this.covSources = [{ source: new CovSource(originalRawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null), path: this.path }];
|
2131
|
+
this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength, this.excludeEmptyLines ? this.sourceMap : null);
|
2132
|
+
}
|
2133
|
+
} else {
|
2134
|
+
this.covSources = [{ source: new CovSource(rawSource, this.wrapperLength), path: this.path }];
|
2135
|
+
}
|
2136
|
+
}
|
2124
2137
|
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
return readFile(realPath, 'utf-8')
|
2129
|
-
.then(result => result)
|
2130
|
-
.catch(err => {
|
2131
|
-
debuglog(`failed to load ${realPath}: ${err.message}`);
|
2132
|
-
})
|
2133
|
-
});
|
2134
|
-
return await Promise.all(fileList)
|
2135
|
-
}
|
2138
|
+
_readFileFromDir (filename) {
|
2139
|
+
return readFileSync(resolve(dirname(this.path), filename), 'utf-8')
|
2140
|
+
}
|
2136
2141
|
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2142
|
+
async sourcesContentFromSources () {
|
2143
|
+
const fileList = this.sourceMap.sources.map(relativePath => {
|
2144
|
+
const realPath = this._resolveSource(this.rawSourceMap, relativePath);
|
2145
|
+
return readFile(realPath, 'utf-8')
|
2146
|
+
.then(result => result)
|
2147
|
+
.catch(err => {
|
2148
|
+
debuglog(`failed to load ${realPath}: ${err.message}`);
|
2149
|
+
})
|
2150
|
+
});
|
2151
|
+
return await Promise.all(fileList)
|
2152
|
+
}
|
2140
2153
|
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
}
|
2145
|
-
sourcePath = sourcePath.replace(/^webpack:\/\//, '');
|
2146
|
-
const sourceRoot = rawSourceMap.sourcemap.sourceRoot ? rawSourceMap.sourcemap.sourceRoot.replace('file://', '') : '';
|
2147
|
-
const candidatePath = join(sourceRoot, sourcePath);
|
2154
|
+
destroy () {
|
2155
|
+
// no longer necessary, but preserved for backwards compatibility.
|
2156
|
+
}
|
2148
2157
|
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2158
|
+
_resolveSource (rawSourceMap, sourcePath) {
|
2159
|
+
if (sourcePath.startsWith('file://')) {
|
2160
|
+
return fileURLToPath(sourcePath)
|
2161
|
+
}
|
2162
|
+
sourcePath = sourcePath.replace(/^webpack:\/\//, '');
|
2163
|
+
const sourceRoot = rawSourceMap.sourcemap.sourceRoot ? rawSourceMap.sourcemap.sourceRoot.replace('file://', '') : '';
|
2164
|
+
const candidatePath = join(sourceRoot, sourcePath);
|
2155
2165
|
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
return
|
2163
|
-
}
|
2164
|
-
let lines;
|
2165
|
-
if (isEmptyCoverage) {
|
2166
|
-
// (empty-report), this will result in a report that has all lines zeroed out.
|
2167
|
-
lines = covSource.lines.filter((line) => {
|
2168
|
-
line.count = 0;
|
2169
|
-
return true
|
2170
|
-
});
|
2171
|
-
this.all = lines.length > 0;
|
2172
|
-
} else {
|
2173
|
-
lines = sliceRange(covSource.lines, startCol, endCol);
|
2174
|
-
}
|
2175
|
-
if (!lines.length) {
|
2176
|
-
return
|
2177
|
-
}
|
2166
|
+
if (isAbsolute(candidatePath)) {
|
2167
|
+
return candidatePath
|
2168
|
+
} else {
|
2169
|
+
return resolve(dirname(this.path), candidatePath)
|
2170
|
+
}
|
2171
|
+
}
|
2178
2172
|
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2173
|
+
applyCoverage (blocks) {
|
2174
|
+
blocks.forEach(block => {
|
2175
|
+
block.ranges.forEach((range, i) => {
|
2176
|
+
const isEmptyCoverage = block.functionName === '(empty-report)';
|
2177
|
+
const { startCol, endCol, path, covSource } = this._maybeRemapStartColEndCol(range, isEmptyCoverage);
|
2178
|
+
if (this.excludePath(path)) {
|
2179
|
+
return
|
2180
|
+
}
|
2181
|
+
let lines;
|
2182
|
+
if (isEmptyCoverage) {
|
2183
|
+
// (empty-report), this will result in a report that has all lines zeroed out.
|
2184
|
+
lines = covSource.lines.filter((line) => {
|
2185
|
+
line.count = 0;
|
2186
|
+
return true
|
2187
|
+
});
|
2188
|
+
this.all = lines.length > 0;
|
2189
|
+
} else {
|
2190
|
+
lines = sliceRange(covSource.lines, startCol, endCol);
|
2191
|
+
}
|
2192
|
+
if (!lines.length) {
|
2193
|
+
return
|
2194
|
+
}
|
2195
|
+
|
2196
|
+
const startLineInstance = lines[0];
|
2197
|
+
const endLineInstance = lines[lines.length - 1];
|
2198
|
+
|
2199
|
+
if (block.isBlockCoverage) {
|
2200
|
+
this.branches[path] = this.branches[path] || [];
|
2201
|
+
// record branches.
|
2202
|
+
this.branches[path].push(new CovBranch(
|
2203
|
+
startLineInstance.line,
|
2204
|
+
startCol - startLineInstance.startCol,
|
2205
|
+
endLineInstance.line,
|
2206
|
+
endCol - endLineInstance.startCol,
|
2207
|
+
range.count
|
2208
|
+
));
|
2209
|
+
|
2210
|
+
// if block-level granularity is enabled, we still create a single
|
2211
|
+
// CovFunction tracking object for each set of ranges.
|
2212
|
+
if (block.functionName && i === 0) {
|
2213
|
+
this.functions[path] = this.functions[path] || [];
|
2214
|
+
this.functions[path].push(new CovFunction(
|
2215
|
+
block.functionName,
|
2216
|
+
startLineInstance.line,
|
2217
|
+
startCol - startLineInstance.startCol,
|
2218
|
+
endLineInstance.line,
|
2219
|
+
endCol - endLineInstance.startCol,
|
2220
|
+
range.count
|
2221
|
+
));
|
2222
|
+
}
|
2223
|
+
} else if (block.functionName) {
|
2224
|
+
this.functions[path] = this.functions[path] || [];
|
2225
|
+
// record functions.
|
2226
|
+
this.functions[path].push(new CovFunction(
|
2227
|
+
block.functionName,
|
2228
|
+
startLineInstance.line,
|
2229
|
+
startCol - startLineInstance.startCol,
|
2230
|
+
endLineInstance.line,
|
2231
|
+
endCol - endLineInstance.startCol,
|
2232
|
+
range.count
|
2233
|
+
));
|
2234
|
+
}
|
2235
|
+
|
2236
|
+
// record the lines (we record these as statements, such that we're
|
2237
|
+
// compatible with Istanbul 2.0).
|
2238
|
+
lines.forEach(line => {
|
2239
|
+
// make sure branch spans entire line; don't record 'goodbye'
|
2240
|
+
// branch in `const foo = true ? 'hello' : 'goodbye'` as a
|
2241
|
+
// 0 for line coverage.
|
2242
|
+
//
|
2243
|
+
// All lines start out with coverage of 1, and are later set to 0
|
2244
|
+
// if they are not invoked; line.ignore prevents a line from being
|
2245
|
+
// set to 0, and is set if the special comment /* c8 ignore next */
|
2246
|
+
// is used.
|
2247
|
+
|
2248
|
+
if (startCol <= line.startCol && endCol >= line.endCol && !line.ignore) {
|
2249
|
+
line.count = range.count;
|
2250
|
+
}
|
2251
|
+
});
|
2252
|
+
});
|
2253
|
+
});
|
2254
|
+
}
|
2218
2255
|
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2256
|
+
_maybeRemapStartColEndCol (range, isEmptyCoverage) {
|
2257
|
+
let covSource = this.covSources[0].source;
|
2258
|
+
const covSourceWrapperLength = isEmptyCoverage ? 0 : covSource.wrapperLength;
|
2259
|
+
let startCol = Math.max(0, range.startOffset - covSourceWrapperLength);
|
2260
|
+
let endCol = Math.min(covSource.eof, range.endOffset - covSourceWrapperLength);
|
2261
|
+
let path = this.path;
|
2262
|
+
|
2263
|
+
if (this.sourceMap) {
|
2264
|
+
const sourceTranspiledWrapperLength = isEmptyCoverage ? 0 : this.sourceTranspiled.wrapperLength;
|
2265
|
+
startCol = Math.max(0, range.startOffset - sourceTranspiledWrapperLength);
|
2266
|
+
endCol = Math.min(this.sourceTranspiled.eof, range.endOffset - sourceTranspiledWrapperLength);
|
2267
|
+
|
2268
|
+
const { startLine, relStartCol, endLine, relEndCol, source } = this.sourceTranspiled.offsetToOriginalRelative(
|
2269
|
+
this.sourceMap,
|
2270
|
+
startCol,
|
2271
|
+
endCol
|
2272
|
+
);
|
2273
|
+
|
2274
|
+
const matchingSource = this.covSources.find(covSource => covSource.path === source);
|
2275
|
+
covSource = matchingSource ? matchingSource.source : this.covSources[0].source;
|
2276
|
+
path = matchingSource ? matchingSource.path : this.covSources[0].path;
|
2277
|
+
|
2278
|
+
// next we convert these relative positions back to absolute positions
|
2279
|
+
// in the original source (which is the format expected in the next step).
|
2280
|
+
startCol = covSource.relativeToOffset(startLine, relStartCol);
|
2281
|
+
endCol = covSource.relativeToOffset(endLine, relEndCol);
|
2282
|
+
}
|
2238
2283
|
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
if (this.sourceMap) {
|
2247
|
-
const sourceTranspiledWrapperLength = isEmptyCoverage ? 0 : this.sourceTranspiled.wrapperLength;
|
2248
|
-
startCol = Math.max(0, range.startOffset - sourceTranspiledWrapperLength);
|
2249
|
-
endCol = Math.min(this.sourceTranspiled.eof, range.endOffset - sourceTranspiledWrapperLength);
|
2250
|
-
|
2251
|
-
const { startLine, relStartCol, endLine, relEndCol, source } = this.sourceTranspiled.offsetToOriginalRelative(
|
2252
|
-
this.sourceMap,
|
2253
|
-
startCol,
|
2254
|
-
endCol
|
2255
|
-
);
|
2284
|
+
return {
|
2285
|
+
path,
|
2286
|
+
covSource,
|
2287
|
+
startCol,
|
2288
|
+
endCol
|
2289
|
+
}
|
2290
|
+
}
|
2256
2291
|
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2292
|
+
getInnerIstanbul (source, path) {
|
2293
|
+
// We apply the "Resolving Sources" logic (as defined in
|
2294
|
+
// sourcemaps.info/spec.html) as a final step for 1:many source maps.
|
2295
|
+
// for 1:1 source maps, the resolve logic is applied while loading.
|
2296
|
+
//
|
2297
|
+
// TODO: could we move the resolving logic for 1:1 source maps to the final
|
2298
|
+
// step as well? currently this breaks some tests in c8.
|
2299
|
+
let resolvedPath = path;
|
2300
|
+
if (this.rawSourceMap && this.rawSourceMap.sourcemap.sources.length > 1) {
|
2301
|
+
resolvedPath = this._resolveSource(this.rawSourceMap, path);
|
2302
|
+
}
|
2260
2303
|
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
endCol = covSource.relativeToOffset(endLine, relEndCol);
|
2265
|
-
}
|
2304
|
+
if (this.excludePath(resolvedPath)) {
|
2305
|
+
return
|
2306
|
+
}
|
2266
2307
|
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2308
|
+
return {
|
2309
|
+
[resolvedPath]: {
|
2310
|
+
path: resolvedPath,
|
2311
|
+
all: this.all,
|
2312
|
+
...this._statementsToIstanbul(source, path),
|
2313
|
+
...this._branchesToIstanbul(source, path),
|
2314
|
+
...this._functionsToIstanbul(source, path)
|
2315
|
+
}
|
2316
|
+
}
|
2317
|
+
}
|
2274
2318
|
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
// for 1:1 source maps, the resolve logic is applied while loading.
|
2279
|
-
//
|
2280
|
-
// TODO: could we move the resolving logic for 1:1 source maps to the final
|
2281
|
-
// step as well? currently this breaks some tests in c8.
|
2282
|
-
let resolvedPath = path;
|
2283
|
-
if (this.rawSourceMap && this.rawSourceMap.sourcemap.sources.length > 1) {
|
2284
|
-
resolvedPath = this._resolveSource(this.rawSourceMap, path);
|
2285
|
-
}
|
2319
|
+
toIstanbul () {
|
2320
|
+
return this.covSources.reduce((istanbulOuter, { source, path }) => Object.assign(istanbulOuter, this.getInnerIstanbul(source, path)), {})
|
2321
|
+
}
|
2286
2322
|
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2323
|
+
_statementsToIstanbul (source, path) {
|
2324
|
+
const statements = {
|
2325
|
+
statementMap: {},
|
2326
|
+
s: {}
|
2327
|
+
};
|
2328
|
+
source.lines.forEach((line, index) => {
|
2329
|
+
if (!line.ignore) {
|
2330
|
+
statements.statementMap[`${index}`] = line.toIstanbul();
|
2331
|
+
statements.s[`${index}`] = line.count;
|
2332
|
+
}
|
2333
|
+
});
|
2334
|
+
return statements
|
2335
|
+
}
|
2290
2336
|
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2337
|
+
_branchesToIstanbul (source, path) {
|
2338
|
+
const branches = {
|
2339
|
+
branchMap: {},
|
2340
|
+
b: {}
|
2341
|
+
};
|
2342
|
+
this.branches[path] = this.branches[path] || [];
|
2343
|
+
this.branches[path].forEach((branch, index) => {
|
2344
|
+
const srcLine = source.lines[branch.startLine - 1];
|
2345
|
+
const ignore = srcLine === undefined ? true : srcLine.ignore;
|
2346
|
+
branches.branchMap[`${index}`] = branch.toIstanbul();
|
2347
|
+
branches.b[`${index}`] = [ignore ? 1 : branch.count];
|
2348
|
+
});
|
2349
|
+
return branches
|
2350
|
+
}
|
2301
2351
|
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2352
|
+
_functionsToIstanbul (source, path) {
|
2353
|
+
const functions = {
|
2354
|
+
fnMap: {},
|
2355
|
+
f: {}
|
2356
|
+
};
|
2357
|
+
this.functions[path] = this.functions[path] || [];
|
2358
|
+
this.functions[path].forEach((fn, index) => {
|
2359
|
+
const srcLine = source.lines[fn.startLine - 1];
|
2360
|
+
const ignore = srcLine === undefined ? true : srcLine.ignore;
|
2361
|
+
functions.fnMap[`${index}`] = fn.toIstanbul();
|
2362
|
+
functions.f[`${index}`] = ignore ? 1 : fn.count;
|
2363
|
+
});
|
2364
|
+
return functions
|
2365
|
+
}
|
2366
|
+
};
|
2305
2367
|
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
source.lines.forEach((line, index) => {
|
2312
|
-
if (!line.ignore) {
|
2313
|
-
statements.statementMap[`${index}`] = line.toIstanbul();
|
2314
|
-
statements.s[`${index}`] = line.count;
|
2315
|
-
}
|
2316
|
-
});
|
2317
|
-
return statements
|
2318
|
-
}
|
2368
|
+
function parsePath (scriptPath) {
|
2369
|
+
return scriptPath.startsWith('file://') ? fileURLToPath(scriptPath) : scriptPath
|
2370
|
+
}
|
2371
|
+
return v8ToIstanbul$2;
|
2372
|
+
}
|
2319
2373
|
|
2320
|
-
|
2321
|
-
|
2322
|
-
branchMap: {},
|
2323
|
-
b: {}
|
2324
|
-
};
|
2325
|
-
this.branches[path] = this.branches[path] || [];
|
2326
|
-
this.branches[path].forEach((branch, index) => {
|
2327
|
-
const srcLine = source.lines[branch.startLine - 1];
|
2328
|
-
const ignore = srcLine === undefined ? true : srcLine.ignore;
|
2329
|
-
branches.branchMap[`${index}`] = branch.toIstanbul();
|
2330
|
-
branches.b[`${index}`] = [ignore ? 1 : branch.count];
|
2331
|
-
});
|
2332
|
-
return branches
|
2333
|
-
}
|
2374
|
+
var v8ToIstanbul$1;
|
2375
|
+
var hasRequiredV8ToIstanbul;
|
2334
2376
|
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
this.functions[path] = this.functions[path] || [];
|
2341
|
-
this.functions[path].forEach((fn, index) => {
|
2342
|
-
const srcLine = source.lines[fn.startLine - 1];
|
2343
|
-
const ignore = srcLine === undefined ? true : srcLine.ignore;
|
2344
|
-
functions.fnMap[`${index}`] = fn.toIstanbul();
|
2345
|
-
functions.f[`${index}`] = ignore ? 1 : fn.count;
|
2346
|
-
});
|
2347
|
-
return functions
|
2348
|
-
}
|
2349
|
-
};
|
2377
|
+
function requireV8ToIstanbul () {
|
2378
|
+
if (hasRequiredV8ToIstanbul) return v8ToIstanbul$1;
|
2379
|
+
hasRequiredV8ToIstanbul = 1;
|
2380
|
+
// Patch applied: https://github.com/istanbuljs/v8-to-istanbul/pull/244
|
2381
|
+
const V8ToIstanbul = requireV8ToIstanbul$1();
|
2350
2382
|
|
2351
|
-
function
|
2352
|
-
|
2383
|
+
v8ToIstanbul$1 = function (path, wrapperLength, sources, excludePath, excludeEmptyLines) {
|
2384
|
+
return new V8ToIstanbul(path, wrapperLength, sources, excludePath, excludeEmptyLines)
|
2385
|
+
};
|
2386
|
+
return v8ToIstanbul$1;
|
2353
2387
|
}
|
2354
2388
|
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
var v8ToIstanbul = function (path, wrapperLength, sources, excludePath, excludeEmptyLines) {
|
2359
|
-
return new V8ToIstanbul(path, wrapperLength, sources, excludePath, excludeEmptyLines)
|
2360
|
-
};
|
2361
|
-
|
2362
|
-
var v8ToIstanbul$1 = /*@__PURE__*/getDefaultExportFromCjs(v8ToIstanbul);
|
2389
|
+
var v8ToIstanbulExports = requireV8ToIstanbul();
|
2390
|
+
var v8ToIstanbul = /*@__PURE__*/getDefaultExportFromCjs(v8ToIstanbulExports);
|
2363
2391
|
|
2364
2392
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
2365
2393
|
function normalizeWindowsPath(input = "") {
|
@@ -2512,7 +2540,7 @@ function cleanUrl(url) {
|
|
2512
2540
|
"wasi"
|
2513
2541
|
]);
|
2514
2542
|
|
2515
|
-
var version = "2.1.
|
2543
|
+
var version = "2.1.2";
|
2516
2544
|
|
2517
2545
|
const WRAPPER_LENGTH = 185;
|
2518
2546
|
const VITE_EXPORTS_LINE_PATTERN = /Object\.defineProperty\(__vite_ssr_exports__.*\n/g;
|
@@ -2582,20 +2610,20 @@ Update your dependencies and make sure the versions match.`
|
|
2582
2610
|
}
|
2583
2611
|
async clean(clean = true) {
|
2584
2612
|
if (clean && existsSync(this.options.reportsDirectory)) {
|
2585
|
-
await promises
|
2613
|
+
await promises.rm(this.options.reportsDirectory, {
|
2586
2614
|
recursive: true,
|
2587
2615
|
force: true,
|
2588
2616
|
maxRetries: 10
|
2589
2617
|
});
|
2590
2618
|
}
|
2591
2619
|
if (existsSync(this.coverageFilesDirectory)) {
|
2592
|
-
await promises
|
2620
|
+
await promises.rm(this.coverageFilesDirectory, {
|
2593
2621
|
recursive: true,
|
2594
2622
|
force: true,
|
2595
2623
|
maxRetries: 10
|
2596
2624
|
});
|
2597
2625
|
}
|
2598
|
-
await promises
|
2626
|
+
await promises.mkdir(this.coverageFilesDirectory, { recursive: true });
|
2599
2627
|
this.coverageFiles = /* @__PURE__ */ new Map();
|
2600
2628
|
this.pendingPromises = [];
|
2601
2629
|
}
|
@@ -2604,21 +2632,22 @@ Update your dependencies and make sure the versions match.`
|
|
2604
2632
|
* Note that adding new entries here and requiring on those without
|
2605
2633
|
* backwards compatibility is a breaking change.
|
2606
2634
|
*/
|
2607
|
-
onAfterSuiteRun({ coverage, transformMode, projectName }) {
|
2635
|
+
onAfterSuiteRun({ coverage, transformMode, projectName, testFiles }) {
|
2608
2636
|
if (transformMode !== "web" && transformMode !== "ssr" && transformMode !== "browser") {
|
2609
2637
|
throw new Error(`Invalid transform mode: ${transformMode}`);
|
2610
2638
|
}
|
2611
2639
|
let entry = this.coverageFiles.get(projectName || DEFAULT_PROJECT);
|
2612
2640
|
if (!entry) {
|
2613
|
-
entry = { web:
|
2641
|
+
entry = { web: {}, ssr: {}, browser: {} };
|
2614
2642
|
this.coverageFiles.set(projectName || DEFAULT_PROJECT, entry);
|
2615
2643
|
}
|
2644
|
+
const testFilenames = testFiles.join();
|
2616
2645
|
const filename = resolve(
|
2617
2646
|
this.coverageFilesDirectory,
|
2618
2647
|
`coverage-${uniqueId++}.json`
|
2619
2648
|
);
|
2620
|
-
entry[transformMode]
|
2621
|
-
const promise = promises
|
2649
|
+
entry[transformMode][testFilenames] = filename;
|
2650
|
+
const promise = promises.writeFile(filename, JSON.stringify(coverage), "utf-8");
|
2622
2651
|
this.pendingPromises.push(promise);
|
2623
2652
|
}
|
2624
2653
|
async generateCoverage({ allTestsRun }) {
|
@@ -2628,8 +2657,9 @@ Update your dependencies and make sure the versions match.`
|
|
2628
2657
|
await Promise.all(this.pendingPromises);
|
2629
2658
|
this.pendingPromises = [];
|
2630
2659
|
for (const [projectName, coveragePerProject] of this.coverageFiles.entries()) {
|
2631
|
-
for (const [transformMode,
|
2660
|
+
for (const [transformMode, coverageByTestfiles] of Object.entries(coveragePerProject)) {
|
2632
2661
|
let merged = { result: [] };
|
2662
|
+
const filenames = Object.values(coverageByTestfiles);
|
2633
2663
|
const project = this.ctx.projects.find((p) => p.getName() === projectName) || this.ctx.getCoreWorkspaceProject();
|
2634
2664
|
for (const chunk of this.toSlices(filenames, this.options.processingConcurrency)) {
|
2635
2665
|
if (debug.enabled) {
|
@@ -2638,7 +2668,7 @@ Update your dependencies and make sure the versions match.`
|
|
2638
2668
|
}
|
2639
2669
|
await Promise.all(
|
2640
2670
|
chunk.map(async (filename) => {
|
2641
|
-
const contents = await promises
|
2671
|
+
const contents = await promises.readFile(filename, "utf-8");
|
2642
2672
|
const coverage = JSON.parse(contents);
|
2643
2673
|
merged = mergeProcessCovs([merged, coverage]);
|
2644
2674
|
})
|
@@ -2653,7 +2683,7 @@ Update your dependencies and make sure the versions match.`
|
|
2653
2683
|
coverageMap.merge(transformedCoverage);
|
2654
2684
|
}
|
2655
2685
|
}
|
2656
|
-
if (this.options.all && allTestsRun) {
|
2686
|
+
if (this.options.all && (allTestsRun || !this.options.cleanOnRerun)) {
|
2657
2687
|
const coveredFiles = coverageMap.files();
|
2658
2688
|
const untestedCoverage = await this.getUntestedFiles(coveredFiles);
|
2659
2689
|
const converted = await this.convertCoverage(untestedCoverage);
|
@@ -2678,11 +2708,19 @@ Update your dependencies and make sure the versions match.`
|
|
2678
2708
|
);
|
2679
2709
|
const keepResults = !this.options.cleanOnRerun && this.ctx.config.watch;
|
2680
2710
|
if (!keepResults) {
|
2681
|
-
this.
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2711
|
+
await this.cleanAfterRun();
|
2712
|
+
}
|
2713
|
+
}
|
2714
|
+
async cleanAfterRun() {
|
2715
|
+
this.coverageFiles = /* @__PURE__ */ new Map();
|
2716
|
+
await promises.rm(this.coverageFilesDirectory, { recursive: true });
|
2717
|
+
if (readdirSync(this.options.reportsDirectory).length === 0) {
|
2718
|
+
await promises.rm(this.options.reportsDirectory, { recursive: true });
|
2719
|
+
}
|
2720
|
+
}
|
2721
|
+
async onTestFailure() {
|
2722
|
+
if (!this.options.reportOnFailure) {
|
2723
|
+
await this.cleanAfterRun();
|
2686
2724
|
}
|
2687
2725
|
}
|
2688
2726
|
async generateReports(coverageMap, allTestsRun) {
|
@@ -2723,7 +2761,7 @@ Update your dependencies and make sure the versions match.`
|
|
2723
2761
|
}
|
2724
2762
|
const configFilePath = this.ctx.server.config.configFile;
|
2725
2763
|
const configModule = parseModule(
|
2726
|
-
await promises
|
2764
|
+
await promises.readFile(configFilePath, "utf8")
|
2727
2765
|
);
|
2728
2766
|
this.updateThresholds({
|
2729
2767
|
thresholds: resolvedThresholds,
|
@@ -2809,7 +2847,7 @@ Update your dependencies and make sure the versions match.`
|
|
2809
2847
|
return merged;
|
2810
2848
|
}
|
2811
2849
|
async getSources(url, transformResults, onTransform, functions = []) {
|
2812
|
-
const filePath = normalize(fileURLToPath
|
2850
|
+
const filePath = normalize(fileURLToPath(url));
|
2813
2851
|
let isExecuted = true;
|
2814
2852
|
let transformResult = transformResults.get(filePath);
|
2815
2853
|
if (!transformResult) {
|
@@ -2820,7 +2858,7 @@ Update your dependencies and make sure the versions match.`
|
|
2820
2858
|
const code = transformResult?.code;
|
2821
2859
|
const sourcesContent = map?.sourcesContent || [];
|
2822
2860
|
if (!sourcesContent[0]) {
|
2823
|
-
sourcesContent[0] = await promises
|
2861
|
+
sourcesContent[0] = await promises.readFile(filePath, "utf-8").catch(() => {
|
2824
2862
|
const length = findLongestFunctionLength(functions);
|
2825
2863
|
return ".".repeat(length);
|
2826
2864
|
});
|
@@ -2874,7 +2912,7 @@ Update your dependencies and make sure the versions match.`
|
|
2874
2912
|
result.url = `${FILE_PROTOCOL}${project.config.root}${result.url}`;
|
2875
2913
|
}
|
2876
2914
|
}
|
2877
|
-
if (this.testExclude.shouldInstrument(fileURLToPath
|
2915
|
+
if (this.testExclude.shouldInstrument(fileURLToPath(result.url))) {
|
2878
2916
|
scriptCoverages.push(result);
|
2879
2917
|
}
|
2880
2918
|
}
|
@@ -2894,7 +2932,7 @@ Update your dependencies and make sure the versions match.`
|
|
2894
2932
|
functions
|
2895
2933
|
);
|
2896
2934
|
const wrapperLength = sources.isExecuted ? WRAPPER_LENGTH : 0;
|
2897
|
-
const converter = v8ToIstanbul
|
2935
|
+
const converter = v8ToIstanbul(
|
2898
2936
|
url,
|
2899
2937
|
wrapperLength,
|
2900
2938
|
sources,
|