less 2.1.1 → 2.3.1
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/.idea/inspectionProfiles/Project_Default.xml +1 -0
- package/.idea/jsLinters/jscs.xml +4 -0
- package/.idea/jsLinters/jshint.xml +58 -4
- package/.idea/workspace.xml +451 -758
- package/.jscsrc +38 -0
- package/.jshintrc +0 -2
- package/.travis.yml +0 -1
- package/CHANGELOG.md +52 -0
- package/Gruntfile.js +37 -3
- package/bin/lessc +380 -316
- package/bower.json +1 -1
- package/dist/less.js +790 -479
- package/dist/less.min.js +7 -7
- package/lib/less/contexts.js +1 -1
- package/lib/less/data/unit-conversions.js +3 -3
- package/lib/less/environment/abstract-file-manager.js +4 -4
- package/lib/less/environment/environment.js +9 -0
- package/lib/less/functions/color-blending.js +3 -3
- package/lib/less/functions/color.js +8 -8
- package/lib/less/functions/data-uri.js +39 -31
- package/lib/less/functions/string.js +3 -1
- package/lib/less/functions/svg.js +12 -15
- package/lib/less/functions/types.js +15 -2
- package/lib/less/import-manager.js +10 -5
- package/lib/less/index.js +2 -1
- package/lib/less/parse-tree.js +8 -2
- package/lib/less/parse.js +65 -0
- package/lib/less/parser/parser-input.js +3 -2
- package/lib/less/parser/parser.js +24 -11
- package/lib/less/render.js +7 -36
- package/lib/less/source-map-output.js +3 -3
- package/lib/less/transform-tree.js +1 -1
- package/lib/less/tree/assignment.js +0 -1
- package/lib/less/tree/color.js +4 -4
- package/lib/less/tree/condition.js +1 -1
- package/lib/less/tree/debug-info.js +6 -2
- package/lib/less/tree/dimension.js +1 -1
- package/lib/less/tree/directive.js +25 -6
- package/lib/less/tree/expression.js +1 -1
- package/lib/less/tree/import.js +2 -2
- package/lib/less/tree/index.js +1 -0
- package/lib/less/tree/media.js +3 -2
- package/lib/less/tree/mixin-call.js +3 -4
- package/lib/less/tree/mixin-definition.js +4 -3
- package/lib/less/tree/quoted.js +1 -1
- package/lib/less/tree/rule.js +2 -3
- package/lib/less/tree/ruleset.js +263 -157
- package/lib/less/tree/selector.js +2 -1
- package/lib/less/tree/url.js +5 -2
- package/lib/less/tree/value.js +1 -1
- package/lib/less/tree/variable.js +1 -1
- package/lib/less/visitors/extend-visitor.js +60 -25
- package/lib/less/visitors/import-sequencer.js +20 -14
- package/lib/less/visitors/import-visitor.js +13 -10
- package/lib/less/visitors/to-css-visitor.js +37 -5
- package/lib/less-browser/add-default-options.js +5 -1
- package/lib/less-browser/bootstrap.js +10 -8
- package/lib/less-browser/cache.js +1 -1
- package/lib/less-browser/index.js +13 -12
- package/lib/less-browser/utils.js +9 -6
- package/lib/less-node/file-manager.js +51 -28
- package/lib/less-node/image-size.js +34 -0
- package/lib/less-node/index.js +3 -0
- package/lib/less-node/lessc-helper.js +3 -2
- package/lib/less-node/url-file-manager.js +2 -2
- package/lib/less-rhino/index.js +2 -4
- package/package.json +10 -7
- package/test/browser/common.js +13 -11
- package/test/browser/css/urls.css +6 -3
- package/test/browser/jasmine-jsreporter.js +2 -3
- package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
- package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
- package/test/browser/less/urls.less +1 -0
- package/test/browser/less.js +15 -9424
- package/test/browser/runner-errors-options.js +0 -1
- package/test/browser/runner-errors-spec.js +0 -1
- package/test/browser/runner-legacy-options.js +0 -1
- package/test/browser/runner-no-js-errors-spec.js +0 -1
- package/test/browser/runner-production-options.js +0 -1
- package/test/browser/runner-relative-urls-options.js +0 -1
- package/test/browser/runner-rootpath-options.js +0 -1
- package/test/browser/runner-rootpath-relative-options.js +0 -1
- package/test/browser/runner-strict-units-options.js +0 -1
- package/test/copy-bom.js +72 -0
- package/test/css/comments.css +1 -0
- package/test/css/css-3.css +2 -0
- package/test/css/functions.css +2 -0
- package/test/css/import-interpolation.css +6 -0
- package/test/css/import-reference.css +25 -0
- package/test/css/include-path/include-path.css +6 -0
- package/test/css/mixins-important.css +6 -0
- package/test/css/selectors.css +10 -1
- package/test/css/url-args/urls.css +3 -3
- package/test/css/urls.css +12 -4
- package/test/css/variables.css +7 -1
- package/test/data/image.svg +3 -0
- package/test/index.js +14 -10
- package/test/less/comments.less +1 -0
- package/test/less/css-3.less +3 -0
- package/test/less/css-guards.less +2 -1
- package/test/less/errors/detached-ruleset-2.txt +1 -1
- package/test/less/errors/import-missing.txt +1 -1
- package/test/less/errors/parens-error-1.txt +1 -1
- package/test/less/errors/parens-error-2.txt +1 -1
- package/test/less/errors/parens-error-3.txt +1 -1
- package/test/less/errors/single-character.less +1 -0
- package/test/less/errors/single-character.txt +2 -0
- package/test/less/functions.less +5 -0
- package/test/less/import/import-interpolation.less +1 -0
- package/test/less/import/import-reference.less +38 -0
- package/test/less/import-reference.less +3 -1
- package/test/less/import.less +2 -0
- package/test/less/include-path/include-path.less +6 -0
- package/test/less/mixins-important.less +12 -0
- package/test/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
- package/test/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
- package/test/less/selectors.less +19 -4
- package/test/less/urls.less +10 -1
- package/test/less/variables.less +17 -3
- package/test/less-bom/charsets.less +3 -0
- package/test/less-bom/colors.less +98 -0
- package/test/less-bom/comments.less +102 -0
- package/test/less-bom/comments2.less +20 -0
- package/test/less-bom/compression/compression.less +36 -0
- package/test/less-bom/css-3.less +154 -0
- package/test/less-bom/css-escapes.less +33 -0
- package/test/less-bom/css-guards.less +103 -0
- package/test/less-bom/css.less +108 -0
- package/test/less-bom/debug/import/test.less +25 -0
- package/test/less-bom/debug/linenumbers.less +33 -0
- package/test/less-bom/detached-rulesets.less +103 -0
- package/test/less-bom/empty.less +1 -0
- package/test/less-bom/errors/add-mixed-units.less +3 -0
- package/test/less-bom/errors/add-mixed-units.txt +4 -0
- package/test/less-bom/errors/add-mixed-units2.less +3 -0
- package/test/less-bom/errors/add-mixed-units2.txt +4 -0
- package/test/less-bom/errors/at-rules-undefined-var.less +4 -0
- package/test/less-bom/errors/at-rules-undefined-var.txt +4 -0
- package/test/less-bom/errors/bad-variable-declaration1.less +1 -0
- package/test/less-bom/errors/bad-variable-declaration1.txt +2 -0
- package/test/less-bom/errors/color-func-invalid-color.less +3 -0
- package/test/less-bom/errors/color-func-invalid-color.txt +4 -0
- package/test/less-bom/errors/color-invalid-hex-code.less +3 -0
- package/test/less-bom/errors/color-invalid-hex-code.txt +4 -0
- package/test/less-bom/errors/color-invalid-hex-code2.less +3 -0
- package/test/less-bom/errors/color-invalid-hex-code2.txt +4 -0
- package/test/less-bom/errors/css-guard-default-func.less +4 -0
- package/test/less-bom/errors/css-guard-default-func.txt +4 -0
- package/test/less-bom/errors/detached-ruleset-1.less +6 -0
- package/test/less-bom/errors/detached-ruleset-1.txt +4 -0
- package/test/less-bom/errors/detached-ruleset-2.less +6 -0
- package/test/less-bom/errors/detached-ruleset-2.txt +4 -0
- package/test/less-bom/errors/detached-ruleset-3.less +4 -0
- package/test/less-bom/errors/detached-ruleset-3.txt +4 -0
- package/test/less-bom/errors/detached-ruleset-4.less +5 -0
- package/test/less-bom/errors/detached-ruleset-4.txt +4 -0
- package/test/less-bom/errors/detached-ruleset-5.less +4 -0
- package/test/less-bom/errors/detached-ruleset-5.txt +3 -0
- package/test/less-bom/errors/detached-ruleset-6.less +5 -0
- package/test/less-bom/errors/detached-ruleset-6.txt +4 -0
- package/test/less-bom/errors/divide-mixed-units.less +3 -0
- package/test/less-bom/errors/divide-mixed-units.txt +4 -0
- package/test/less-bom/errors/extend-no-selector.less +3 -0
- package/test/less-bom/errors/extend-no-selector.txt +3 -0
- package/test/less-bom/errors/extend-not-at-end.less +3 -0
- package/test/less-bom/errors/extend-not-at-end.txt +3 -0
- package/test/less-bom/errors/import-malformed.less +1 -0
- package/test/less-bom/errors/import-malformed.txt +3 -0
- package/test/less-bom/errors/import-missing.less +6 -0
- package/test/less-bom/errors/import-missing.txt +3 -0
- package/test/less-bom/errors/import-no-semi.less +1 -0
- package/test/less-bom/errors/import-no-semi.txt +2 -0
- package/test/less-bom/errors/import-subfolder1.less +1 -0
- package/test/less-bom/errors/import-subfolder1.txt +3 -0
- package/test/less-bom/errors/import-subfolder2.less +1 -0
- package/test/less-bom/errors/import-subfolder2.txt +4 -0
- package/test/less-bom/errors/imports/import-subfolder1.less +1 -0
- package/test/less-bom/errors/imports/import-subfolder2.less +1 -0
- package/test/less-bom/errors/imports/import-test.less +4 -0
- package/test/less-bom/errors/imports/subfolder/mixin-not-defined.less +1 -0
- package/test/less-bom/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
- package/test/less-bom/errors/javascript-error.less +3 -0
- package/test/less-bom/errors/javascript-error.txt +4 -0
- package/test/less-bom/errors/javascript-undefined-var.less +3 -0
- package/test/less-bom/errors/javascript-undefined-var.txt +4 -0
- package/test/less-bom/errors/mixed-mixin-definition-args-1.less +6 -0
- package/test/less-bom/errors/mixed-mixin-definition-args-1.txt +4 -0
- package/test/less-bom/errors/mixed-mixin-definition-args-2.less +6 -0
- package/test/less-bom/errors/mixed-mixin-definition-args-2.txt +4 -0
- package/test/less-bom/errors/mixin-not-defined.less +11 -0
- package/test/less-bom/errors/mixin-not-defined.txt +3 -0
- package/test/less-bom/errors/mixin-not-matched.less +6 -0
- package/test/less-bom/errors/mixin-not-matched.txt +3 -0
- package/test/less-bom/errors/mixin-not-matched2.less +6 -0
- package/test/less-bom/errors/mixin-not-matched2.txt +3 -0
- package/test/less-bom/errors/mixin-not-visible-in-scope-1.less +9 -0
- package/test/less-bom/errors/mixin-not-visible-in-scope-1.txt +4 -0
- package/test/less-bom/errors/mixins-guards-default-func-1.less +9 -0
- package/test/less-bom/errors/mixins-guards-default-func-1.txt +4 -0
- package/test/less-bom/errors/mixins-guards-default-func-2.less +9 -0
- package/test/less-bom/errors/mixins-guards-default-func-2.txt +4 -0
- package/test/less-bom/errors/mixins-guards-default-func-3.less +9 -0
- package/test/less-bom/errors/mixins-guards-default-func-3.txt +4 -0
- package/test/less-bom/errors/multiple-guards-on-css-selectors.less +4 -0
- package/test/less-bom/errors/multiple-guards-on-css-selectors.txt +4 -0
- package/test/less-bom/errors/multiple-guards-on-css-selectors2.less +4 -0
- package/test/less-bom/errors/multiple-guards-on-css-selectors2.txt +4 -0
- package/test/less-bom/errors/multiply-mixed-units.less +7 -0
- package/test/less-bom/errors/multiply-mixed-units.txt +4 -0
- package/test/less-bom/errors/parens-error-1.less +3 -0
- package/test/less-bom/errors/parens-error-1.txt +4 -0
- package/test/less-bom/errors/parens-error-2.less +3 -0
- package/test/less-bom/errors/parens-error-2.txt +4 -0
- package/test/less-bom/errors/parens-error-3.less +3 -0
- package/test/less-bom/errors/parens-error-3.txt +4 -0
- package/test/less-bom/errors/parse-error-curly-bracket.less +4 -0
- package/test/less-bom/errors/parse-error-curly-bracket.txt +4 -0
- package/test/less-bom/errors/parse-error-extra-parens.less +5 -0
- package/test/less-bom/errors/parse-error-extra-parens.txt +3 -0
- package/test/less-bom/errors/parse-error-missing-bracket.less +2 -0
- package/test/less-bom/errors/parse-error-missing-bracket.txt +3 -0
- package/test/less-bom/errors/parse-error-missing-parens.less +5 -0
- package/test/less-bom/errors/parse-error-missing-parens.txt +3 -0
- package/test/less-bom/errors/parse-error-with-import.less +13 -0
- package/test/less-bom/errors/parse-error-with-import.txt +4 -0
- package/test/less-bom/errors/percentage-missing-space.less +3 -0
- package/test/less-bom/errors/percentage-missing-space.txt +4 -0
- package/test/less-bom/errors/property-asterisk-only-name.less +3 -0
- package/test/less-bom/errors/property-asterisk-only-name.txt +4 -0
- package/test/less-bom/errors/property-ie5-hack.less +3 -0
- package/test/less-bom/errors/property-ie5-hack.txt +3 -0
- package/test/less-bom/errors/property-in-root.less +4 -0
- package/test/less-bom/errors/property-in-root.txt +4 -0
- package/test/less-bom/errors/property-in-root2.less +1 -0
- package/test/less-bom/errors/property-in-root2.txt +4 -0
- package/test/less-bom/errors/property-in-root3.less +4 -0
- package/test/less-bom/errors/property-in-root3.txt +3 -0
- package/test/less-bom/errors/property-interp-not-defined.less +1 -0
- package/test/less-bom/errors/property-interp-not-defined.txt +2 -0
- package/test/less-bom/errors/recursive-variable.less +1 -0
- package/test/less-bom/errors/recursive-variable.txt +2 -0
- package/test/less-bom/errors/single-character.less +1 -0
- package/test/less-bom/errors/single-character.txt +2 -0
- package/test/less-bom/errors/svg-gradient1.less +3 -0
- package/test/less-bom/errors/svg-gradient1.txt +4 -0
- package/test/less-bom/errors/svg-gradient2.less +3 -0
- package/test/less-bom/errors/svg-gradient2.txt +4 -0
- package/test/less-bom/errors/svg-gradient3.less +3 -0
- package/test/less-bom/errors/svg-gradient3.txt +4 -0
- package/test/less-bom/errors/unit-function.less +3 -0
- package/test/less-bom/errors/unit-function.txt +4 -0
- package/test/less-bom/extend-chaining.less +91 -0
- package/test/less-bom/extend-clearfix.less +19 -0
- package/test/less-bom/extend-exact.less +46 -0
- package/test/less-bom/extend-media.less +24 -0
- package/test/less-bom/extend-nest.less +65 -0
- package/test/less-bom/extend-selector.less +99 -0
- package/test/less-bom/extend.less +81 -0
- package/test/less-bom/extract-and-length.less +133 -0
- package/test/less-bom/functions.less +201 -0
- package/test/less-bom/globalVars/extended.json +5 -0
- package/test/less-bom/globalVars/extended.less +10 -0
- package/test/less-bom/globalVars/simple.json +3 -0
- package/test/less-bom/globalVars/simple.less +3 -0
- package/test/less-bom/ie-filters.less +15 -0
- package/test/less-bom/import/deeper/deeper-2/url-import-2.less +3 -0
- package/test/less-bom/import/deeper/deeper-2/url-import.less +1 -0
- package/test/less-bom/import/deeper/import-once-test-a.less +1 -0
- package/test/less-bom/import/deeper/url-import.less +1 -0
- package/test/less-bom/import/import-and-relative-paths-test.less +17 -0
- package/test/less-bom/import/import-charset-test.less +1 -0
- package/test/less-bom/import/import-interpolation.less +2 -0
- package/test/less-bom/import/import-interpolation2.less +5 -0
- package/test/less-bom/import/import-once-test-c.less +6 -0
- package/test/less-bom/import/import-reference.less +89 -0
- package/test/less-bom/import/import-test-a.less +4 -0
- package/test/less-bom/import/import-test-b.less +8 -0
- package/test/less-bom/import/import-test-c.less +6 -0
- package/test/less-bom/import/import-test-d.css +1 -0
- package/test/less-bom/import/import-test-e.less +2 -0
- package/test/less-bom/import/import-test-f.less +5 -0
- package/test/less-bom/import/imports/font.less +8 -0
- package/test/less-bom/import/imports/logo.less +5 -0
- package/test/less-bom/import/interpolation-vars.less +6 -0
- package/test/less-bom/import/invalid-css.less +1 -0
- package/test/less-bom/import/urls.less +1 -0
- package/test/less-bom/import-inline.less +3 -0
- package/test/less-bom/import-interpolation.less +8 -0
- package/test/less-bom/import-once.less +6 -0
- package/test/less-bom/import-reference.less +23 -0
- package/test/less-bom/import.less +30 -0
- package/test/less-bom/include-path/include-path.less +6 -0
- package/test/less-bom/javascript.less +38 -0
- package/test/less-bom/lazy-eval.less +6 -0
- package/test/less-bom/legacy/legacy.less +7 -0
- package/test/less-bom/media.less +234 -0
- package/test/less-bom/merge.less +78 -0
- package/test/less-bom/mixins-args.less +215 -0
- package/test/less-bom/mixins-closure.less +26 -0
- package/test/less-bom/mixins-guards-default-func.less +195 -0
- package/test/less-bom/mixins-guards.less +271 -0
- package/test/less-bom/mixins-important.less +37 -0
- package/test/less-bom/mixins-interpolated.less +75 -0
- package/test/less-bom/mixins-named-args.less +36 -0
- package/test/less-bom/mixins-nested.less +22 -0
- package/test/less-bom/mixins-pattern.less +102 -0
- package/test/less-bom/mixins.less +145 -0
- package/test/less-bom/modifyVars/extended.json +5 -0
- package/test/less-bom/modifyVars/extended.less +11 -0
- package/test/less-bom/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
- package/test/less-bom/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
- package/test/less-bom/no-js-errors/no-js-errors.less +3 -0
- package/test/less-bom/no-js-errors/no-js-errors.txt +4 -0
- package/test/less-bom/no-output.less +2 -0
- package/test/less-bom/operations.less +62 -0
- package/test/less-bom/parens.less +45 -0
- package/test/less-bom/property-name-interp.less +56 -0
- package/test/less-bom/rulesets.less +30 -0
- package/test/less-bom/scope.less +104 -0
- package/test/less-bom/selectors.less +174 -0
- package/test/less-bom/sourcemaps/basic.json +3 -0
- package/test/less-bom/sourcemaps/basic.less +27 -0
- package/test/less-bom/sourcemaps/imported.css +7 -0
- package/test/less-bom/static-urls/urls.less +33 -0
- package/test/less-bom/strict-units/strict-units.less +4 -0
- package/test/less-bom/strings.less +73 -0
- package/test/less-bom/url-args/urls.less +63 -0
- package/test/less-bom/urls.less +94 -0
- package/test/less-bom/variables-in-at-rules.less +20 -0
- package/test/less-bom/variables.less +119 -0
- package/test/less-bom/whitespace.less +44 -0
- package/test/less-test.js +127 -28
- package/test/modify-vars.js +6 -4
package/test/less-test.js
CHANGED
|
@@ -3,21 +3,62 @@
|
|
|
3
3
|
module.exports = function() {
|
|
4
4
|
var path = require('path'),
|
|
5
5
|
fs = require('fs');
|
|
6
|
+
copyBom = require('./copy-bom')();
|
|
6
7
|
|
|
7
8
|
var less = require('../lib/less-node');
|
|
8
9
|
var stylize = require('../lib/less-node/lessc-helper').stylize;
|
|
9
10
|
|
|
10
11
|
var globals = Object.keys(global);
|
|
11
12
|
|
|
12
|
-
var oneTestOnly = process.argv[2]
|
|
13
|
+
var oneTestOnly = process.argv[2],
|
|
14
|
+
isFinished = false;
|
|
13
15
|
|
|
14
16
|
var isVerbose = process.env.npm_config_loglevel === 'verbose';
|
|
15
17
|
|
|
18
|
+
var normalFolder = 'test/less';
|
|
19
|
+
var bomFolder = 'test/less-bom';
|
|
20
|
+
|
|
21
|
+
less.logger.addListener({
|
|
22
|
+
info: function(msg) {
|
|
23
|
+
if (isVerbose) {
|
|
24
|
+
process.stdout.write(msg + "\n");
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
warn: function(msg) {
|
|
28
|
+
process.stdout.write(msg + "\n");
|
|
29
|
+
},
|
|
30
|
+
error: function(msg) {
|
|
31
|
+
process.stdout.write(msg + "\n");
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
var queueList = [],
|
|
36
|
+
queueRunning = false;
|
|
37
|
+
function queue(func) {
|
|
38
|
+
if (queueRunning) {
|
|
39
|
+
//console.log("adding to queue");
|
|
40
|
+
queueList.push(func);
|
|
41
|
+
} else {
|
|
42
|
+
//console.log("first in queue - starting");
|
|
43
|
+
queueRunning = true;
|
|
44
|
+
func();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function release() {
|
|
48
|
+
if (queueList.length) {
|
|
49
|
+
//console.log("running next in queue");
|
|
50
|
+
var func = queueList.shift();
|
|
51
|
+
setTimeout(func, 0);
|
|
52
|
+
} else {
|
|
53
|
+
//console.log("stopping queue");
|
|
54
|
+
queueRunning = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
16
58
|
var totalTests = 0,
|
|
17
59
|
failedTests = 0,
|
|
18
60
|
passedTests = 0;
|
|
19
61
|
|
|
20
|
-
|
|
21
62
|
less.functions.functionRegistry.addMultiple({
|
|
22
63
|
add: function (a, b) {
|
|
23
64
|
return new(less.tree.Dimension)(a.value + b.value);
|
|
@@ -30,9 +71,9 @@ module.exports = function() {
|
|
|
30
71
|
}
|
|
31
72
|
});
|
|
32
73
|
|
|
33
|
-
function testSourcemap(name, err, compiledLess, doReplacements, sourcemap) {
|
|
74
|
+
function testSourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
|
|
34
75
|
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
|
|
35
|
-
process.stdout.write("- " + name + ": ");
|
|
76
|
+
process.stdout.write("- " + path.join(baseFolder, name) + ": ");
|
|
36
77
|
if (sourcemap === expectedSourcemap) {
|
|
37
78
|
ok('OK');
|
|
38
79
|
} else if (err) {
|
|
@@ -47,10 +88,10 @@ module.exports = function() {
|
|
|
47
88
|
});
|
|
48
89
|
}
|
|
49
90
|
|
|
50
|
-
function testErrors(name, err, compiledLess, doReplacements) {
|
|
51
|
-
fs.readFile(path.join(
|
|
52
|
-
process.stdout.write("- " + name + ": ");
|
|
53
|
-
expectedErr = doReplacements(expectedErr,
|
|
91
|
+
function testErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
|
|
92
|
+
fs.readFile(path.join(baseFolder, name) + '.txt', 'utf8', function (e, expectedErr) {
|
|
93
|
+
process.stdout.write("- " + path.join(baseFolder, name) + ": ");
|
|
94
|
+
expectedErr = doReplacements(expectedErr, baseFolder);
|
|
54
95
|
if (!err) {
|
|
55
96
|
if (compiledLess) {
|
|
56
97
|
fail("No Error", 'red');
|
|
@@ -71,8 +112,8 @@ module.exports = function() {
|
|
|
71
112
|
function globalReplacements(input, directory) {
|
|
72
113
|
var p = path.join(process.cwd(), directory),
|
|
73
114
|
pathimport = path.join(process.cwd(), directory + "import/"),
|
|
74
|
-
pathesc = p.replace(/[.:/\\]/g, function(a) { return '\\' + (a=='\\' ? '\/' : a); }),
|
|
75
|
-
pathimportesc = pathimport.replace(/[.:/\\]/g, function(a) { return '\\' + (a=='\\' ? '\/' : a); });
|
|
115
|
+
pathesc = p.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); }),
|
|
116
|
+
pathimportesc = pathimport.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); });
|
|
76
117
|
|
|
77
118
|
return input.replace(/\{path\}/g, p)
|
|
78
119
|
.replace(/\{pathesc\}/g, pathesc)
|
|
@@ -88,9 +129,13 @@ module.exports = function() {
|
|
|
88
129
|
}
|
|
89
130
|
|
|
90
131
|
function testSyncronous(options, filenameNoExtension) {
|
|
91
|
-
|
|
132
|
+
if (oneTestOnly && ("Test Sync " + filenameNoExtension) !== oneTestOnly) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
92
135
|
totalTests++;
|
|
93
|
-
|
|
136
|
+
queue(function() {
|
|
137
|
+
var isSync = true;
|
|
138
|
+
toCSS(options, path.join(normalFolder, filenameNoExtension + ".less"), function (err, result) {
|
|
94
139
|
process.stdout.write("- Test Sync " + filenameNoExtension + ": ");
|
|
95
140
|
|
|
96
141
|
if (isSync) {
|
|
@@ -98,11 +143,27 @@ module.exports = function() {
|
|
|
98
143
|
} else {
|
|
99
144
|
fail("Not Sync");
|
|
100
145
|
}
|
|
146
|
+
release();
|
|
101
147
|
});
|
|
102
148
|
isSync = false;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function prepBomTest() {
|
|
153
|
+
copyBom.copyFolderWithBom(normalFolder, bomFolder);
|
|
103
154
|
}
|
|
104
155
|
|
|
105
156
|
function runTestSet(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
|
|
157
|
+
var options2 = options ? JSON.parse(JSON.stringify(options)) : {};
|
|
158
|
+
runTestSetInternal(normalFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
|
|
159
|
+
runTestSetInternal(bomFolder, options2, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function runTestSetNormalOnly(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
|
|
163
|
+
runTestSetInternal(normalFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function runTestSetInternal(baseFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
|
|
106
167
|
foldername = foldername || "";
|
|
107
168
|
|
|
108
169
|
if(!doReplacements) {
|
|
@@ -113,7 +174,7 @@ module.exports = function() {
|
|
|
113
174
|
return foldername + path.basename(file, '.less');
|
|
114
175
|
}
|
|
115
176
|
|
|
116
|
-
fs.readdirSync(path.join(
|
|
177
|
+
fs.readdirSync(path.join(baseFolder, foldername)).forEach(function (file) {
|
|
117
178
|
if (! /\.less/.test(file)) { return; }
|
|
118
179
|
|
|
119
180
|
var name = getBasename(file);
|
|
@@ -126,20 +187,32 @@ module.exports = function() {
|
|
|
126
187
|
|
|
127
188
|
if (options.sourceMap) {
|
|
128
189
|
options.sourceMapOutputFilename = name + ".css";
|
|
129
|
-
options.sourceMapBasepath = path.join(process.cwd(),
|
|
190
|
+
options.sourceMapBasepath = path.join(process.cwd(), baseFolder);
|
|
130
191
|
options.sourceMapRootpath = "testweb/";
|
|
131
192
|
// TODO separate options?
|
|
132
193
|
options.sourceMap = options;
|
|
133
194
|
}
|
|
134
195
|
|
|
135
196
|
options.getVars = function(file) {
|
|
136
|
-
return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars'), 'utf8'));
|
|
197
|
+
return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars', baseFolder), 'utf8'));
|
|
137
198
|
};
|
|
138
199
|
|
|
139
|
-
|
|
200
|
+
var doubleCallCheck = false;
|
|
201
|
+
queue(function() {
|
|
202
|
+
toCSS(options, path.join(baseFolder, foldername + file), function (err, result) {
|
|
203
|
+
if (doubleCallCheck) {
|
|
204
|
+
totalTests++;
|
|
205
|
+
fail("less is calling back twice");
|
|
206
|
+
process.stdout.write(doubleCallCheck + "\n");
|
|
207
|
+
process.stdout.write((new Error()).stack + "\n");
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
doubleCallCheck = (new Error()).stack;
|
|
140
211
|
|
|
141
212
|
if (verifyFunction) {
|
|
142
|
-
|
|
213
|
+
var verificationResult = verifyFunction(name, err, result && result.css, doReplacements, result && result.map, baseFolder);
|
|
214
|
+
release();
|
|
215
|
+
return verificationResult;
|
|
143
216
|
}
|
|
144
217
|
if (err) {
|
|
145
218
|
fail("ERROR: " + (err && err.message));
|
|
@@ -147,30 +220,33 @@ module.exports = function() {
|
|
|
147
220
|
process.stdout.write("\n");
|
|
148
221
|
process.stdout.write(err.stack + "\n");
|
|
149
222
|
}
|
|
223
|
+
release();
|
|
150
224
|
return;
|
|
151
225
|
}
|
|
152
226
|
var css_name = name;
|
|
153
227
|
if(nameModifier) { css_name = nameModifier(name); }
|
|
154
228
|
fs.readFile(path.join('test/css', css_name) + '.css', 'utf8', function (e, css) {
|
|
155
|
-
process.stdout.write("- " + css_name + ": ");
|
|
229
|
+
process.stdout.write("- " + path.join(baseFolder, css_name) + ": ");
|
|
156
230
|
|
|
157
|
-
|
|
231
|
+
css = css && doReplacements(css, path.join(baseFolder, foldername));
|
|
158
232
|
if (result.css === css) { ok('OK'); }
|
|
159
233
|
else {
|
|
160
234
|
difference("FAIL", css, result.css);
|
|
161
235
|
}
|
|
236
|
+
release();
|
|
162
237
|
});
|
|
163
238
|
});
|
|
239
|
+
});
|
|
164
240
|
});
|
|
165
241
|
}
|
|
166
242
|
|
|
167
243
|
function diff(left, right) {
|
|
168
244
|
require('diff').diffLines(left, right).forEach(function(item) {
|
|
169
245
|
if(item.added || item.removed) {
|
|
170
|
-
var text = item.value.replace("\n", String.fromCharCode(182) + "\n");
|
|
246
|
+
var text = item.value.replace("\n", String.fromCharCode(182) + "\n").replace('\ufeff', '[[BOM]]');
|
|
171
247
|
process.stdout.write(stylize(text, item.added ? 'green' : 'red'));
|
|
172
248
|
} else {
|
|
173
|
-
process.stdout.write(item.value);
|
|
249
|
+
process.stdout.write(item.value.replace('\ufeff', '[[BOM]]'));
|
|
174
250
|
}
|
|
175
251
|
});
|
|
176
252
|
process.stdout.write("\n");
|
|
@@ -196,9 +272,15 @@ module.exports = function() {
|
|
|
196
272
|
endTest();
|
|
197
273
|
}
|
|
198
274
|
|
|
275
|
+
function finished() {
|
|
276
|
+
isFinished = true;
|
|
277
|
+
endTest();
|
|
278
|
+
}
|
|
279
|
+
|
|
199
280
|
function endTest() {
|
|
200
|
-
|
|
201
|
-
|
|
281
|
+
if (isFinished && ((failedTests + passedTests) >= totalTests)) {
|
|
282
|
+
var leaked = checkGlobalLeaks();
|
|
283
|
+
|
|
202
284
|
process.stdout.write("\n");
|
|
203
285
|
if (failedTests > 0) {
|
|
204
286
|
process.stdout.write(failedTests + stylize(" Failed", "red") + ", " + passedTests + " passed\n");
|
|
@@ -211,17 +293,28 @@ module.exports = function() {
|
|
|
211
293
|
}
|
|
212
294
|
|
|
213
295
|
if (leaked.length || failedTests) {
|
|
214
|
-
|
|
215
|
-
process.on('exit', function() { process.reallyExit(1) });
|
|
296
|
+
process.on('exit', function() { process.reallyExit(1); });
|
|
216
297
|
}
|
|
217
298
|
}
|
|
218
299
|
}
|
|
219
300
|
|
|
301
|
+
function contains(fullArray, obj) {
|
|
302
|
+
for (var i = 0; i < fullArray.length; i++) {
|
|
303
|
+
if (fullArray[i] === obj) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
|
|
220
310
|
function toCSS(options, path, callback) {
|
|
221
311
|
options = options || {};
|
|
222
|
-
var str = fs.readFileSync(path, 'utf8');
|
|
312
|
+
var str = fs.readFileSync(path, 'utf8'), addPath = require('path').dirname(path);
|
|
223
313
|
|
|
224
|
-
options.paths = [
|
|
314
|
+
options.paths = options.paths || [];
|
|
315
|
+
if (!contains(options.paths, addPath)) {
|
|
316
|
+
options.paths.push(addPath);
|
|
317
|
+
}
|
|
225
318
|
options.filename = require('path').resolve(process.cwd(), path);
|
|
226
319
|
options.optimization = options.optimization || 0;
|
|
227
320
|
|
|
@@ -235,6 +328,9 @@ module.exports = function() {
|
|
|
235
328
|
}
|
|
236
329
|
|
|
237
330
|
function testNoOptions() {
|
|
331
|
+
if (oneTestOnly && "Integration" !== oneTestOnly) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
238
334
|
totalTests++;
|
|
239
335
|
try {
|
|
240
336
|
process.stdout.write("- Integration - creating parser without options: ");
|
|
@@ -248,9 +344,12 @@ module.exports = function() {
|
|
|
248
344
|
|
|
249
345
|
return {
|
|
250
346
|
runTestSet: runTestSet,
|
|
347
|
+
runTestSetNormalOnly: runTestSetNormalOnly,
|
|
251
348
|
testSyncronous: testSyncronous,
|
|
252
349
|
testErrors: testErrors,
|
|
253
350
|
testSourcemap: testSourcemap,
|
|
254
|
-
testNoOptions: testNoOptions
|
|
351
|
+
testNoOptions: testNoOptions,
|
|
352
|
+
prepBomTest: prepBomTest,
|
|
353
|
+
finished: finished
|
|
255
354
|
};
|
|
256
355
|
};
|
package/test/modify-vars.js
CHANGED
|
@@ -8,10 +8,12 @@ var options = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
less.render(input, options, function (err, result) {
|
|
11
|
-
if (err)
|
|
11
|
+
if (err) {
|
|
12
|
+
console.log(err);
|
|
13
|
+
}
|
|
12
14
|
if (result.css === expectedCss) {
|
|
13
|
-
console.log("PASS")
|
|
15
|
+
console.log("PASS");
|
|
14
16
|
} else {
|
|
15
|
-
console.log("FAIL")
|
|
17
|
+
console.log("FAIL");
|
|
16
18
|
}
|
|
17
|
-
})
|
|
19
|
+
});
|