|
1 | 1 | /* jshint latedef: nofunc */
|
2 |
| - |
| 2 | +var semver = require('semver'); |
3 | 3 | var logger = require('../lib/less/logger').default;
|
4 | 4 |
|
5 | 5 | var isVerbose = process.env.npm_config_loglevel !== 'concise';
|
@@ -226,6 +226,31 @@ module.exports = function() {
|
226 | 226 | });
|
227 | 227 | }
|
228 | 228 |
|
| 229 | + // To fix ci fail about error format change in upstream v8 project |
| 230 | + // https://github.com/v8/v8/commit/c0fd89c3c089e888c4f4e8582e56db7066fa779b |
| 231 | + // Node 16.9.0+ include this change via https://github.com/nodejs/node/pull/39947 |
| 232 | + function testTypeErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) { |
| 233 | + const fileSuffix = semver.gte(process.version, 'v16.9.0') ? '-2.txt' : '.txt'; |
| 234 | + fs.readFile(path.join(baseFolder, name) + fileSuffix, 'utf8', function (e, expectedErr) { |
| 235 | + process.stdout.write('- ' + path.join(baseFolder, name) + ': '); |
| 236 | + expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename); |
| 237 | + if (!err) { |
| 238 | + if (compiledLess) { |
| 239 | + fail('No Error', 'red'); |
| 240 | + } else { |
| 241 | + fail('No Error, No Output'); |
| 242 | + } |
| 243 | + } else { |
| 244 | + var errMessage = err.toString(); |
| 245 | + if (errMessage === expectedErr) { |
| 246 | + ok('OK'); |
| 247 | + } else { |
| 248 | + difference('FAIL', expectedErr, errMessage); |
| 249 | + } |
| 250 | + } |
| 251 | + }); |
| 252 | + } |
| 253 | + |
229 | 254 | // https://github.com/less/less.js/issues/3112
|
230 | 255 | function testJSImport() {
|
231 | 256 | process.stdout.write('- Testing root function registry');
|
@@ -543,6 +568,7 @@ module.exports = function() {
|
543 | 568 | runTestSetNormalOnly: runTestSetNormalOnly,
|
544 | 569 | testSyncronous: testSyncronous,
|
545 | 570 | testErrors: testErrors,
|
| 571 | + testTypeErrors: testTypeErrors, |
546 | 572 | testSourcemap: testSourcemap,
|
547 | 573 | testSourcemapWithoutUrlAnnotation: testSourcemapWithoutUrlAnnotation,
|
548 | 574 | testImports: testImports,
|
|
0 commit comments