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