Making the specs run again in an easier way

This commit is contained in:
Tyler Akins 2017-08-02 10:34:09 -05:00
parent 2447f40abd
commit 00af9e978c
No known key found for this signature in database
GPG Key ID: 8F3B8C432F4393BD
3 changed files with 14 additions and 7 deletions

View File

@ -144,11 +144,7 @@ Developing
Check out the code and hack away. Please add tests to show off bugs before fixing them. New functionality should also be covered by a test.
First you need to get the official tests. This command will pull them down and put those tests into a "spec" folder.
git clone https://github.com/mustache/spec.git spec
After that you need to install node.js and run `npm install async` (no, I didn't make a package.json to just list one dependency). Finally, `./run-spec.js spec/specs/*.json` will run against the official tests - there's over 100 of them.
First, make sure you install Node.js. After that, run `npm run install-tests` to get the dependencies and the repository of YAML tests. Run `npm run test` to run the JavaScript tests. There's over 100 of them, which is great. Not all of them will pass, but that's discussed later.
When submitting patches, make sure to run them past [ShellCheck] and ensure no problems are found. Also please use Bash 3 syntax if you are manipulating arrays.

10
package.json Normal file
View File

@ -0,0 +1,10 @@
{
"dependencies": {
"async": "*"
},
"scripts": {
"clean": "rm -rf package-lock.json node_modules/ spec/",
"install-tests": "npm install; git clone https://github.com/mustache/spec.git spec",
"test": "node run-spec.js spec/specs/*.json"
}
}

5
run-spec.js Executable file → Normal file
View File

@ -1,6 +1,6 @@
#!/usr/bin/env node
var async, exec, fs, summary, specFiles;
var async, exec, fs, summary;
function makeShellString(value) {
if (typeof value === 'string') {
@ -71,7 +71,8 @@ function runTest(test, done) {
Object.keys(test.data).forEach(function (name) {
script.push(addToEnvironment(name, test.data[name]));
});
script.push('. mo spec-runner/spec-template');
script.push('. mo');
script.push('mo spec-runner/spec-template');
test.script = script.join('\n');
async.series([
function (taskDone) {