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.
Files changed (333) hide show
  1. package/.idea/inspectionProfiles/Project_Default.xml +1 -0
  2. package/.idea/jsLinters/jscs.xml +4 -0
  3. package/.idea/jsLinters/jshint.xml +58 -4
  4. package/.idea/workspace.xml +451 -758
  5. package/.jscsrc +38 -0
  6. package/.jshintrc +0 -2
  7. package/.travis.yml +0 -1
  8. package/CHANGELOG.md +52 -0
  9. package/Gruntfile.js +37 -3
  10. package/bin/lessc +380 -316
  11. package/bower.json +1 -1
  12. package/dist/less.js +790 -479
  13. package/dist/less.min.js +7 -7
  14. package/lib/less/contexts.js +1 -1
  15. package/lib/less/data/unit-conversions.js +3 -3
  16. package/lib/less/environment/abstract-file-manager.js +4 -4
  17. package/lib/less/environment/environment.js +9 -0
  18. package/lib/less/functions/color-blending.js +3 -3
  19. package/lib/less/functions/color.js +8 -8
  20. package/lib/less/functions/data-uri.js +39 -31
  21. package/lib/less/functions/string.js +3 -1
  22. package/lib/less/functions/svg.js +12 -15
  23. package/lib/less/functions/types.js +15 -2
  24. package/lib/less/import-manager.js +10 -5
  25. package/lib/less/index.js +2 -1
  26. package/lib/less/parse-tree.js +8 -2
  27. package/lib/less/parse.js +65 -0
  28. package/lib/less/parser/parser-input.js +3 -2
  29. package/lib/less/parser/parser.js +24 -11
  30. package/lib/less/render.js +7 -36
  31. package/lib/less/source-map-output.js +3 -3
  32. package/lib/less/transform-tree.js +1 -1
  33. package/lib/less/tree/assignment.js +0 -1
  34. package/lib/less/tree/color.js +4 -4
  35. package/lib/less/tree/condition.js +1 -1
  36. package/lib/less/tree/debug-info.js +6 -2
  37. package/lib/less/tree/dimension.js +1 -1
  38. package/lib/less/tree/directive.js +25 -6
  39. package/lib/less/tree/expression.js +1 -1
  40. package/lib/less/tree/import.js +2 -2
  41. package/lib/less/tree/index.js +1 -0
  42. package/lib/less/tree/media.js +3 -2
  43. package/lib/less/tree/mixin-call.js +3 -4
  44. package/lib/less/tree/mixin-definition.js +4 -3
  45. package/lib/less/tree/quoted.js +1 -1
  46. package/lib/less/tree/rule.js +2 -3
  47. package/lib/less/tree/ruleset.js +263 -157
  48. package/lib/less/tree/selector.js +2 -1
  49. package/lib/less/tree/url.js +5 -2
  50. package/lib/less/tree/value.js +1 -1
  51. package/lib/less/tree/variable.js +1 -1
  52. package/lib/less/visitors/extend-visitor.js +60 -25
  53. package/lib/less/visitors/import-sequencer.js +20 -14
  54. package/lib/less/visitors/import-visitor.js +13 -10
  55. package/lib/less/visitors/to-css-visitor.js +37 -5
  56. package/lib/less-browser/add-default-options.js +5 -1
  57. package/lib/less-browser/bootstrap.js +10 -8
  58. package/lib/less-browser/cache.js +1 -1
  59. package/lib/less-browser/index.js +13 -12
  60. package/lib/less-browser/utils.js +9 -6
  61. package/lib/less-node/file-manager.js +51 -28
  62. package/lib/less-node/image-size.js +34 -0
  63. package/lib/less-node/index.js +3 -0
  64. package/lib/less-node/lessc-helper.js +3 -2
  65. package/lib/less-node/url-file-manager.js +2 -2
  66. package/lib/less-rhino/index.js +2 -4
  67. package/package.json +10 -7
  68. package/test/browser/common.js +13 -11
  69. package/test/browser/css/urls.css +6 -3
  70. package/test/browser/jasmine-jsreporter.js +2 -3
  71. package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  72. package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  73. package/test/browser/less/urls.less +1 -0
  74. package/test/browser/less.js +15 -9424
  75. package/test/browser/runner-errors-options.js +0 -1
  76. package/test/browser/runner-errors-spec.js +0 -1
  77. package/test/browser/runner-legacy-options.js +0 -1
  78. package/test/browser/runner-no-js-errors-spec.js +0 -1
  79. package/test/browser/runner-production-options.js +0 -1
  80. package/test/browser/runner-relative-urls-options.js +0 -1
  81. package/test/browser/runner-rootpath-options.js +0 -1
  82. package/test/browser/runner-rootpath-relative-options.js +0 -1
  83. package/test/browser/runner-strict-units-options.js +0 -1
  84. package/test/copy-bom.js +72 -0
  85. package/test/css/comments.css +1 -0
  86. package/test/css/css-3.css +2 -0
  87. package/test/css/functions.css +2 -0
  88. package/test/css/import-interpolation.css +6 -0
  89. package/test/css/import-reference.css +25 -0
  90. package/test/css/include-path/include-path.css +6 -0
  91. package/test/css/mixins-important.css +6 -0
  92. package/test/css/selectors.css +10 -1
  93. package/test/css/url-args/urls.css +3 -3
  94. package/test/css/urls.css +12 -4
  95. package/test/css/variables.css +7 -1
  96. package/test/data/image.svg +3 -0
  97. package/test/index.js +14 -10
  98. package/test/less/comments.less +1 -0
  99. package/test/less/css-3.less +3 -0
  100. package/test/less/css-guards.less +2 -1
  101. package/test/less/errors/detached-ruleset-2.txt +1 -1
  102. package/test/less/errors/import-missing.txt +1 -1
  103. package/test/less/errors/parens-error-1.txt +1 -1
  104. package/test/less/errors/parens-error-2.txt +1 -1
  105. package/test/less/errors/parens-error-3.txt +1 -1
  106. package/test/less/errors/single-character.less +1 -0
  107. package/test/less/errors/single-character.txt +2 -0
  108. package/test/less/functions.less +5 -0
  109. package/test/less/import/import-interpolation.less +1 -0
  110. package/test/less/import/import-reference.less +38 -0
  111. package/test/less/import-reference.less +3 -1
  112. package/test/less/import.less +2 -0
  113. package/test/less/include-path/include-path.less +6 -0
  114. package/test/less/mixins-important.less +12 -0
  115. package/test/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  116. package/test/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  117. package/test/less/selectors.less +19 -4
  118. package/test/less/urls.less +10 -1
  119. package/test/less/variables.less +17 -3
  120. package/test/less-bom/charsets.less +3 -0
  121. package/test/less-bom/colors.less +98 -0
  122. package/test/less-bom/comments.less +102 -0
  123. package/test/less-bom/comments2.less +20 -0
  124. package/test/less-bom/compression/compression.less +36 -0
  125. package/test/less-bom/css-3.less +154 -0
  126. package/test/less-bom/css-escapes.less +33 -0
  127. package/test/less-bom/css-guards.less +103 -0
  128. package/test/less-bom/css.less +108 -0
  129. package/test/less-bom/debug/import/test.less +25 -0
  130. package/test/less-bom/debug/linenumbers.less +33 -0
  131. package/test/less-bom/detached-rulesets.less +103 -0
  132. package/test/less-bom/empty.less +1 -0
  133. package/test/less-bom/errors/add-mixed-units.less +3 -0
  134. package/test/less-bom/errors/add-mixed-units.txt +4 -0
  135. package/test/less-bom/errors/add-mixed-units2.less +3 -0
  136. package/test/less-bom/errors/add-mixed-units2.txt +4 -0
  137. package/test/less-bom/errors/at-rules-undefined-var.less +4 -0
  138. package/test/less-bom/errors/at-rules-undefined-var.txt +4 -0
  139. package/test/less-bom/errors/bad-variable-declaration1.less +1 -0
  140. package/test/less-bom/errors/bad-variable-declaration1.txt +2 -0
  141. package/test/less-bom/errors/color-func-invalid-color.less +3 -0
  142. package/test/less-bom/errors/color-func-invalid-color.txt +4 -0
  143. package/test/less-bom/errors/color-invalid-hex-code.less +3 -0
  144. package/test/less-bom/errors/color-invalid-hex-code.txt +4 -0
  145. package/test/less-bom/errors/color-invalid-hex-code2.less +3 -0
  146. package/test/less-bom/errors/color-invalid-hex-code2.txt +4 -0
  147. package/test/less-bom/errors/css-guard-default-func.less +4 -0
  148. package/test/less-bom/errors/css-guard-default-func.txt +4 -0
  149. package/test/less-bom/errors/detached-ruleset-1.less +6 -0
  150. package/test/less-bom/errors/detached-ruleset-1.txt +4 -0
  151. package/test/less-bom/errors/detached-ruleset-2.less +6 -0
  152. package/test/less-bom/errors/detached-ruleset-2.txt +4 -0
  153. package/test/less-bom/errors/detached-ruleset-3.less +4 -0
  154. package/test/less-bom/errors/detached-ruleset-3.txt +4 -0
  155. package/test/less-bom/errors/detached-ruleset-4.less +5 -0
  156. package/test/less-bom/errors/detached-ruleset-4.txt +4 -0
  157. package/test/less-bom/errors/detached-ruleset-5.less +4 -0
  158. package/test/less-bom/errors/detached-ruleset-5.txt +3 -0
  159. package/test/less-bom/errors/detached-ruleset-6.less +5 -0
  160. package/test/less-bom/errors/detached-ruleset-6.txt +4 -0
  161. package/test/less-bom/errors/divide-mixed-units.less +3 -0
  162. package/test/less-bom/errors/divide-mixed-units.txt +4 -0
  163. package/test/less-bom/errors/extend-no-selector.less +3 -0
  164. package/test/less-bom/errors/extend-no-selector.txt +3 -0
  165. package/test/less-bom/errors/extend-not-at-end.less +3 -0
  166. package/test/less-bom/errors/extend-not-at-end.txt +3 -0
  167. package/test/less-bom/errors/import-malformed.less +1 -0
  168. package/test/less-bom/errors/import-malformed.txt +3 -0
  169. package/test/less-bom/errors/import-missing.less +6 -0
  170. package/test/less-bom/errors/import-missing.txt +3 -0
  171. package/test/less-bom/errors/import-no-semi.less +1 -0
  172. package/test/less-bom/errors/import-no-semi.txt +2 -0
  173. package/test/less-bom/errors/import-subfolder1.less +1 -0
  174. package/test/less-bom/errors/import-subfolder1.txt +3 -0
  175. package/test/less-bom/errors/import-subfolder2.less +1 -0
  176. package/test/less-bom/errors/import-subfolder2.txt +4 -0
  177. package/test/less-bom/errors/imports/import-subfolder1.less +1 -0
  178. package/test/less-bom/errors/imports/import-subfolder2.less +1 -0
  179. package/test/less-bom/errors/imports/import-test.less +4 -0
  180. package/test/less-bom/errors/imports/subfolder/mixin-not-defined.less +1 -0
  181. package/test/less-bom/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
  182. package/test/less-bom/errors/javascript-error.less +3 -0
  183. package/test/less-bom/errors/javascript-error.txt +4 -0
  184. package/test/less-bom/errors/javascript-undefined-var.less +3 -0
  185. package/test/less-bom/errors/javascript-undefined-var.txt +4 -0
  186. package/test/less-bom/errors/mixed-mixin-definition-args-1.less +6 -0
  187. package/test/less-bom/errors/mixed-mixin-definition-args-1.txt +4 -0
  188. package/test/less-bom/errors/mixed-mixin-definition-args-2.less +6 -0
  189. package/test/less-bom/errors/mixed-mixin-definition-args-2.txt +4 -0
  190. package/test/less-bom/errors/mixin-not-defined.less +11 -0
  191. package/test/less-bom/errors/mixin-not-defined.txt +3 -0
  192. package/test/less-bom/errors/mixin-not-matched.less +6 -0
  193. package/test/less-bom/errors/mixin-not-matched.txt +3 -0
  194. package/test/less-bom/errors/mixin-not-matched2.less +6 -0
  195. package/test/less-bom/errors/mixin-not-matched2.txt +3 -0
  196. package/test/less-bom/errors/mixin-not-visible-in-scope-1.less +9 -0
  197. package/test/less-bom/errors/mixin-not-visible-in-scope-1.txt +4 -0
  198. package/test/less-bom/errors/mixins-guards-default-func-1.less +9 -0
  199. package/test/less-bom/errors/mixins-guards-default-func-1.txt +4 -0
  200. package/test/less-bom/errors/mixins-guards-default-func-2.less +9 -0
  201. package/test/less-bom/errors/mixins-guards-default-func-2.txt +4 -0
  202. package/test/less-bom/errors/mixins-guards-default-func-3.less +9 -0
  203. package/test/less-bom/errors/mixins-guards-default-func-3.txt +4 -0
  204. package/test/less-bom/errors/multiple-guards-on-css-selectors.less +4 -0
  205. package/test/less-bom/errors/multiple-guards-on-css-selectors.txt +4 -0
  206. package/test/less-bom/errors/multiple-guards-on-css-selectors2.less +4 -0
  207. package/test/less-bom/errors/multiple-guards-on-css-selectors2.txt +4 -0
  208. package/test/less-bom/errors/multiply-mixed-units.less +7 -0
  209. package/test/less-bom/errors/multiply-mixed-units.txt +4 -0
  210. package/test/less-bom/errors/parens-error-1.less +3 -0
  211. package/test/less-bom/errors/parens-error-1.txt +4 -0
  212. package/test/less-bom/errors/parens-error-2.less +3 -0
  213. package/test/less-bom/errors/parens-error-2.txt +4 -0
  214. package/test/less-bom/errors/parens-error-3.less +3 -0
  215. package/test/less-bom/errors/parens-error-3.txt +4 -0
  216. package/test/less-bom/errors/parse-error-curly-bracket.less +4 -0
  217. package/test/less-bom/errors/parse-error-curly-bracket.txt +4 -0
  218. package/test/less-bom/errors/parse-error-extra-parens.less +5 -0
  219. package/test/less-bom/errors/parse-error-extra-parens.txt +3 -0
  220. package/test/less-bom/errors/parse-error-missing-bracket.less +2 -0
  221. package/test/less-bom/errors/parse-error-missing-bracket.txt +3 -0
  222. package/test/less-bom/errors/parse-error-missing-parens.less +5 -0
  223. package/test/less-bom/errors/parse-error-missing-parens.txt +3 -0
  224. package/test/less-bom/errors/parse-error-with-import.less +13 -0
  225. package/test/less-bom/errors/parse-error-with-import.txt +4 -0
  226. package/test/less-bom/errors/percentage-missing-space.less +3 -0
  227. package/test/less-bom/errors/percentage-missing-space.txt +4 -0
  228. package/test/less-bom/errors/property-asterisk-only-name.less +3 -0
  229. package/test/less-bom/errors/property-asterisk-only-name.txt +4 -0
  230. package/test/less-bom/errors/property-ie5-hack.less +3 -0
  231. package/test/less-bom/errors/property-ie5-hack.txt +3 -0
  232. package/test/less-bom/errors/property-in-root.less +4 -0
  233. package/test/less-bom/errors/property-in-root.txt +4 -0
  234. package/test/less-bom/errors/property-in-root2.less +1 -0
  235. package/test/less-bom/errors/property-in-root2.txt +4 -0
  236. package/test/less-bom/errors/property-in-root3.less +4 -0
  237. package/test/less-bom/errors/property-in-root3.txt +3 -0
  238. package/test/less-bom/errors/property-interp-not-defined.less +1 -0
  239. package/test/less-bom/errors/property-interp-not-defined.txt +2 -0
  240. package/test/less-bom/errors/recursive-variable.less +1 -0
  241. package/test/less-bom/errors/recursive-variable.txt +2 -0
  242. package/test/less-bom/errors/single-character.less +1 -0
  243. package/test/less-bom/errors/single-character.txt +2 -0
  244. package/test/less-bom/errors/svg-gradient1.less +3 -0
  245. package/test/less-bom/errors/svg-gradient1.txt +4 -0
  246. package/test/less-bom/errors/svg-gradient2.less +3 -0
  247. package/test/less-bom/errors/svg-gradient2.txt +4 -0
  248. package/test/less-bom/errors/svg-gradient3.less +3 -0
  249. package/test/less-bom/errors/svg-gradient3.txt +4 -0
  250. package/test/less-bom/errors/unit-function.less +3 -0
  251. package/test/less-bom/errors/unit-function.txt +4 -0
  252. package/test/less-bom/extend-chaining.less +91 -0
  253. package/test/less-bom/extend-clearfix.less +19 -0
  254. package/test/less-bom/extend-exact.less +46 -0
  255. package/test/less-bom/extend-media.less +24 -0
  256. package/test/less-bom/extend-nest.less +65 -0
  257. package/test/less-bom/extend-selector.less +99 -0
  258. package/test/less-bom/extend.less +81 -0
  259. package/test/less-bom/extract-and-length.less +133 -0
  260. package/test/less-bom/functions.less +201 -0
  261. package/test/less-bom/globalVars/extended.json +5 -0
  262. package/test/less-bom/globalVars/extended.less +10 -0
  263. package/test/less-bom/globalVars/simple.json +3 -0
  264. package/test/less-bom/globalVars/simple.less +3 -0
  265. package/test/less-bom/ie-filters.less +15 -0
  266. package/test/less-bom/import/deeper/deeper-2/url-import-2.less +3 -0
  267. package/test/less-bom/import/deeper/deeper-2/url-import.less +1 -0
  268. package/test/less-bom/import/deeper/import-once-test-a.less +1 -0
  269. package/test/less-bom/import/deeper/url-import.less +1 -0
  270. package/test/less-bom/import/import-and-relative-paths-test.less +17 -0
  271. package/test/less-bom/import/import-charset-test.less +1 -0
  272. package/test/less-bom/import/import-interpolation.less +2 -0
  273. package/test/less-bom/import/import-interpolation2.less +5 -0
  274. package/test/less-bom/import/import-once-test-c.less +6 -0
  275. package/test/less-bom/import/import-reference.less +89 -0
  276. package/test/less-bom/import/import-test-a.less +4 -0
  277. package/test/less-bom/import/import-test-b.less +8 -0
  278. package/test/less-bom/import/import-test-c.less +6 -0
  279. package/test/less-bom/import/import-test-d.css +1 -0
  280. package/test/less-bom/import/import-test-e.less +2 -0
  281. package/test/less-bom/import/import-test-f.less +5 -0
  282. package/test/less-bom/import/imports/font.less +8 -0
  283. package/test/less-bom/import/imports/logo.less +5 -0
  284. package/test/less-bom/import/interpolation-vars.less +6 -0
  285. package/test/less-bom/import/invalid-css.less +1 -0
  286. package/test/less-bom/import/urls.less +1 -0
  287. package/test/less-bom/import-inline.less +3 -0
  288. package/test/less-bom/import-interpolation.less +8 -0
  289. package/test/less-bom/import-once.less +6 -0
  290. package/test/less-bom/import-reference.less +23 -0
  291. package/test/less-bom/import.less +30 -0
  292. package/test/less-bom/include-path/include-path.less +6 -0
  293. package/test/less-bom/javascript.less +38 -0
  294. package/test/less-bom/lazy-eval.less +6 -0
  295. package/test/less-bom/legacy/legacy.less +7 -0
  296. package/test/less-bom/media.less +234 -0
  297. package/test/less-bom/merge.less +78 -0
  298. package/test/less-bom/mixins-args.less +215 -0
  299. package/test/less-bom/mixins-closure.less +26 -0
  300. package/test/less-bom/mixins-guards-default-func.less +195 -0
  301. package/test/less-bom/mixins-guards.less +271 -0
  302. package/test/less-bom/mixins-important.less +37 -0
  303. package/test/less-bom/mixins-interpolated.less +75 -0
  304. package/test/less-bom/mixins-named-args.less +36 -0
  305. package/test/less-bom/mixins-nested.less +22 -0
  306. package/test/less-bom/mixins-pattern.less +102 -0
  307. package/test/less-bom/mixins.less +145 -0
  308. package/test/less-bom/modifyVars/extended.json +5 -0
  309. package/test/less-bom/modifyVars/extended.less +11 -0
  310. package/test/less-bom/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  311. package/test/less-bom/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  312. package/test/less-bom/no-js-errors/no-js-errors.less +3 -0
  313. package/test/less-bom/no-js-errors/no-js-errors.txt +4 -0
  314. package/test/less-bom/no-output.less +2 -0
  315. package/test/less-bom/operations.less +62 -0
  316. package/test/less-bom/parens.less +45 -0
  317. package/test/less-bom/property-name-interp.less +56 -0
  318. package/test/less-bom/rulesets.less +30 -0
  319. package/test/less-bom/scope.less +104 -0
  320. package/test/less-bom/selectors.less +174 -0
  321. package/test/less-bom/sourcemaps/basic.json +3 -0
  322. package/test/less-bom/sourcemaps/basic.less +27 -0
  323. package/test/less-bom/sourcemaps/imported.css +7 -0
  324. package/test/less-bom/static-urls/urls.less +33 -0
  325. package/test/less-bom/strict-units/strict-units.less +4 -0
  326. package/test/less-bom/strings.less +73 -0
  327. package/test/less-bom/url-args/urls.less +63 -0
  328. package/test/less-bom/urls.less +94 -0
  329. package/test/less-bom/variables-in-at-rules.less +20 -0
  330. package/test/less-bom/variables.less +119 -0
  331. package/test/less-bom/whitespace.less +44 -0
  332. package/test/less-test.js +127 -28
  333. 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('test/less/', name) + '.txt', 'utf8', function (e, expectedErr) {
52
- process.stdout.write("- " + name + ": ");
53
- expectedErr = doReplacements(expectedErr, 'test/less/errors/');
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
- var isSync = true;
132
+ if (oneTestOnly && ("Test Sync " + filenameNoExtension) !== oneTestOnly) {
133
+ return;
134
+ }
92
135
  totalTests++;
93
- toCSS(options, path.join('test/less/', filenameNoExtension + ".less"), function (err, result) {
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('test/less/', foldername)).forEach(function (file) {
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(), "test/less");
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
- toCSS(options, path.join('test/less/', foldername + file), function (err, result) {
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
- return verifyFunction(name, err, result && result.css, doReplacements, result && result.map);
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
- css = css && doReplacements(css, 'test/less/' + foldername);
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
- var leaked = checkGlobalLeaks();
201
- if (failedTests + passedTests === totalTests) {
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
- //process.exit(1);
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 = [require('path').dirname(path)];
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
  };
@@ -8,10 +8,12 @@ var options = {
8
8
  }
9
9
 
10
10
  less.render(input, options, function (err, result) {
11
- if (err) console.log(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
+ });