Comments (12)
@rwaldron I thought I'll get the ball rolling on this one, added a gulp task i.e 'beautify'. Attached diff below. Thoughts? Happy to iterate on this based on feedback.
When would be the apt time to run this task? Would it make sense to run this prior to commit? (pre-commit hook), or as a watch task?
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b512c09
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
\ No newline at end of file
diff --git a/.hgignore b/.hgignore
index 944d1fb..b0536e7 100644
--- a/.hgignore
+++ b/.hgignore
@@ -2,4 +2,4 @@
\.d8_history$
~$
\.pyc$
-console/TestCases
+console/TestCases
\ No newline at end of file
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..c176c0b
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,37 @@
+var
+ gulp = require('gulp'),
+ through = require('through2'),
+ jsBeautify = require('js-beautify').js_beautify;
+
+var
+ beautify = function(opt) {
+ function modifyFile(file, enc, cb) {
+ if (file.isNull()) {
+ this.push(file);
+ return cb();
+ }
+ if (file.isStream()) {
+ this.emit('error', new gutil.PluginError('gulp-beautify', 'Streaming not supported'));
+ return cb();
+ }
+
+ var str = file.contents.toString();
+
+ file.contents = new Buffer(jsBeautify(str, opts));
+ this.push(file);
+ cb();
+ }
+
+ return through.obj(modifyFile);
+};
+
+/*
+ * Beautify task
+**/
+gulp.task('beautify', function() {
+ gulp.src('./test/suite/**/**.js')
+ .pipe(beautify({
+ indentSize: 2,
+ break_chained_methods: false
+ }))
+});
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e2e75f0
--- /dev/null
+++ b/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "test262",
+ "version": "0.0.1",
+ "description": "Official ECMAScript Conformance Test Suite ",
+ "directories": {
+ "docs": "docs",
+ "test": "test"
+ },
+ "devDependencies": {
+ "gulp": "~3.5.0",
+ "gulp-util": "~2.2.13",
+ "through2": "~0.4.1",
+ "js-beautify": "~1.4.2"
+ },
+ "scripts": {
+ "beautify": "gulp beautify"
+ },
+ "repository": {
+ "type": "git",
+ "url": "[email protected]:tc39/test262.git"
+ },
+ "keywords": [
+ "test",
+ "suite",
+ "ecmascript",
+ "ecma"
+ ],
+ "author": "",
+ "license": "Refer LICENSe",
+ "gitHead": "9b669da66c78bd583bc130a7ca3151258e4681a1"
+}
from test262.
@rowoot Thanks, but I'd prefer to use Grunt and have already written the patch.
from test262.
There is a problem with beautifiers: it may change the test in undesirable ways. For testing library semantics, formatting doesn't matter. But when testing syntax, it's conceivable that the precise placement of braces/spaces/line breaks/etc. are intended and required to exercise syntax of a particular feature...
from test262.
But when testing syntax, it's conceivable that the precise placement of braces/spaces/line breaks/etc. are intended and required to exercise syntax of a particular feature..
Yep, these can be skipped by convention.
from test262.
What convention do you propose? It seems like before we add any beautification we would need to very carefully understand a large number of current tests to know to exclude them.
from test262.
@bterlson I hadn't thought that far ahead, but I assume any syntax test should have the word "syntax" in the file name. We can omit these with globbing patterns
from test262.
I do not believe that assumption is correct, as there is currently no convention established for identifying syntax tests... Perhaps the description could contain "syntax" but that's not 100% guaranteed either.
I guess my ultimate point is: any patch for adding beautification should also come with updates applying the convention to the current test collateral.
In terms of convention, I think I'd rather have an @syntax attribute than use filename for some sigils and @-ributes for others.
from test262.
Another concern with beautifiers is that they may not have the latest language features added yet. I haven't checked the jsbeautifier source but they will probably need some updates before being ES6 compliant.
from test262.
@rowoot Thanks, but I'd prefer to use Grunt and have already written the patch.
Sounds good.
from test262.
I do not believe that assumption is correct
That's cool, I just made it up on the spot :P
I guess my ultimate point is: any patch for adding beautification should also come with updates applying the convention to the current test collateral.
Agreed.
In terms of convention, I think I'd rather have an @syntax attribute than use filename for some sigils and @-ributes for others.
In the actual file?
from test262.
@rwaldron yeah, in the file along with the @path and @Negative attributes. I just think it is better to have all of a test's metadata in one place.
from test262.
I don't think we should blanket-apply a beautifier, so I'm going to close this. If particular tests are ugly, file a bug. If you want to tackle a broader normalization, file an issue with the normalization you propose so we can consider whether it's appropriate.
from test262.
Related Issues (20)
- Import cycles through star exports
- Test gap for custom calendars
- XS engine failing to install on CircleCI
- Test gap for invalid string calendar IDs
- Tests for Promise.withResolvers HOT 4
- Helpers should be documented in or from CONTRIBUTING.md HOT 2
- Dependency of async-gc helper on cleanupSome functionality HOT 1
- Missing tests for `next` caching in array-destructuring? HOT 1
- built-ins/RegExp/property-escapes/generated need to be updated for Unicode 15.1
- cjtenny would like to become a maintainer HOT 3
- ESVU Chakra installation fails in CI HOT 1
- Missing coverage for parenthesized LHS
- [spam]
- Missing coverage for Top Level Await
- Missing byteConversionValues.expected.Float16
- Tests of Iterator.prototype.constructor/toStringTag are broken HOT 2
- $262.IsHTMLDDA's [[Call]] behavior is underspecified
- The Decorators proposal does not have enough tests HOT 2
- Tests using `__proto__` without appropriate `features` entry HOT 1
- Guidance on writing testing plans and where to include them in the process HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from test262.