Skip to content

Commit 51fb02b

Browse files
authored
Fixes #3504 / organizes tests (#3523)
* Fixes #3504 / organizes tests
1 parent efb76ec commit 51fb02b

File tree

214 files changed

+81
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+81
-66
lines changed

packages/less/Gruntfile.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -235,31 +235,31 @@ module.exports = function(grunt) {
235235
// @TODO: make this more thorough
236236
// CURRENT OPTIONS
237237
// --math
238-
"node bin/lessc --math=always test/less/lazy-eval.less tmp/lazy-eval.css",
239-
"node bin/lessc --math=parens-division test/less/lazy-eval.less tmp/lazy-eval.css",
240-
"node bin/lessc --math=parens test/less/lazy-eval.less tmp/lazy-eval.css",
241-
"node bin/lessc --math=strict test/less/lazy-eval.less tmp/lazy-eval.css",
242-
"node bin/lessc --math=strict-legacy test/less/lazy-eval.less tmp/lazy-eval.css",
238+
"node bin/lessc --math=always test/less/_main/lazy-eval.less tmp/lazy-eval.css",
239+
"node bin/lessc --math=parens-division test/less/_main/lazy-eval.less tmp/lazy-eval.css",
240+
"node bin/lessc --math=parens test/less/_main/lazy-eval.less tmp/lazy-eval.css",
241+
"node bin/lessc --math=strict test/less/_main/lazy-eval.less tmp/lazy-eval.css",
242+
"node bin/lessc --math=strict-legacy test/less/_main/lazy-eval.less tmp/lazy-eval.css",
243243

244244
// DEPRECATED OPTIONS
245245
// --strict-math
246-
"node bin/lessc --strict-math=on test/less/lazy-eval.less tmp/lazy-eval.css"
246+
"node bin/lessc --strict-math=on test/less/_main/lazy-eval.less tmp/lazy-eval.css"
247247
].join(" && ")
248248
},
249249
plugin: {
250250
command: [
251-
'node bin/lessc --clean-css="--s1 --advanced" test/less/lazy-eval.less tmp/lazy-eval.css',
251+
'node bin/lessc --clean-css="--s1 --advanced" test/less/_main/lazy-eval.less tmp/lazy-eval.css',
252252
"cd lib",
253-
'node ../bin/lessc --clean-css="--s1 --advanced" ../test/less/lazy-eval.less ../tmp/lazy-eval.css',
253+
'node ../bin/lessc --clean-css="--s1 --advanced" ../test/less/_main/lazy-eval.less ../tmp/lazy-eval.css',
254254
"cd ..",
255255
// Test multiple plugins
256-
'node bin/lessc --plugin=clean-css="--s1 --advanced" --plugin=autoprefix="ie 11,Edge >= 13,Chrome >= 47,Firefox >= 45,iOS >= 9.2,Safari >= 9" test/less/lazy-eval.less tmp/lazy-eval.css'
256+
'node bin/lessc --plugin=clean-css="--s1 --advanced" --plugin=autoprefix="ie 11,Edge >= 13,Chrome >= 47,Firefox >= 45,iOS >= 9.2,Safari >= 9" test/less/_main/lazy-eval.less tmp/lazy-eval.css'
257257
].join(" && ")
258258
},
259259
"sourcemap-test": {
260260
// quoted value doesn't seem to get picked up by time-grunt, or isn't output, at least; maybe just "sourcemap" is fine?
261261
command: [
262-
"node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/import.less test/sourcemaps/import.css",
262+
"node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/_main/import.less test/sourcemaps/import.css",
263263
"node bin/lessc --source-map test/less/sourcemaps/basic.less test/sourcemaps/basic.css"
264264
].join(" && ")
265265
}

packages/less/lib/less/tree/import.js

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/less/lib/less/tree/import.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/less/src/less/tree/import.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,13 @@ class Import extends Node {
171171
throw this.error;
172172
}
173173
return newImport;
174-
} else {
174+
} else if (this.root) {
175175
ruleset = new Ruleset(null, utils.copyArray(this.root.rules));
176176
ruleset.evalImports(context);
177177

178178
return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules;
179+
} else {
180+
return [];
179181
}
180182
}
181183
}

packages/less/test/README.md

+3

packages/less/test/browser/generator/runner.config.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module.exports = {
33
main: {
44
// src is used to build list of less files to compile
55
src: [
6-
"test/less/*.less",
7-
"!test/less/plugin-preeval.less", // uses ES6 syntax
6+
"test/less/_main/*.less",
7+
"!test/less/_main/plugin-preeval.less", // uses ES6 syntax
88
// Don't test NPM import, obviously
9-
"!test/less/plugin-module.less",
10-
"!test/less/import-module.less",
11-
"!test/less/javascript.less",
12-
"!test/less/urls.less",
13-
"!test/less/empty.less"
9+
"!test/less/_main/plugin-module.less",
10+
"!test/less/_main/import-module.less",
11+
"!test/less/_main/javascript.less",
12+
"!test/less/_main/urls.less",
13+
"!test/less/_main/empty.less"
1414
],
1515
options: {
1616
helpers: "test/browser/runner-main-options.js",

packages/less/test/browser/runner-browser-options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media',
1313

1414
for (var i = 0; i < testFiles.length; i++) {
1515
var file = testFiles[i],
16-
lessPath = '/test/less/' + file + '.less',
17-
cssPath = '/test/css/' + file + '.css',
16+
lessPath = '/test/less/_main/' + file + '.less',
17+
cssPath = '/test/css/_main/' + file + '.css',
1818
lessStyle = document.createElement('style'),
1919
cssLink = document.createElement('link'),
2020
lessText = '@import "' + lessPath + '";';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.a {
2+
b: c;
3+
}

packages/less/test/index.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ console.log('\n' + stylize('Less', 'underline') + '\n');
77

88
lessTester.prepBomTest();
99
var testMap = [
10-
[{}, 'namespacing/'],
1110
[{
1211
// TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed
1312
relativeUrls: true,
1413
silent: true,
1514
javascriptEnabled: true
16-
}],
15+
}, '_main/'],
16+
[{}, 'namespacing/'],
1717
[{
1818
math: 'strict-legacy'
1919
}, 'math/strict-legacy/'],
@@ -49,7 +49,7 @@ var testMap = [
4949
return path.join('test/sourcemaps', filename) + '.json';
5050
}],
5151

52-
[{math: 'strict', strictUnits: true, globalVars: true }, 'import/json/',
52+
[{math: 'strict', strictUnits: true, globalVars: true }, '_main/import/json/',
5353
lessTester.testImports, null, true,
5454
function(filename, type, baseFolder) {
5555
return path.join(baseFolder, filename) + '.json';
@@ -67,20 +67,21 @@ var testMap = [
6767
[{rewriteUrls: 'local'}, 'rewrite-urls-local/'],
6868
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'],
6969
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'local'}, 'rootpath-rewrite-urls-local/'],
70-
[{paths: ['test/data/', 'test/less/import/']}, 'include-path/'],
71-
[{paths: 'test/data/'}, 'include-path-string/'],
70+
[{paths: ['test/less/data/', 'test/less/_main/import/']}, 'include-path/'],
71+
[{paths: 'test/less/data/'}, 'include-path-string/'],
7272
[{plugin: 'test/plugins/postprocess/'}, 'postProcessorPlugin/'],
7373
[{plugin: 'test/plugins/preprocess/'}, 'preProcessorPlugin/'],
7474
[{plugin: 'test/plugins/visitor/'}, 'visitorPlugin/'],
7575
[{plugin: 'test/plugins/filemanager/'}, 'filemanagerPlugin/'],
7676
[{}, 'no-strict-math/'],
77-
[{}, '3rd-party/']
77+
[{}, '3rd-party/'],
78+
[{ processImports: false }, 'process-imports/']
7879
];
7980
testMap.forEach(function(args) {
8081
lessTester.runTestSet.apply(lessTester, args)
8182
});
82-
lessTester.testSyncronous({syncImport: true}, 'import');
83-
lessTester.testSyncronous({syncImport: true}, 'plugin');
83+
lessTester.testSyncronous({syncImport: true}, '_main/import');
84+
lessTester.testSyncronous({syncImport: true}, '_main/plugin');
8485
lessTester.testSyncronous({syncImport: true}, 'math/strict-legacy/css');
8586
lessTester.testNoOptions();
8687
lessTester.testJSImport();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-undefined();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Function 'test-undefined' is undefined in {path}functions-1.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-undefined();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-keyword();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Keyword node returned by a function is not valid here in {path}functions-10-keyword.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-keyword();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-operation();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Operation node returned by a function is not valid here in {path}functions-11-operation.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-operation();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-quoted();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Quoted node returned by a function is not valid here in {path}functions-12-quoted.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-quoted();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-selector();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Selector node returned by a function is not valid here in {path}functions-13-selector.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-selector();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-url();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Url node returned by a function is not valid here in {path}functions-14-url.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-url();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-value();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Value node returned by a function is not valid here in {path}functions-15-value.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-value();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-assignment();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Assignment node returned by a function is not valid here in {path}functions-3-assignment.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-assignment();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-call();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Function 'foo' is undefined in {path}functions-4-call.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-call();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-color();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Color node returned by a function is not valid here in {path}functions-5-color.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-color();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-condition();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Condition node returned by a function is not valid here in {path}functions-6-condition.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-condition();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-dimension();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Dimension node returned by a function is not valid here in {path}functions-7-dimension.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-dimension();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-element();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Element node returned by a function is not valid here in {path}functions-8-element.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-element();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes";
1+
@plugin "../_main/plugin/plugin-tree-nodes";
22
test-expression();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Expression node returned by a function is not valid here in {path}functions-9-expression.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes";
33
2 test-expression();
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@plugin "../plugin/plugin-tree-nodes.js";
1+
@plugin "../_main/plugin/plugin-tree-nodes.js";
22
test-undefined();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SyntaxError: Function 'test-undefined' is undefined in {path}root-func-undefined-2.less on line 2, column 1:
2-
1 @plugin "../plugin/plugin-tree-nodes.js";
2+
1 @plugin "../_main/plugin/plugin-tree-nodes.js";
33
2 test-undefined();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');
2+
3+
.a { b: c; }

packages/less/test/less/static-urls/urls.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
url: url(@a);
3131
}
3232

33-
@import "../import/import-and-relative-paths-test";
33+
@import "../_main/import/import-and-relative-paths-test";

packages/less/test/less/url-args/urls.less

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@
3333
url: url(@a);
3434
}
3535

36-
@import "../import/imports/font";
36+
@import "../_main/import/imports/font";
3737

3838
#data-uri {
39-
uri: data-uri('image/jpeg;base64', '../../data/image.jpg');
39+
uri: data-uri('image/jpeg;base64', '../data/image.jpg');
4040
}
4141

4242
#data-uri-guess {
43-
uri: data-uri('../../data/image.jpg');
43+
uri: data-uri('../data/image.jpg');
4444
}
4545

4646
#data-uri-ascii {
47-
uri-1: data-uri('text/html', '../../data/page.html');
48-
uri-2: data-uri('../../data/page.html');
47+
uri-1: data-uri('text/html', '../data/page.html');
48+
uri-2: data-uri('../data/page.html');
4949
}
5050

5151
#svg-functions {

0 commit comments

Comments
 (0)