You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.4 KiB

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