@@ -169,6 +169,29 @@ module.exports = function() {
169169 }
170170 }
171171
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+
172195 function testImports ( name , err , compiledLess , doReplacements , sourcemap , baseFolder , imports ) {
173196 if ( err ) {
174197 fail ( 'ERROR: ' + ( err && err . message ) ) ;
@@ -228,7 +251,7 @@ module.exports = function() {
228251
229252 // To fix ci fail about error format change in upstream v8 project
230253 // 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
232255 function testTypeErrors ( name , err , compiledLess , doReplacements , sourcemap , baseFolder ) {
233256 const fileSuffix = semver . gte ( process . version , 'v16.9.0' ) ? '-2.txt' : '.txt' ;
234257 fs . readFile ( path . join ( baseFolder , name ) + fileSuffix , 'utf8' , function ( e , expectedErr ) {
@@ -254,7 +277,7 @@ module.exports = function() {
254277 // https://github.com/less/less.js/issues/3112
255278 function testJSImport ( ) {
256279 process . stdout . write ( '- Testing root function registry' ) ;
257- less . functions . functionRegistry . add ( 'ext' , function ( ) {
280+ less . functions . functionRegistry . add ( 'ext' , function ( ) {
258281 return new less . tree . Anonymous ( 'file' ) ;
259282 } ) ;
260283 var expected = '@charset "utf-8";\n' ;
@@ -282,7 +305,7 @@ module.exports = function() {
282305 . replace ( / \{ p a t h h r e f \} / g, '' )
283306 . replace ( / \{ 4 0 4 s t a t u s \} / g, '' )
284307 . 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 ) , '/' ) )
286309 . replace ( / \{ p a t h e s c \} / g, pathesc )
287310 . replace ( / \{ p a t h i m p o r t \} / g, pathimport )
288311 . replace ( / \{ p a t h i m p o r t e s c \} / g, pathimportesc )
@@ -327,7 +350,7 @@ module.exports = function() {
327350
328351 function runTestSetInternal ( baseFolder , opts , foldername , verifyFunction , nameModifier , doReplacements , getFilename ) {
329352 foldername = foldername || '' ;
330-
353+
331354 var originalOptions = opts || { } ;
332355
333356 if ( ! doReplacements ) {
@@ -497,10 +520,10 @@ module.exports = function() {
497520 }
498521
499522 /**
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
504527 */
505528 function toCSS ( options , filePath , callback ) {
506529 options = options || { } ;
@@ -577,7 +600,7 @@ module.exports = function() {
577600 }
578601 ok ( stylize ( 'OK\n' , 'green' ) ) ;
579602 }
580- ) ;
603+ ) ;
581604 }
582605
583606 return {
@@ -588,6 +611,7 @@ module.exports = function() {
588611 testTypeErrors : testTypeErrors ,
589612 testSourcemap : testSourcemap ,
590613 testSourcemapWithoutUrlAnnotation : testSourcemapWithoutUrlAnnotation ,
614+ testSourcemapWithVariableInSelector : testSourcemapWithVariableInSelector ,
591615 testImports : testImports ,
592616 testImportRedirect : testImportRedirect ,
593617 testEmptySourcemap : testEmptySourcemap ,
0 commit comments