duster/js
2020-05-16 16:24:36 -04:00
..
test_cases Have greater than helper very close to correct. Just need to make it compare arrays of scalars. 2020-05-16 16:24:36 -04:00
dustjs_shim.js Integrate the dustjs official helpers into the test framework. 2020-05-10 13:43:32 -04:00
README.md Initial attempt at docker compliance tests. 2020-04-12 14:37:54 -04:00
run_compliance_suite.bash Add a check to the equality helper to mark identical paths as equal. 2020-05-16 15:22:48 -04:00
run_dockerized_compliance_suite.bash Support passing args to the dockerized test runner 2020-04-12 15:47:38 -04:00

Compliance Tests

These tests run my implementation of LinkedIn's Dust and the official implementation of LinkedIn's DustJS as compares the output to ensure they match.

Running in Docker

Go to the root directory of this repository where there is a Dockerfile and run:

docker build -t duster . && docker run --rm -i -t duster

This command will run through the test cases in js/test_cases, comparing the output of the official LinkedIn DustJS implementation against the output of the duster implementation. If there are any differences, it will flag the test as a failure.

The tests have a structure of:

test_cases
└── hello_world
    ├── input1.json
    ├── input2.json
    ├── main.dust
    └── partial.dust

The folder name hello_world is the name of the test group. For each test group there must be a file named main.dust. This file will be the top-level template that gets rendered. All other *.dust files will get registered into the dust rendering context as partials, with the same name as their file excluding the file extension. For example, main.dust could invoke partial.dust with {>partial/}. Each *.json file is a separate context that will be passed into the dust renderer, making each *.json file form a test inside the test group.

Running Manually

Individually

If you want to invoke the LinkedIn DustJS manually, the dustjs_shim expects the json context to be passed in over stdin, and a list of templates to be passed in as arguments, with the first argument serving as the main template. An example invocation from this folder would therefore be:

npm install dustjs-linkedin
cat test_cases/hello_world/input1.json | node dustjs_shim.js test_cases/hello_world/main.dust

Unlike the docker variant, there is no requirement for the template to be named main.dust since it will render the first argument as the main template. Running the same test case through the duster implementation would be:

npm install dustjs-linkedin
cat test_cases/hello_world/input1.json | ../target/debug/duster-cli test_cases/hello_world/main.dust

Batch

If you instead would like to run the entire compliance test suite manually outside of docker, you can run:

npm install dustjs-linkedin
(cd .. && cargo build)
./run_compliance_suite.bash