less 4.4.2 → 4.6.0
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/bin/lessc +67 -58
- package/dist/less.js +14496 -11811
- package/dist/less.min.js +4 -4
- package/dist/less.min.js.map +1 -1
- package/lib/less/constants.js +5 -7
- package/lib/less/contexts.js +71 -56
- package/lib/less/data/colors.js +150 -153
- package/lib/less/data/index.js +4 -7
- package/lib/less/data/unit-conversions.js +2 -5
- package/lib/less/default-options.js +52 -23
- package/lib/less/deprecation.js +67 -0
- package/lib/less/environment/abstract-file-manager.js +62 -50
- package/lib/less/environment/abstract-plugin-loader.js +69 -46
- package/lib/less/environment/environment-api.ts +21 -0
- package/lib/less/environment/environment.js +34 -30
- package/lib/less/environment/file-manager-api.ts +77 -0
- package/lib/less/functions/boolean.js +13 -13
- package/lib/less/functions/color-blending.js +39 -31
- package/lib/less/functions/color.js +153 -137
- package/lib/less/functions/data-uri.js +73 -64
- package/lib/less/functions/default.js +9 -11
- package/lib/less/functions/function-caller.js +35 -34
- package/lib/less/functions/function-registry.js +16 -17
- package/lib/less/functions/index.js +33 -33
- package/lib/less/functions/list.js +88 -75
- package/lib/less/functions/math-helper.js +8 -11
- package/lib/less/functions/math.js +21 -21
- package/lib/less/functions/number.js +42 -53
- package/lib/less/functions/string.js +18 -22
- package/lib/less/functions/style.js +21 -20
- package/lib/less/functions/svg.js +83 -82
- package/lib/less/functions/types.js +28 -32
- package/lib/less/import-manager.js +73 -64
- package/lib/less/index.js +65 -65
- package/lib/less/less-error.js +65 -46
- package/lib/less/logger.js +11 -14
- package/lib/less/parse-tree.js +94 -38
- package/lib/less/parse.js +44 -44
- package/lib/less/parser/parser-input.js +152 -131
- package/lib/less/parser/parser.js +866 -672
- package/lib/less/plugin-manager.js +57 -46
- package/lib/less/render.js +17 -23
- package/lib/less/source-map-builder.js +52 -43
- package/lib/less/source-map-output.js +57 -44
- package/lib/less/transform-tree.js +40 -30
- package/lib/less/tree/anonymous.js +52 -28
- package/lib/less/tree/assignment.js +44 -27
- package/lib/less/tree/atrule-syntax.js +4 -6
- package/lib/less/tree/atrule.js +247 -140
- package/lib/less/tree/attribute.js +55 -24
- package/lib/less/tree/call.js +70 -42
- package/lib/less/tree/color.js +194 -145
- package/lib/less/tree/combinator.js +31 -21
- package/lib/less/tree/comment.js +44 -23
- package/lib/less/tree/condition.js +61 -36
- package/lib/less/tree/container.js +90 -34
- package/lib/less/tree/debug-info.js +53 -11
- package/lib/less/tree/declaration.js +97 -52
- package/lib/less/tree/detached-ruleset.js +42 -24
- package/lib/less/tree/dimension.js +127 -71
- package/lib/less/tree/element.js +82 -52
- package/lib/less/tree/expression.js +75 -50
- package/lib/less/tree/extend.js +71 -42
- package/lib/less/tree/import.js +184 -110
- package/lib/less/tree/index.js +52 -81
- package/lib/less/tree/javascript.js +43 -32
- package/lib/less/tree/js-eval-node.js +46 -32
- package/lib/less/tree/keyword.js +25 -17
- package/lib/less/tree/media.js +77 -35
- package/lib/less/tree/merge-rules.js +47 -0
- package/lib/less/tree/mixin-call.js +181 -98
- package/lib/less/tree/mixin-definition.js +211 -117
- package/lib/less/tree/namespace-value.js +63 -44
- package/lib/less/tree/negative.js +34 -21
- package/lib/less/tree/nested-at-rule.js +149 -66
- package/lib/less/tree/node.js +225 -90
- package/lib/less/tree/operation.js +59 -34
- package/lib/less/tree/paren.js +34 -17
- package/lib/less/tree/property.js +66 -35
- package/lib/less/tree/query-in-parens.js +52 -60
- package/lib/less/tree/quoted.js +93 -44
- package/lib/less/tree/ruleset.js +632 -318
- package/lib/less/tree/selector.js +151 -77
- package/lib/less/tree/unicode-descriptor.js +14 -12
- package/lib/less/tree/unit.js +111 -63
- package/lib/less/tree/url.js +62 -38
- package/lib/less/tree/value.js +50 -34
- package/lib/less/tree/variable-call.js +47 -30
- package/lib/less/tree/variable.js +53 -31
- package/lib/less/utils.js +44 -47
- package/lib/less/visitors/extend-visitor.js +233 -172
- package/lib/less/visitors/import-sequencer.js +24 -24
- package/lib/less/visitors/import-visitor.js +62 -52
- package/lib/less/visitors/index.js +14 -17
- package/lib/less/visitors/join-selector-visitor.js +40 -37
- package/lib/less/visitors/set-tree-visibility-visitor.js +32 -18
- package/lib/less/visitors/to-css-visitor.js +135 -128
- package/lib/less/visitors/visitor.js +60 -45
- package/lib/less-browser/add-default-options.js +23 -13
- package/lib/less-browser/bootstrap.js +23 -17
- package/lib/less-browser/browser.js +24 -21
- package/lib/less-browser/cache.js +17 -19
- package/lib/less-browser/error-reporting.js +52 -44
- package/lib/less-browser/file-manager.js +52 -42
- package/lib/less-browser/image-size.js +12 -12
- package/lib/less-browser/index.js +131 -105
- package/lib/less-browser/log-listener.js +30 -31
- package/lib/less-browser/plugin-loader.js +10 -10
- package/lib/less-browser/utils.js +19 -21
- package/lib/less-node/environment.js +32 -8
- package/lib/less-node/file-manager.js +62 -45
- package/lib/less-node/fs.js +11 -8
- package/lib/less-node/image-size.js +40 -31
- package/lib/less-node/index.js +28 -19
- package/lib/less-node/lessc-helper.js +28 -28
- package/lib/less-node/plugin-loader.js +35 -27
- package/lib/less-node/url-file-manager.js +33 -31
- package/package.json +31 -19
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -63
- package/Gruntfile.js +0 -404
- package/bower.json +0 -22
- package/lib/less/constants.js.map +0 -1
- package/lib/less/contexts.js.map +0 -1
- package/lib/less/data/colors.js.map +0 -1
- package/lib/less/data/index.js.map +0 -1
- package/lib/less/data/unit-conversions.js.map +0 -1
- package/lib/less/default-options.js.map +0 -1
- package/lib/less/environment/abstract-file-manager.js.map +0 -1
- package/lib/less/environment/abstract-plugin-loader.js.map +0 -1
- package/lib/less/environment/environment-api.js +0 -3
- package/lib/less/environment/environment-api.js.map +0 -1
- package/lib/less/environment/environment.js.map +0 -1
- package/lib/less/environment/file-manager-api.js +0 -3
- package/lib/less/environment/file-manager-api.js.map +0 -1
- package/lib/less/functions/boolean.js.map +0 -1
- package/lib/less/functions/color-blending.js.map +0 -1
- package/lib/less/functions/color.js.map +0 -1
- package/lib/less/functions/data-uri.js.map +0 -1
- package/lib/less/functions/default.js.map +0 -1
- package/lib/less/functions/function-caller.js.map +0 -1
- package/lib/less/functions/function-registry.js.map +0 -1
- package/lib/less/functions/index.js.map +0 -1
- package/lib/less/functions/list.js.map +0 -1
- package/lib/less/functions/math-helper.js.map +0 -1
- package/lib/less/functions/math.js.map +0 -1
- package/lib/less/functions/number.js.map +0 -1
- package/lib/less/functions/string.js.map +0 -1
- package/lib/less/functions/style.js.map +0 -1
- package/lib/less/functions/svg.js.map +0 -1
- package/lib/less/functions/types.js.map +0 -1
- package/lib/less/import-manager.js.map +0 -1
- package/lib/less/index.js.map +0 -1
- package/lib/less/less-error.js.map +0 -1
- package/lib/less/logger.js.map +0 -1
- package/lib/less/parse-tree.js.map +0 -1
- package/lib/less/parse.js.map +0 -1
- package/lib/less/parser/chunker.js +0 -148
- package/lib/less/parser/chunker.js.map +0 -1
- package/lib/less/parser/parser-input.js.map +0 -1
- package/lib/less/parser/parser.js.map +0 -1
- package/lib/less/plugin-manager.js.map +0 -1
- package/lib/less/render.js.map +0 -1
- package/lib/less/source-map-builder.js.map +0 -1
- package/lib/less/source-map-output.js.map +0 -1
- package/lib/less/transform-tree.js.map +0 -1
- package/lib/less/tree/anonymous.js.map +0 -1
- package/lib/less/tree/assignment.js.map +0 -1
- package/lib/less/tree/atrule-syntax.js.map +0 -1
- package/lib/less/tree/atrule.js.map +0 -1
- package/lib/less/tree/attribute.js.map +0 -1
- package/lib/less/tree/call.js.map +0 -1
- package/lib/less/tree/color.js.map +0 -1
- package/lib/less/tree/combinator.js.map +0 -1
- package/lib/less/tree/comment.js.map +0 -1
- package/lib/less/tree/condition.js.map +0 -1
- package/lib/less/tree/container.js.map +0 -1
- package/lib/less/tree/debug-info.js.map +0 -1
- package/lib/less/tree/declaration.js.map +0 -1
- package/lib/less/tree/detached-ruleset.js.map +0 -1
- package/lib/less/tree/dimension.js.map +0 -1
- package/lib/less/tree/element.js.map +0 -1
- package/lib/less/tree/expression.js.map +0 -1
- package/lib/less/tree/extend.js.map +0 -1
- package/lib/less/tree/import.js.map +0 -1
- package/lib/less/tree/index.js.map +0 -1
- package/lib/less/tree/javascript.js.map +0 -1
- package/lib/less/tree/js-eval-node.js.map +0 -1
- package/lib/less/tree/keyword.js.map +0 -1
- package/lib/less/tree/media.js.map +0 -1
- package/lib/less/tree/mixin-call.js.map +0 -1
- package/lib/less/tree/mixin-definition.js.map +0 -1
- package/lib/less/tree/namespace-value.js.map +0 -1
- package/lib/less/tree/negative.js.map +0 -1
- package/lib/less/tree/nested-at-rule.js.map +0 -1
- package/lib/less/tree/node.js.map +0 -1
- package/lib/less/tree/operation.js.map +0 -1
- package/lib/less/tree/paren.js.map +0 -1
- package/lib/less/tree/property.js.map +0 -1
- package/lib/less/tree/query-in-parens.js.map +0 -1
- package/lib/less/tree/quoted.js.map +0 -1
- package/lib/less/tree/ruleset.js.map +0 -1
- package/lib/less/tree/selector.js.map +0 -1
- package/lib/less/tree/unicode-descriptor.js.map +0 -1
- package/lib/less/tree/unit.js.map +0 -1
- package/lib/less/tree/url.js.map +0 -1
- package/lib/less/tree/value.js.map +0 -1
- package/lib/less/tree/variable-call.js.map +0 -1
- package/lib/less/tree/variable.js.map +0 -1
- package/lib/less/utils.js.map +0 -1
- package/lib/less/visitors/extend-visitor.js.map +0 -1
- package/lib/less/visitors/import-sequencer.js.map +0 -1
- package/lib/less/visitors/import-visitor.js.map +0 -1
- package/lib/less/visitors/index.js.map +0 -1
- package/lib/less/visitors/join-selector-visitor.js.map +0 -1
- package/lib/less/visitors/set-tree-visibility-visitor.js.map +0 -1
- package/lib/less/visitors/to-css-visitor.js.map +0 -1
- package/lib/less/visitors/visitor.js.map +0 -1
- package/lib/less-browser/add-default-options.js.map +0 -1
- package/lib/less-browser/bootstrap.js.map +0 -1
- package/lib/less-browser/browser.js.map +0 -1
- package/lib/less-browser/cache.js.map +0 -1
- package/lib/less-browser/error-reporting.js.map +0 -1
- package/lib/less-browser/file-manager.js.map +0 -1
- package/lib/less-browser/image-size.js.map +0 -1
- package/lib/less-browser/index.js.map +0 -1
- package/lib/less-browser/log-listener.js.map +0 -1
- package/lib/less-browser/plugin-loader.js.map +0 -1
- package/lib/less-browser/utils.js.map +0 -1
- package/lib/less-node/environment.js.map +0 -1
- package/lib/less-node/file-manager.js.map +0 -1
- package/lib/less-node/fs.js.map +0 -1
- package/lib/less-node/image-size.js.map +0 -1
- package/lib/less-node/index.js.map +0 -1
- package/lib/less-node/lessc-helper.js.map +0 -1
- package/lib/less-node/plugin-loader.js.map +0 -1
- package/lib/less-node/url-file-manager.js.map +0 -1
- package/test/.eslintrc.json +0 -9
- package/test/README.md +0 -3
- package/test/browser/common.js +0 -230
- package/test/browser/css/global-vars/simple.css +0 -3
- package/test/browser/css/modify-vars/simple.css +0 -8
- package/test/browser/css/plugin/plugin.css +0 -3
- package/test/browser/css/postProcessor/postProcessor.css +0 -4
- package/test/browser/css/relative-urls/urls.css +0 -36
- package/test/browser/css/rewrite-urls/urls.css +0 -36
- package/test/browser/css/rootpath/urls.css +0 -35
- package/test/browser/css/rootpath-relative/urls.css +0 -35
- package/test/browser/css/rootpath-rewrite-urls/urls.css +0 -35
- package/test/browser/css/urls.css +0 -54
- package/test/browser/generator/benchmark.config.js +0 -50
- package/test/browser/generator/generate.js +0 -78
- package/test/browser/generator/runner.config.js +0 -188
- package/test/browser/generator/runner.js +0 -2
- package/test/browser/generator/template.js +0 -93
- package/test/browser/generator/utils.js +0 -14
- package/test/browser/less/console-errors/test-error.less +0 -3
- package/test/browser/less/console-errors/test-error.txt +0 -2
- package/test/browser/less/errors/image-height-error.less +0 -3
- package/test/browser/less/errors/image-height-error.txt +0 -4
- package/test/browser/less/errors/image-size-error.less +0 -3
- package/test/browser/less/errors/image-size-error.txt +0 -4
- package/test/browser/less/errors/image-width-error.less +0 -3
- package/test/browser/less/errors/image-width-error.txt +0 -4
- package/test/browser/less/global-vars/simple.less +0 -3
- package/test/browser/less/imports/urls.less +0 -4
- package/test/browser/less/imports/urls2.less +0 -4
- package/test/browser/less/modify-vars/imports/simple2.less +0 -4
- package/test/browser/less/modify-vars/simple.less +0 -8
- package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
- package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
- package/test/browser/less/plugin/plugin.js +0 -4
- package/test/browser/less/plugin/plugin.less +0 -4
- package/test/browser/less/postProcessor/postProcessor.less +0 -4
- package/test/browser/less/relative-urls/urls.less +0 -34
- package/test/browser/less/rewrite-urls/urls.less +0 -34
- package/test/browser/less/rootpath/urls.less +0 -33
- package/test/browser/less/rootpath-relative/urls.less +0 -33
- package/test/browser/less/rootpath-rewrite-urls/urls.less +0 -33
- package/test/browser/less/urls.less +0 -62
- package/test/browser/runner-VisitorPlugin-options.js +0 -3
- package/test/browser/runner-VisitorPlugin.js +0 -3
- package/test/browser/runner-browser-options.js +0 -51
- package/test/browser/runner-browser-spec.js +0 -12
- package/test/browser/runner-console-errors.js +0 -5
- package/test/browser/runner-errors-options.js +0 -6
- package/test/browser/runner-errors-spec.js +0 -3
- package/test/browser/runner-filemanagerPlugin-options.js +0 -5
- package/test/browser/runner-filemanagerPlugin.js +0 -3
- package/test/browser/runner-global-vars-options.js +0 -7
- package/test/browser/runner-global-vars-spec.js +0 -3
- package/test/browser/runner-legacy-options.js +0 -6
- package/test/browser/runner-legacy-spec.js +0 -3
- package/test/browser/runner-main-options.js +0 -17
- package/test/browser/runner-main-spec.js +0 -7
- package/test/browser/runner-modify-vars-options.js +0 -5
- package/test/browser/runner-modify-vars-spec.js +0 -33
- package/test/browser/runner-no-js-errors-options.js +0 -4
- package/test/browser/runner-no-js-errors-spec.js +0 -3
- package/test/browser/runner-postProcessorPlugin-options.js +0 -3
- package/test/browser/runner-postProcessorPlugin.js +0 -3
- package/test/browser/runner-preProcessorPlugin-options.js +0 -3
- package/test/browser/runner-preProcessorPlugin.js +0 -3
- package/test/browser/runner-production-options.js +0 -3
- package/test/browser/runner-production-spec.js +0 -5
- package/test/browser/runner-relative-urls-options.js +0 -3
- package/test/browser/runner-relative-urls-spec.js +0 -3
- package/test/browser/runner-rewrite-urls-options.js +0 -3
- package/test/browser/runner-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-options.js +0 -3
- package/test/browser/runner-rootpath-relative-options.js +0 -4
- package/test/browser/runner-rootpath-relative-spec.js +0 -3
- package/test/browser/runner-rootpath-rewrite-urls-options.js +0 -4
- package/test/browser/runner-rootpath-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-spec.js +0 -3
- package/test/browser/runner-strict-units-options.js +0 -5
- package/test/browser/runner-strict-units-spec.js +0 -3
- package/test/index.js +0 -112
- package/test/less-test.js +0 -625
- package/test/mocha-playwright/runner.js +0 -210
- package/test/modify-vars.js +0 -28
- package/test/plugins/filemanager/index.js +0 -19
- package/test/plugins/postprocess/index.js +0 -14
- package/test/plugins/preprocess/index.js +0 -19
- package/test/plugins/visitor/index.js +0 -24
- package/test/sourcemaps/basic.json +0 -1
- package/test/sourcemaps/custom-props.json +0 -1
- package/test/sourcemaps/index.html +0 -17
- package/test/sourcemaps-disable-annotation/basic.json +0 -1
- package/test/sourcemaps-variable-selector/basic.json +0 -1
- package/test/test-es6.ts +0 -17
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -21
package/test/less-test.js
DELETED
|
@@ -1,625 +0,0 @@
|
|
|
1
|
-
/* jshint latedef: nofunc */
|
|
2
|
-
var semver = require('semver');
|
|
3
|
-
var logger = require('../lib/less/logger').default;
|
|
4
|
-
|
|
5
|
-
var isVerbose = process.env.npm_config_loglevel !== 'concise';
|
|
6
|
-
logger.addListener({
|
|
7
|
-
info(msg) {
|
|
8
|
-
if (isVerbose) {
|
|
9
|
-
process.stdout.write(msg + '\n');
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
warn(msg) {
|
|
13
|
-
process.stdout.write(msg + '\n');
|
|
14
|
-
},
|
|
15
|
-
error(msg) {
|
|
16
|
-
process.stdout.write(msg + '\n');
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
module.exports = function() {
|
|
22
|
-
var path = require('path'),
|
|
23
|
-
fs = require('fs'),
|
|
24
|
-
clone = require('copy-anything').copy;
|
|
25
|
-
|
|
26
|
-
var less = require('../');
|
|
27
|
-
|
|
28
|
-
var stylize = require('../lib/less-node/lessc-helper').stylize;
|
|
29
|
-
|
|
30
|
-
var globals = Object.keys(global);
|
|
31
|
-
|
|
32
|
-
var oneTestOnly = process.argv[2],
|
|
33
|
-
isFinished = false;
|
|
34
|
-
|
|
35
|
-
var testFolder = path.dirname(require.resolve('@less/test-data'));
|
|
36
|
-
var lessFolder = path.join(testFolder, 'less');
|
|
37
|
-
|
|
38
|
-
// Define String.prototype.endsWith if it doesn't exist (in older versions of node)
|
|
39
|
-
// This is required by the testSourceMap function below
|
|
40
|
-
if (typeof String.prototype.endsWith !== 'function') {
|
|
41
|
-
String.prototype.endsWith = function (str) {
|
|
42
|
-
return this.slice(-str.length) === str;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var queueList = [],
|
|
47
|
-
queueRunning = false;
|
|
48
|
-
function queue(func) {
|
|
49
|
-
if (queueRunning) {
|
|
50
|
-
// console.log("adding to queue");
|
|
51
|
-
queueList.push(func);
|
|
52
|
-
} else {
|
|
53
|
-
// console.log("first in queue - starting");
|
|
54
|
-
queueRunning = true;
|
|
55
|
-
func();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function release() {
|
|
59
|
-
if (queueList.length) {
|
|
60
|
-
// console.log("running next in queue");
|
|
61
|
-
var func = queueList.shift();
|
|
62
|
-
setTimeout(func, 0);
|
|
63
|
-
} else {
|
|
64
|
-
// console.log("stopping queue");
|
|
65
|
-
queueRunning = false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var totalTests = 0,
|
|
70
|
-
failedTests = 0,
|
|
71
|
-
passedTests = 0,
|
|
72
|
-
finishTimer = setInterval(endTest, 500);
|
|
73
|
-
|
|
74
|
-
less.functions.functionRegistry.addMultiple({
|
|
75
|
-
add: function (a, b) {
|
|
76
|
-
return new(less.tree.Dimension)(a.value + b.value);
|
|
77
|
-
},
|
|
78
|
-
increment: function (a) {
|
|
79
|
-
return new(less.tree.Dimension)(a.value + 1);
|
|
80
|
-
},
|
|
81
|
-
_color: function (str) {
|
|
82
|
-
if (str.value === 'evil red') { return new(less.tree.Color)('600'); }
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
function testSourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
|
|
87
|
-
if (err) {
|
|
88
|
-
fail('ERROR: ' + (err && err.message));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// Check the sourceMappingURL at the bottom of the file
|
|
92
|
-
var expectedSourceMapURL = name + '.css.map',
|
|
93
|
-
sourceMappingPrefix = '/*# sourceMappingURL=',
|
|
94
|
-
sourceMappingSuffix = ' */',
|
|
95
|
-
expectedCSSAppendage = sourceMappingPrefix + expectedSourceMapURL + sourceMappingSuffix;
|
|
96
|
-
if (!compiledLess.endsWith(expectedCSSAppendage)) {
|
|
97
|
-
// To display a better error message, we need to figure out what the actual sourceMappingURL value was, if it was even present
|
|
98
|
-
var indexOfSourceMappingPrefix = compiledLess.indexOf(sourceMappingPrefix);
|
|
99
|
-
if (indexOfSourceMappingPrefix === -1) {
|
|
100
|
-
fail('ERROR: sourceMappingURL was not found in ' + baseFolder + '/' + name + '.css.');
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var startOfSourceMappingValue = indexOfSourceMappingPrefix + sourceMappingPrefix.length,
|
|
105
|
-
indexOfNextSpace = compiledLess.indexOf(' ', startOfSourceMappingValue),
|
|
106
|
-
actualSourceMapURL = compiledLess.substring(startOfSourceMappingValue, indexOfNextSpace === -1 ? compiledLess.length : indexOfNextSpace);
|
|
107
|
-
fail('ERROR: sourceMappingURL should be "' + expectedSourceMapURL + '" but is "' + actualSourceMapURL + '".');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
|
|
111
|
-
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
|
|
112
|
-
if (sourcemap === expectedSourcemap) {
|
|
113
|
-
ok('OK');
|
|
114
|
-
} else if (err) {
|
|
115
|
-
fail('ERROR: ' + (err && err.message));
|
|
116
|
-
if (isVerbose) {
|
|
117
|
-
process.stdout.write('\n');
|
|
118
|
-
process.stdout.write(err.stack + '\n');
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
difference('FAIL', expectedSourcemap, sourcemap);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function testSourcemapWithoutUrlAnnotation(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
|
|
127
|
-
if (err) {
|
|
128
|
-
fail('ERROR: ' + (err && err.message));
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
// This matches with strings that end($) with source mapping url annotation.
|
|
132
|
-
var sourceMapRegExp = /\/\*# sourceMappingURL=.+\.css\.map \*\/$/;
|
|
133
|
-
if (sourceMapRegExp.test(compiledLess)) {
|
|
134
|
-
fail('ERROR: sourceMappingURL found in ' + baseFolder + '/' + name + '.css.');
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Even if annotation is not necessary, the map file should be there.
|
|
139
|
-
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
|
|
140
|
-
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
|
|
141
|
-
if (sourcemap === expectedSourcemap) {
|
|
142
|
-
ok('OK');
|
|
143
|
-
} else if (err) {
|
|
144
|
-
fail('ERROR: ' + (err && err.message));
|
|
145
|
-
if (isVerbose) {
|
|
146
|
-
process.stdout.write('\n');
|
|
147
|
-
process.stdout.write(err.stack + '\n');
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
difference('FAIL', expectedSourcemap, sourcemap);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function testEmptySourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
|
|
156
|
-
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
|
|
157
|
-
if (err) {
|
|
158
|
-
fail('ERROR: ' + (err && err.message));
|
|
159
|
-
} else {
|
|
160
|
-
var expectedSourcemap = undefined;
|
|
161
|
-
if ( compiledLess !== '' ) {
|
|
162
|
-
difference('\nCompiledLess must be empty', '', compiledLess);
|
|
163
|
-
|
|
164
|
-
} else if (sourcemap !== expectedSourcemap) {
|
|
165
|
-
fail('Sourcemap must be undefined');
|
|
166
|
-
} else {
|
|
167
|
-
ok('OK');
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
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
|
-
|
|
195
|
-
function testImports(name, err, compiledLess, doReplacements, sourcemap, baseFolder, imports) {
|
|
196
|
-
if (err) {
|
|
197
|
-
fail('ERROR: ' + (err && err.message));
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function stringify(str) {
|
|
202
|
-
return JSON.stringify(imports, null, ' ')
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/** Imports are not sorted */
|
|
206
|
-
const importsString = stringify(imports.sort())
|
|
207
|
-
|
|
208
|
-
fs.readFile(path.join(lessFolder, name) + '.json', 'utf8', function (e, expectedImports) {
|
|
209
|
-
if (e) {
|
|
210
|
-
fail('ERROR: ' + (e && e.message));
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
|
|
214
|
-
expectedImports = stringify(JSON.parse(expectedImports).sort());
|
|
215
|
-
expectedImports = globalReplacements(expectedImports, baseFolder);
|
|
216
|
-
|
|
217
|
-
if (expectedImports === importsString) {
|
|
218
|
-
ok('OK');
|
|
219
|
-
} else if (err) {
|
|
220
|
-
fail('ERROR: ' + (err && err.message));
|
|
221
|
-
if (isVerbose) {
|
|
222
|
-
process.stdout.write('\n');
|
|
223
|
-
process.stdout.write(err.stack + '\n');
|
|
224
|
-
}
|
|
225
|
-
} else {
|
|
226
|
-
difference('FAIL', expectedImports, importsString);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function testErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
|
|
232
|
-
fs.readFile(path.join(baseFolder, name) + '.txt', 'utf8', function (e, expectedErr) {
|
|
233
|
-
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
|
|
234
|
-
expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename);
|
|
235
|
-
if (!err) {
|
|
236
|
-
if (compiledLess) {
|
|
237
|
-
fail('No Error', 'red');
|
|
238
|
-
} else {
|
|
239
|
-
fail('No Error, No Output');
|
|
240
|
-
}
|
|
241
|
-
} else {
|
|
242
|
-
var errMessage = err.toString();
|
|
243
|
-
if (errMessage === expectedErr) {
|
|
244
|
-
ok('OK');
|
|
245
|
-
} else {
|
|
246
|
-
difference('FAIL', expectedErr, errMessage);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// To fix ci fail about error format change in upstream v8 project
|
|
253
|
-
// https://github.com/v8/v8/commit/c0fd89c3c089e888c4f4e8582e56db7066fa779b
|
|
254
|
-
// Node 16.9.0+ include this change via https://github.com/nodejs/node/pull/39947
|
|
255
|
-
function testTypeErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
|
|
256
|
-
const fileSuffix = semver.gte(process.version, 'v16.9.0') ? '-2.txt' : '.txt';
|
|
257
|
-
fs.readFile(path.join(baseFolder, name) + fileSuffix, 'utf8', function (e, expectedErr) {
|
|
258
|
-
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
|
|
259
|
-
expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename);
|
|
260
|
-
if (!err) {
|
|
261
|
-
if (compiledLess) {
|
|
262
|
-
fail('No Error', 'red');
|
|
263
|
-
} else {
|
|
264
|
-
fail('No Error, No Output');
|
|
265
|
-
}
|
|
266
|
-
} else {
|
|
267
|
-
var errMessage = err.toString();
|
|
268
|
-
if (errMessage === expectedErr) {
|
|
269
|
-
ok('OK');
|
|
270
|
-
} else {
|
|
271
|
-
difference('FAIL', expectedErr, errMessage);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// https://github.com/less/less.js/issues/3112
|
|
278
|
-
function testJSImport() {
|
|
279
|
-
process.stdout.write('- Testing root function registry');
|
|
280
|
-
less.functions.functionRegistry.add('ext', function() {
|
|
281
|
-
return new less.tree.Anonymous('file');
|
|
282
|
-
});
|
|
283
|
-
var expected = '@charset "utf-8";\n';
|
|
284
|
-
toCSS({}, path.join(lessFolder, 'root-registry', 'root.less'), function(error, output) {
|
|
285
|
-
if (error) {
|
|
286
|
-
return fail('ERROR: ' + error);
|
|
287
|
-
}
|
|
288
|
-
if (output.css === expected) {
|
|
289
|
-
return ok('OK');
|
|
290
|
-
}
|
|
291
|
-
difference('FAIL', expected, output.css);
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function globalReplacements(input, directory, filename) {
|
|
296
|
-
var path = require('path');
|
|
297
|
-
var p = filename ? path.join(path.dirname(filename), '/') : directory,
|
|
298
|
-
pathimport = path.join(directory + 'import/'),
|
|
299
|
-
pathesc = p.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); }),
|
|
300
|
-
pathimportesc = pathimport.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); });
|
|
301
|
-
|
|
302
|
-
return input.replace(/\{path\}/g, p)
|
|
303
|
-
.replace(/\{node\}/g, '')
|
|
304
|
-
.replace(/\{\/node\}/g, '')
|
|
305
|
-
.replace(/\{pathhref\}/g, '')
|
|
306
|
-
.replace(/\{404status\}/g, '')
|
|
307
|
-
.replace(/\{nodepath\}/g, path.join(process.cwd(), 'node_modules', '/'))
|
|
308
|
-
.replace(/\{pathrel\}/g, path.join(path.relative(lessFolder, p), '/'))
|
|
309
|
-
.replace(/\{pathesc\}/g, pathesc)
|
|
310
|
-
.replace(/\{pathimport\}/g, pathimport)
|
|
311
|
-
.replace(/\{pathimportesc\}/g, pathimportesc)
|
|
312
|
-
.replace(/\r\n/g, '\n');
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function checkGlobalLeaks() {
|
|
316
|
-
return Object.keys(global).filter(function(v) {
|
|
317
|
-
return globals.indexOf(v) < 0;
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function testSyncronous(options, filenameNoExtension) {
|
|
322
|
-
if (oneTestOnly && ('Test Sync ' + filenameNoExtension) !== oneTestOnly) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
totalTests++;
|
|
326
|
-
queue(function() {
|
|
327
|
-
var isSync = true;
|
|
328
|
-
toCSS(options, path.join(lessFolder, filenameNoExtension + '.less'), function (err, result) {
|
|
329
|
-
process.stdout.write('- Test Sync ' + filenameNoExtension + ': ');
|
|
330
|
-
|
|
331
|
-
if (isSync) {
|
|
332
|
-
ok('OK');
|
|
333
|
-
} else {
|
|
334
|
-
fail('Not Sync');
|
|
335
|
-
}
|
|
336
|
-
release();
|
|
337
|
-
});
|
|
338
|
-
isSync = false;
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function runTestSet(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
|
|
343
|
-
options = options ? clone(options) : {};
|
|
344
|
-
runTestSetInternal(lessFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function runTestSetNormalOnly(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
|
|
348
|
-
runTestSetInternal(lessFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function runTestSetInternal(baseFolder, opts, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
|
|
352
|
-
foldername = foldername || '';
|
|
353
|
-
|
|
354
|
-
var originalOptions = opts || {};
|
|
355
|
-
|
|
356
|
-
if (!doReplacements) {
|
|
357
|
-
doReplacements = globalReplacements;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function getBasename(file) {
|
|
361
|
-
return foldername + path.basename(file, '.less');
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
fs.readdirSync(path.join(baseFolder, foldername)).forEach(function (file) {
|
|
365
|
-
if (!/\.less$/.test(file)) { return; }
|
|
366
|
-
|
|
367
|
-
var options = clone(originalOptions);
|
|
368
|
-
|
|
369
|
-
options.stylize = stylize;
|
|
370
|
-
|
|
371
|
-
var name = getBasename(file);
|
|
372
|
-
|
|
373
|
-
if (oneTestOnly && name !== oneTestOnly) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
totalTests++;
|
|
378
|
-
|
|
379
|
-
if (options.sourceMap && !options.sourceMap.sourceMapFileInline) {
|
|
380
|
-
options.sourceMap = {
|
|
381
|
-
sourceMapOutputFilename: name + '.css',
|
|
382
|
-
sourceMapBasepath: baseFolder,
|
|
383
|
-
sourceMapRootpath: 'testweb/',
|
|
384
|
-
disableSourcemapAnnotation: options.sourceMap.disableSourcemapAnnotation
|
|
385
|
-
};
|
|
386
|
-
// This options is normally set by the bin/lessc script. Setting it causes the sourceMappingURL comment to be appended to the CSS
|
|
387
|
-
// output. The value is designed to allow the sourceMapBasepath option to be tested, as it should be removed by less before
|
|
388
|
-
// setting the sourceMappingURL value, leaving just the sourceMapOutputFilename and .map extension.
|
|
389
|
-
options.sourceMap.sourceMapFilename = options.sourceMap.sourceMapBasepath + '/' + options.sourceMap.sourceMapOutputFilename + '.map';
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
options.getVars = function(file) {
|
|
393
|
-
try {
|
|
394
|
-
return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars', baseFolder), 'utf8'));
|
|
395
|
-
}
|
|
396
|
-
catch (e) {
|
|
397
|
-
return {};
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
var doubleCallCheck = false;
|
|
402
|
-
queue(function() {
|
|
403
|
-
toCSS(options, path.join(baseFolder, foldername + file), function (err, result) {
|
|
404
|
-
|
|
405
|
-
if (doubleCallCheck) {
|
|
406
|
-
totalTests++;
|
|
407
|
-
fail('less is calling back twice');
|
|
408
|
-
process.stdout.write(doubleCallCheck + '\n');
|
|
409
|
-
process.stdout.write((new Error()).stack + '\n');
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
doubleCallCheck = (new Error()).stack;
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* @todo - refactor so the result object is sent to the verify function
|
|
416
|
-
*/
|
|
417
|
-
if (verifyFunction) {
|
|
418
|
-
var verificationResult = verifyFunction(
|
|
419
|
-
name, err, result && result.css, doReplacements, result && result.map, baseFolder, result && result.imports
|
|
420
|
-
);
|
|
421
|
-
release();
|
|
422
|
-
return verificationResult;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
if (err) {
|
|
426
|
-
fail('ERROR: ' + (err && err.message));
|
|
427
|
-
if (isVerbose) {
|
|
428
|
-
process.stdout.write('\n');
|
|
429
|
-
if (err.stack) {
|
|
430
|
-
process.stdout.write(err.stack + '\n');
|
|
431
|
-
} else {
|
|
432
|
-
// this sometimes happen - show the whole error object
|
|
433
|
-
console.log(err);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
release();
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
var css_name = name;
|
|
440
|
-
if (nameModifier) { css_name = nameModifier(name); }
|
|
441
|
-
|
|
442
|
-
fs.readFile(path.join(testFolder, 'css', css_name) + '.css', 'utf8', function (e, css) {
|
|
443
|
-
process.stdout.write('- ' + path.join(baseFolder, css_name) + ': ');
|
|
444
|
-
|
|
445
|
-
css = css && doReplacements(css, path.join(baseFolder, foldername));
|
|
446
|
-
if (result.css === css) { ok('OK'); }
|
|
447
|
-
else {
|
|
448
|
-
difference('FAIL', css, result.css);
|
|
449
|
-
}
|
|
450
|
-
release();
|
|
451
|
-
});
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
function diff(left, right) {
|
|
458
|
-
require('diff').diffLines(left, right).forEach(function(item) {
|
|
459
|
-
if (item.added || item.removed) {
|
|
460
|
-
var text = item.value && item.value.replace('\n', String.fromCharCode(182) + '\n').replace('\ufeff', '[[BOM]]');
|
|
461
|
-
process.stdout.write(stylize(text, item.added ? 'green' : 'red'));
|
|
462
|
-
} else {
|
|
463
|
-
process.stdout.write(item.value && item.value.replace('\ufeff', '[[BOM]]'));
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
process.stdout.write('\n');
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function fail(msg) {
|
|
470
|
-
process.stdout.write(stylize(msg, 'red') + '\n');
|
|
471
|
-
failedTests++;
|
|
472
|
-
endTest();
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function difference(msg, left, right) {
|
|
476
|
-
process.stdout.write(stylize(msg, 'yellow') + '\n');
|
|
477
|
-
failedTests++;
|
|
478
|
-
|
|
479
|
-
diff(left || '', right || '');
|
|
480
|
-
endTest();
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function ok(msg) {
|
|
484
|
-
process.stdout.write(stylize(msg, 'green') + '\n');
|
|
485
|
-
passedTests++;
|
|
486
|
-
endTest();
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function finished() {
|
|
490
|
-
isFinished = true;
|
|
491
|
-
endTest();
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function endTest() {
|
|
495
|
-
if (isFinished && ((failedTests + passedTests) >= totalTests)) {
|
|
496
|
-
clearInterval(finishTimer);
|
|
497
|
-
var leaked = checkGlobalLeaks();
|
|
498
|
-
process.stdout.write('\n');
|
|
499
|
-
if (failedTests > 0) {
|
|
500
|
-
process.stdout.write(failedTests + stylize(' Failed', 'red') + ', ' + passedTests + ' passed\n');
|
|
501
|
-
} else {
|
|
502
|
-
process.stdout.write(stylize('All Passed ', 'green') + passedTests + ' run\n');
|
|
503
|
-
}
|
|
504
|
-
if (leaked.length > 0) {
|
|
505
|
-
process.stdout.write('\n');
|
|
506
|
-
process.stdout.write(stylize('Global leak detected: ', 'red') + leaked.join(', ') + '\n');
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
if (leaked.length || failedTests) {
|
|
510
|
-
process.on('exit', function() { process.reallyExit(1); });
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function contains(fullArray, obj) {
|
|
516
|
-
for (var i = 0; i < fullArray.length; i++) {
|
|
517
|
-
if (fullArray[i] === obj) {
|
|
518
|
-
return true;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return false;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
*
|
|
526
|
-
* @param {Object} options
|
|
527
|
-
* @param {string} filePath
|
|
528
|
-
* @param {Function} callback
|
|
529
|
-
*/
|
|
530
|
-
function toCSS(options, filePath, callback) {
|
|
531
|
-
options = options || {};
|
|
532
|
-
var str = fs.readFileSync(filePath, 'utf8'), addPath = path.dirname(filePath);
|
|
533
|
-
if (typeof options.paths !== 'string') {
|
|
534
|
-
options.paths = options.paths || [];
|
|
535
|
-
if (!contains(options.paths, addPath)) {
|
|
536
|
-
options.paths.push(addPath);
|
|
537
|
-
}
|
|
538
|
-
} else {
|
|
539
|
-
options.paths = [options.paths]
|
|
540
|
-
}
|
|
541
|
-
options.paths = options.paths.map(searchPath => {
|
|
542
|
-
return path.resolve(lessFolder, searchPath)
|
|
543
|
-
})
|
|
544
|
-
options.filename = path.resolve(process.cwd(), filePath);
|
|
545
|
-
options.optimization = options.optimization || 0;
|
|
546
|
-
|
|
547
|
-
if (options.globalVars) {
|
|
548
|
-
options.globalVars = options.getVars(filePath);
|
|
549
|
-
} else if (options.modifyVars) {
|
|
550
|
-
options.modifyVars = options.getVars(filePath);
|
|
551
|
-
}
|
|
552
|
-
if (options.plugin) {
|
|
553
|
-
var Plugin = require(path.resolve(process.cwd(), options.plugin));
|
|
554
|
-
options.plugins = [Plugin];
|
|
555
|
-
}
|
|
556
|
-
less.render(str, options, callback);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function testNoOptions() {
|
|
560
|
-
if (oneTestOnly && 'Integration' !== oneTestOnly) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
totalTests++;
|
|
564
|
-
try {
|
|
565
|
-
process.stdout.write('- Integration - creating parser without options: ');
|
|
566
|
-
less.render('');
|
|
567
|
-
} catch (e) {
|
|
568
|
-
fail(stylize('FAIL\n', 'red'));
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
ok(stylize('OK\n', 'green'));
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
function testImportRedirect(nockScope) {
|
|
575
|
-
return (name, err, css, doReplacements, sourcemap, baseFolder) => {
|
|
576
|
-
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
|
|
577
|
-
if (err) {
|
|
578
|
-
fail('FAIL: ' + (err && err.message));
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
const expected = 'h1 {\n color: red;\n}\n';
|
|
582
|
-
if (css !== expected) {
|
|
583
|
-
difference('FAIL', expected, css);
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
nockScope.done();
|
|
587
|
-
ok('OK');
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
function testDisablePluginRule() {
|
|
592
|
-
less.render(
|
|
593
|
-
'@plugin "../../plugin/some_plugin";',
|
|
594
|
-
{disablePluginRule: true},
|
|
595
|
-
function(err) {
|
|
596
|
-
// TODO: Need a better way of identifing exactly which error is thrown. Checking
|
|
597
|
-
// text like this tends to be rather brittle.
|
|
598
|
-
const EXPECTED = '@plugin statements are not allowed when disablePluginRule is set to true';
|
|
599
|
-
if (!err || String(err).indexOf(EXPECTED) < 0) {
|
|
600
|
-
fail('ERROR: Expected "' + EXPECTED + '" error');
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
ok(stylize('OK\n', 'green'));
|
|
604
|
-
}
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
return {
|
|
609
|
-
runTestSet: runTestSet,
|
|
610
|
-
runTestSetNormalOnly: runTestSetNormalOnly,
|
|
611
|
-
testSyncronous: testSyncronous,
|
|
612
|
-
testErrors: testErrors,
|
|
613
|
-
testTypeErrors: testTypeErrors,
|
|
614
|
-
testSourcemap: testSourcemap,
|
|
615
|
-
testSourcemapWithoutUrlAnnotation: testSourcemapWithoutUrlAnnotation,
|
|
616
|
-
testSourcemapWithVariableInSelector: testSourcemapWithVariableInSelector,
|
|
617
|
-
testImports: testImports,
|
|
618
|
-
testImportRedirect: testImportRedirect,
|
|
619
|
-
testEmptySourcemap: testEmptySourcemap,
|
|
620
|
-
testNoOptions: testNoOptions,
|
|
621
|
-
testDisablePluginRule: testDisablePluginRule,
|
|
622
|
-
testJSImport: testJSImport,
|
|
623
|
-
finished: finished
|
|
624
|
-
};
|
|
625
|
-
};
|