Initial attempt at docker compliance tests.

This commit is contained in:
Tom Alexander
2020-04-12 14:37:54 -04:00
parent 542c2c4536
commit db575d145e
8 changed files with 115 additions and 11 deletions

View File

@@ -1,11 +0,0 @@
* Compliance Tests
These tests run my implementation of LinkedIn's Dust and the official implementation of [LinkedIn's DustJS](https://www.dustjs.com) as compares the output to ensure they match.
** Setup
Install LinkedIn's DustJS in order to rust the compliance tests
** Running
The dustjs_shim expects a path to a template file as the first parameter, and it expects a json context over stdin. For example, to invoke it on the command line you could run:
```sh
cat test_cases/hello_world/input1.json | node dustjs_shim.js test_cases/hello_world/main.dust
```
Each template will be compiled with the same name as the file without the file extension (so main.dust will be compiled as "main"). THe shim renders the first template passed into it (all the others can be accessed as partials).

View File

@@ -1,36 +0,0 @@
var dust = require('dustjs-linkedin');
var fs = require('fs');
const path = require('path');
var argv = process.argv.slice(2);
if (argv.length < 1) {
console.error("Expecting only 1 argument (a path to a template)");
process.exit(1);
}
var context = JSON.parse(fs.readFileSync(0, 'utf-8'));
var main_template = path.parse(argv[0])["name"];
for (var i = 0, len = argv.length; i < len; ++i) {
var filename = path.parse(argv[i])["name"];
try {
var template_source = fs.readFileSync(argv[i], 'utf-8');
} catch (err) {
console.error(err);
process.exit(1);
}
var compiled_template = dust.compile(template_source, filename);
dust.loadSource(compiled_template);
}
dust.render(main_template, context, function(err, out) {
if(err) {
console.error(err);
process.exit(1);
} else {
console.log(out);
process.exit(0);
}
});

View File

@@ -1 +0,0 @@
{"name": "Bob"}

View File

@@ -1 +0,0 @@
{"name": "Alice"}

View File

@@ -1 +0,0 @@
Hello {name}!