Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3504 / organizes tests #3523

Merged
merged 3 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/less/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,31 +235,31 @@ module.exports = function(grunt) {
// @TODO: make this more thorough
// CURRENT OPTIONS
// --math
"node bin/lessc --math=always test/less/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=parens-division test/less/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=parens test/less/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=strict test/less/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=strict-legacy test/less/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=always test/less/_main/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=parens-division test/less/_main/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=parens test/less/_main/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=strict test/less/_main/lazy-eval.less tmp/lazy-eval.css",
"node bin/lessc --math=strict-legacy test/less/_main/lazy-eval.less tmp/lazy-eval.css",

// DEPRECATED OPTIONS
// --strict-math
"node bin/lessc --strict-math=on test/less/lazy-eval.less tmp/lazy-eval.css"
"node bin/lessc --strict-math=on test/less/_main/lazy-eval.less tmp/lazy-eval.css"
].join(" && ")
},
plugin: {
command: [
'node bin/lessc --clean-css="--s1 --advanced" test/less/lazy-eval.less tmp/lazy-eval.css',
'node bin/lessc --clean-css="--s1 --advanced" test/less/_main/lazy-eval.less tmp/lazy-eval.css',
"cd lib",
'node ../bin/lessc --clean-css="--s1 --advanced" ../test/less/lazy-eval.less ../tmp/lazy-eval.css',
'node ../bin/lessc --clean-css="--s1 --advanced" ../test/less/_main/lazy-eval.less ../tmp/lazy-eval.css',
"cd ..",
// Test multiple plugins
'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'
'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'
].join(" && ")
},
"sourcemap-test": {
// quoted value doesn't seem to get picked up by time-grunt, or isn't output, at least; maybe just "sourcemap" is fine?
command: [
"node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/import.less test/sourcemaps/import.css",
"node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/_main/import.less test/sourcemaps/import.css",
"node bin/lessc --source-map test/less/sourcemaps/basic.less test/sourcemaps/basic.css"
].join(" && ")
}
Expand Down
5 changes: 4 additions & 1 deletion packages/less/lib/less/tree/import.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/less/lib/less/tree/import.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/less/src/less/tree/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ class Import extends Node {
throw this.error;
}
return newImport;
} else {
} else if (this.root) {
ruleset = new Ruleset(null, utils.copyArray(this.root.rules));
ruleset.evalImports(context);

return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules;
} else {
return [];
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/less/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Tests are generally organized in the `less/` folder by what options are set in index.js.

The main tests are located under `less/_main/`
14 changes: 7 additions & 7 deletions packages/less/test/browser/generator/runner.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module.exports = {
main: {
// src is used to build list of less files to compile
src: [
"test/less/*.less",
"!test/less/plugin-preeval.less", // uses ES6 syntax
"test/less/_main/*.less",
"!test/less/_main/plugin-preeval.less", // uses ES6 syntax
// Don't test NPM import, obviously
"!test/less/plugin-module.less",
"!test/less/import-module.less",
"!test/less/javascript.less",
"!test/less/urls.less",
"!test/less/empty.less"
"!test/less/_main/plugin-module.less",
"!test/less/_main/import-module.less",
"!test/less/_main/javascript.less",
"!test/less/_main/urls.less",
"!test/less/_main/empty.less"
],
options: {
helpers: "test/browser/runner-main-options.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/less/test/browser/runner-browser-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media',

for (var i = 0; i < testFiles.length; i++) {
var file = testFiles[i],
lessPath = '/test/less/' + file + '.less',
cssPath = '/test/css/' + file + '.css',
lessPath = '/test/less/_main/' + file + '.less',
cssPath = '/test/css/_main/' + file + '.css',
lessStyle = document.createElement('style'),
cssLink = document.createElement('link'),
lessText = '@import "' + lessPath + '";';
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/less/test/css/process-imports/google.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.a {
b: c;
}
17 changes: 9 additions & 8 deletions packages/less/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ console.log('\n' + stylize('Less', 'underline') + '\n');

lessTester.prepBomTest();
var testMap = [
[{}, 'namespacing/'],
[{
// TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed
relativeUrls: true,
silent: true,
javascriptEnabled: true
}],
}, '_main/'],
[{}, 'namespacing/'],
[{
math: 'strict-legacy'
}, 'math/strict-legacy/'],
Expand Down Expand Up @@ -49,7 +49,7 @@ var testMap = [
return path.join('test/sourcemaps', filename) + '.json';
}],

[{math: 'strict', strictUnits: true, globalVars: true }, 'import/json/',
[{math: 'strict', strictUnits: true, globalVars: true }, '_main/import/json/',
lessTester.testImports, null, true,
function(filename, type, baseFolder) {
return path.join(baseFolder, filename) + '.json';
Expand All @@ -67,20 +67,21 @@ var testMap = [
[{rewriteUrls: 'local'}, 'rewrite-urls-local/'],
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'],
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'local'}, 'rootpath-rewrite-urls-local/'],
[{paths: ['test/data/', 'test/less/import/']}, 'include-path/'],
[{paths: 'test/data/'}, 'include-path-string/'],
[{paths: ['test/less/data/', 'test/less/_main/import/']}, 'include-path/'],
[{paths: 'test/less/data/'}, 'include-path-string/'],
[{plugin: 'test/plugins/postprocess/'}, 'postProcessorPlugin/'],
[{plugin: 'test/plugins/preprocess/'}, 'preProcessorPlugin/'],
[{plugin: 'test/plugins/visitor/'}, 'visitorPlugin/'],
[{plugin: 'test/plugins/filemanager/'}, 'filemanagerPlugin/'],
[{}, 'no-strict-math/'],
[{}, '3rd-party/']
[{}, '3rd-party/'],
[{ processImports: false }, 'process-imports/']
];
testMap.forEach(function(args) {
lessTester.runTestSet.apply(lessTester, args)
});
lessTester.testSyncronous({syncImport: true}, 'import');
lessTester.testSyncronous({syncImport: true}, 'plugin');
lessTester.testSyncronous({syncImport: true}, '_main/import');
lessTester.testSyncronous({syncImport: true}, '_main/plugin');
lessTester.testSyncronous({syncImport: true}, 'math/strict-legacy/css');
lessTester.testNoOptions();
lessTester.testJSImport();
Expand Down
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-1.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-undefined();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-1.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Function 'test-undefined' is undefined in {path}functions-1.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-undefined();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-10-keyword.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-keyword();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-10-keyword.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Keyword node returned by a function is not valid here in {path}functions-10-keyword.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-keyword();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-11-operation.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-operation();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-11-operation.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Operation node returned by a function is not valid here in {path}functions-11-operation.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-operation();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-12-quoted.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-quoted();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-12-quoted.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Quoted node returned by a function is not valid here in {path}functions-12-quoted.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-quoted();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-13-selector.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-selector();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-13-selector.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Selector node returned by a function is not valid here in {path}functions-13-selector.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-selector();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-14-url.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-url();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-14-url.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Url node returned by a function is not valid here in {path}functions-14-url.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-url();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-15-value.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-value();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-15-value.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Value node returned by a function is not valid here in {path}functions-15-value.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-value();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-3-assignment.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-assignment();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-3-assignment.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Assignment node returned by a function is not valid here in {path}functions-3-assignment.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-assignment();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-4-call.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-call();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-4-call.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Function 'foo' is undefined in {path}functions-4-call.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-call();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-5-color.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-color();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-5-color.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Color node returned by a function is not valid here in {path}functions-5-color.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-color();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-6-condition.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-condition();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-6-condition.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Condition node returned by a function is not valid here in {path}functions-6-condition.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-condition();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-7-dimension.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-dimension();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-7-dimension.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Dimension node returned by a function is not valid here in {path}functions-7-dimension.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-dimension();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-8-element.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-element();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-8-element.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Element node returned by a function is not valid here in {path}functions-8-element.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-element();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-9-expression.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes";
@plugin "../_main/plugin/plugin-tree-nodes";
test-expression();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/functions-9-expression.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Expression node returned by a function is not valid here in {path}functions-9-expression.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes";
1 @plugin "../_main/plugin/plugin-tree-nodes";
2 test-expression();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/root-func-undefined-2.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@plugin "../plugin/plugin-tree-nodes.js";
@plugin "../_main/plugin/plugin-tree-nodes.js";
test-undefined();
2 changes: 1 addition & 1 deletion packages/less/test/less/errors/root-func-undefined-2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SyntaxError: Function 'test-undefined' is undefined in {path}root-func-undefined-2.less on line 2, column 1:
1 @plugin "../plugin/plugin-tree-nodes.js";
1 @plugin "../_main/plugin/plugin-tree-nodes.js";
2 test-undefined();
3 changes: 3 additions & 0 deletions packages/less/test/less/process-imports/google.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');

.a { b: c; }
2 changes: 1 addition & 1 deletion packages/less/test/less/static-urls/urls.less
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
url: url(@a);
}

@import "../import/import-and-relative-paths-test";
@import "../_main/import/import-and-relative-paths-test";
10 changes: 5 additions & 5 deletions packages/less/test/less/url-args/urls.less
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
url: url(@a);
}

@import "../import/imports/font";
@import "../_main/import/imports/font";

#data-uri {
uri: data-uri('image/jpeg;base64', '../../data/image.jpg');
uri: data-uri('image/jpeg;base64', '../data/image.jpg');
}

#data-uri-guess {
uri: data-uri('../../data/image.jpg');
uri: data-uri('../data/image.jpg');
}

#data-uri-ascii {
uri-1: data-uri('text/html', '../../data/page.html');
uri-2: data-uri('../../data/page.html');
uri-1: data-uri('text/html', '../data/page.html');
uri-2: data-uri('../data/page.html');
}

#svg-functions {
Expand Down