Skip to content

Commit 26610ff

Browse files
committed
Fixes #3504 / organizes tests
1 parent efb76ec commit 26610ff

File tree

213 files changed

+131
-116
lines changed

Some content is hidden

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

213 files changed

+131
-116
lines changed

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

+69-68
Original file line numberDiff line numberDiff line change
@@ -7,80 +7,81 @@ console.log('\n' + stylize('Less', 'underline') + '\n');
77

88
lessTester.prepBomTest();
99
var testMap = [
10-
[{}, 'namespacing/'],
11-
[{
12-
// TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed
13-
relativeUrls: true,
14-
silent: true,
15-
javascriptEnabled: true
16-
}],
17-
[{
18-
math: 'strict-legacy'
19-
}, 'math/strict-legacy/'],
20-
[{
21-
math: 'parens'
22-
}, 'math/strict/'],
23-
[{
24-
math: 'parens-division'
25-
}, 'math/parens-division/'],
26-
// Use legacy strictMath: true here to demonstrate it still works
27-
[{strictMath: true, strictUnits: true, javascriptEnabled: true}, 'errors/',
28-
lessTester.testErrors, null],
10+
// [{
11+
// // TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed
12+
// relativeUrls: true,
13+
// silent: true,
14+
// javascriptEnabled: true
15+
// }, '_main/'],
16+
// [{}, 'namespacing/'],
17+
// [{
18+
// math: 'strict-legacy'
19+
// }, 'math/strict-legacy/'],
20+
// [{
21+
// math: 'parens'
22+
// }, 'math/strict/'],
23+
// [{
24+
// math: 'parens-division'
25+
// }, 'math/parens-division/'],
26+
// // Use legacy strictMath: true here to demonstrate it still works
27+
// [{strictMath: true, strictUnits: true, javascriptEnabled: true}, 'errors/',
28+
// lessTester.testErrors, null],
2929

30-
[{math: 'strict', strictUnits: true, javascriptEnabled: false}, 'no-js-errors/',
31-
lessTester.testErrors, null],
32-
[{math: 'strict', dumpLineNumbers: 'comments'}, 'debug/', null,
33-
function(name) { return name + '-comments'; }],
34-
[{math: 'strict', dumpLineNumbers: 'mediaquery'}, 'debug/', null,
35-
function(name) { return name + '-mediaquery'; }],
36-
[{math: 'strict', dumpLineNumbers: 'all'}, 'debug/', null,
37-
function(name) { return name + '-all'; }],
38-
// TODO: Change this to rewriteUrls: false once the relativeUrls option is removed
39-
[{math: 'strict', relativeUrls: false, rootpath: 'folder (1)/'}, 'static-urls/'],
40-
[{math: 'strict', compress: true}, 'compression/'],
41-
[{math: 0, strictUnits: true}, 'strict-units/'],
42-
[{}, 'legacy/'],
43-
[{math: 'strict', strictUnits: true, sourceMap: true, globalVars: true }, 'sourcemaps/',
44-
lessTester.testSourcemap, null, null,
45-
function(filename, type, baseFolder) {
46-
if (type === 'vars') {
47-
return path.join(baseFolder, filename) + '.json';
48-
}
49-
return path.join('test/sourcemaps', filename) + '.json';
50-
}],
30+
// [{math: 'strict', strictUnits: true, javascriptEnabled: false}, 'no-js-errors/',
31+
// lessTester.testErrors, null],
32+
// [{math: 'strict', dumpLineNumbers: 'comments'}, 'debug/', null,
33+
// function(name) { return name + '-comments'; }],
34+
// [{math: 'strict', dumpLineNumbers: 'mediaquery'}, 'debug/', null,
35+
// function(name) { return name + '-mediaquery'; }],
36+
// [{math: 'strict', dumpLineNumbers: 'all'}, 'debug/', null,
37+
// function(name) { return name + '-all'; }],
38+
// // TODO: Change this to rewriteUrls: false once the relativeUrls option is removed
39+
// [{math: 'strict', relativeUrls: false, rootpath: 'folder (1)/'}, 'static-urls/'],
40+
// [{math: 'strict', compress: true}, 'compression/'],
41+
// [{math: 0, strictUnits: true}, 'strict-units/'],
42+
// [{}, 'legacy/'],
43+
// [{math: 'strict', strictUnits: true, sourceMap: true, globalVars: true }, 'sourcemaps/',
44+
// lessTester.testSourcemap, null, null,
45+
// function(filename, type, baseFolder) {
46+
// if (type === 'vars') {
47+
// return path.join(baseFolder, filename) + '.json';
48+
// }
49+
// return path.join('test/sourcemaps', filename) + '.json';
50+
// }],
5151

52-
[{math: 'strict', strictUnits: true, globalVars: true }, 'import/json/',
53-
lessTester.testImports, null, true,
54-
function(filename, type, baseFolder) {
55-
return path.join(baseFolder, filename) + '.json';
56-
}],
57-
[{math: 'strict', strictUnits: true, sourceMap: {sourceMapFileInline: true}},
58-
'sourcemaps-empty/', lessTester.testEmptySourcemap],
59-
[{math: 'strict', strictUnits: true, sourceMap: {disableSourcemapAnnotation: true}},
60-
'sourcemaps-disable-annotation/', lessTester.testSourcemapWithoutUrlAnnotation],
61-
[{globalVars: true, banner: '/**\n * Test\n */\n'}, 'globalVars/',
62-
null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
63-
[{modifyVars: true}, 'modifyVars/',
64-
null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
65-
[{urlArgs: '424242'}, 'url-args/'],
66-
[{rewriteUrls: 'all'}, 'rewrite-urls-all/'],
67-
[{rewriteUrls: 'local'}, 'rewrite-urls-local/'],
68-
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'],
69-
[{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/'],
72-
[{plugin: 'test/plugins/postprocess/'}, 'postProcessorPlugin/'],
73-
[{plugin: 'test/plugins/preprocess/'}, 'preProcessorPlugin/'],
74-
[{plugin: 'test/plugins/visitor/'}, 'visitorPlugin/'],
75-
[{plugin: 'test/plugins/filemanager/'}, 'filemanagerPlugin/'],
76-
[{}, 'no-strict-math/'],
77-
[{}, '3rd-party/']
52+
// [{math: 'strict', strictUnits: true, globalVars: true }, '_main/import/json/',
53+
// lessTester.testImports, null, true,
54+
// function(filename, type, baseFolder) {
55+
// return path.join(baseFolder, filename) + '.json';
56+
// }],
57+
// [{math: 'strict', strictUnits: true, sourceMap: {sourceMapFileInline: true}},
58+
// 'sourcemaps-empty/', lessTester.testEmptySourcemap],
59+
// [{math: 'strict', strictUnits: true, sourceMap: {disableSourcemapAnnotation: true}},
60+
// 'sourcemaps-disable-annotation/', lessTester.testSourcemapWithoutUrlAnnotation],
61+
// [{globalVars: true, banner: '/**\n * Test\n */\n'}, 'globalVars/',
62+
// null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
63+
// [{modifyVars: true}, 'modifyVars/',
64+
// null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
65+
// [{urlArgs: '424242'}, 'url-args/'],
66+
// [{rewriteUrls: 'all'}, 'rewrite-urls-all/'],
67+
// [{rewriteUrls: 'local'}, 'rewrite-urls-local/'],
68+
// [{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'],
69+
// [{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'local'}, 'rootpath-rewrite-urls-local/'],
70+
// [{paths: ['test/less/data/', 'test/less/_main/import/']}, 'include-path/'],
71+
// [{paths: 'test/less/data/'}, 'include-path-string/'],
72+
// [{plugin: 'test/plugins/postprocess/'}, 'postProcessorPlugin/'],
73+
// [{plugin: 'test/plugins/preprocess/'}, 'preProcessorPlugin/'],
74+
// [{plugin: 'test/plugins/visitor/'}, 'visitorPlugin/'],
75+
// [{plugin: 'test/plugins/filemanager/'}, 'filemanagerPlugin/'],
76+
// [{}, 'no-strict-math/'],
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";

0 commit comments

Comments
 (0)