@@ -169,6 +169,29 @@ module.exports = function() {
169
169
}
170
170
}
171
171
172
+ function testSourcemapWithVariableInSelector ( name , err , compiledLess , doReplacements , sourcemap , baseFolder ) {
173
+ if ( err ) {
174
+ fail ( 'ERROR: ' + ( err && err . message ) ) ;
175
+ return ;
176
+ }
177
+
178
+ // Even if annotation is not necessary, the map file should be there.
179
+ fs . readFile ( path . join ( 'test/' , name ) + '.json' , 'utf8' , function ( e , expectedSourcemap ) {
180
+ process . stdout . write ( '- ' + path . join ( baseFolder , name ) + ': ' ) ;
181
+ if ( sourcemap === expectedSourcemap ) {
182
+ ok ( 'OK' ) ;
183
+ } else if ( err ) {
184
+ fail ( 'ERROR: ' + ( err && err . message ) ) ;
185
+ if ( isVerbose ) {
186
+ process . stdout . write ( '\n' ) ;
187
+ process . stdout . write ( err . stack + '\n' ) ;
188
+ }
189
+ } else {
190
+ difference ( 'FAIL' , expectedSourcemap , sourcemap ) ;
191
+ }
192
+ } ) ;
193
+ }
194
+
172
195
function testImports ( name , err , compiledLess , doReplacements , sourcemap , baseFolder , imports ) {
173
196
if ( err ) {
174
197
fail ( 'ERROR: ' + ( err && err . message ) ) ;
@@ -228,7 +251,7 @@ module.exports = function() {
228
251
229
252
// To fix ci fail about error format change in upstream v8 project
230
253
// https://github.com/v8/v8/commit/c0fd89c3c089e888c4f4e8582e56db7066fa779b
231
- // Node 16.9.0+ include this change via https://github.com/nodejs/node/pull/39947
254
+ // Node 16.9.0+ include this change via https://github.com/nodejs/node/pull/39947
232
255
function testTypeErrors ( name , err , compiledLess , doReplacements , sourcemap , baseFolder ) {
233
256
const fileSuffix = semver . gte ( process . version , 'v16.9.0' ) ? '-2.txt' : '.txt' ;
234
257
fs . readFile ( path . join ( baseFolder , name ) + fileSuffix , 'utf8' , function ( e , expectedErr ) {
@@ -254,7 +277,7 @@ module.exports = function() {
254
277
// https://github.com/less/less.js/issues/3112
255
278
function testJSImport ( ) {
256
279
process . stdout . write ( '- Testing root function registry' ) ;
257
- less . functions . functionRegistry . add ( 'ext' , function ( ) {
280
+ less . functions . functionRegistry . add ( 'ext' , function ( ) {
258
281
return new less . tree . Anonymous ( 'file' ) ;
259
282
} ) ;
260
283
var expected = '@charset "utf-8";\n' ;
@@ -282,7 +305,7 @@ module.exports = function() {
282
305
. replace ( / \{ p a t h h r e f \} / g, '' )
283
306
. replace ( / \{ 4 0 4 s t a t u s \} / g, '' )
284
307
. replace ( / \{ n o d e p a t h \} / g, path . join ( process . cwd ( ) , 'node_modules' , '/' ) )
285
- . replace ( / \{ p a t h r e l \} / g, path . join ( path . relative ( lessFolder , p ) , '/' ) )
308
+ . replace ( / \{ p a t h r e l \} / g, path . join ( path . relative ( lessFolder , p ) , '/' ) )
286
309
. replace ( / \{ p a t h e s c \} / g, pathesc )
287
310
. replace ( / \{ p a t h i m p o r t \} / g, pathimport )
288
311
. replace ( / \{ p a t h i m p o r t e s c \} / g, pathimportesc )
@@ -327,7 +350,7 @@ module.exports = function() {
327
350
328
351
function runTestSetInternal ( baseFolder , opts , foldername , verifyFunction , nameModifier , doReplacements , getFilename ) {
329
352
foldername = foldername || '' ;
330
-
353
+
331
354
var originalOptions = opts || { } ;
332
355
333
356
if ( ! doReplacements ) {
@@ -497,10 +520,10 @@ module.exports = function() {
497
520
}
498
521
499
522
/**
500
- *
501
- * @param {Object } options
502
- * @param {string } filePath
503
- * @param {Function } callback
523
+ *
524
+ * @param {Object } options
525
+ * @param {string } filePath
526
+ * @param {Function } callback
504
527
*/
505
528
function toCSS ( options , filePath , callback ) {
506
529
options = options || { } ;
@@ -577,7 +600,7 @@ module.exports = function() {
577
600
}
578
601
ok ( stylize ( 'OK\n' , 'green' ) ) ;
579
602
}
580
- ) ;
603
+ ) ;
581
604
}
582
605
583
606
return {
@@ -588,6 +611,7 @@ module.exports = function() {
588
611
testTypeErrors : testTypeErrors ,
589
612
testSourcemap : testSourcemap ,
590
613
testSourcemapWithoutUrlAnnotation : testSourcemapWithoutUrlAnnotation ,
614
+ testSourcemapWithVariableInSelector : testSourcemapWithVariableInSelector ,
591
615
testImports : testImports ,
592
616
testImportRedirect : testImportRedirect ,
593
617
testEmptySourcemap : testEmptySourcemap ,
0 commit comments