reveal-test v3.3.0
reveal-test
Utilities for testing presentation code snippets by compiling them on Compiler Explorer.
Check out also reveal-compiler-explorer package.
Example
const { parseMarkdown, compile, CompileError } = require('reveal-test');
const codeInfos = await parseMarkdown('presentation.md');
describe("demo presentation", function () {
codeInfo.forEach((info, index) => {
it(`should have snippet ${index} compiled`, async function () {
await compile(info);
});
});
}, 10000);For reference, take a look at the demo package in this repo.
Installation
npm install --save-dev reveal-testor
yarn add -D reveal-testAPI
parseMarkdown
parseMarkdown(path: String, config: Config = {}) => Promise<Array<SnippetInfo>>Asynchronously generates a list of all code snippets from a given markdown file. For possible config fields, see here.
compile
compile(info: SnippetInfo) => StringCalls CE's Rest API to compile a code snippet.
Returns output from compiling and running the code (if enabled) on success, otherwise throws CompileError with code being the exit code and message being the compiler's error message.
Directives
In addition to the directives mentioned here, the following directives are supported:
///fails=<reason>
When given, compile will fail if compiling and running the code (if enabled) succeeds, or if the error message doesn't include the given reason.
Cannot be defined together with output.
Usage example:
///fails=expected ';' before '}' token
#include <iostream>
int main() {
std::cout << "Hello CE!"
}///output=<expected>
When given, compile will fail if the snippet's output doesn't include the given output.
Cannot be defined together with fails.
Usage example:
///external
///output=Hello CE!
#include <iostream>
int main() {
std::cout << "Hello CE!";
}1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
3 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago