splitting the examples into two sections to speed things up

This commit is contained in:
Yotam Mann 2020-07-19 12:41:20 -07:00
parent 5771eb4383
commit 9352dcafc6
2 changed files with 17 additions and 1 deletions

View file

@ -42,6 +42,12 @@ jobs:
- npm run docs
- npm run test:examples
env : TEST_EXAMPLES=1
- stage: test
script:
- npm run build
- npm run docs
- npm run test:examples
env : TEST_EXAMPLES=2
- stage: test
script:
- npm run build

View file

@ -6,6 +6,8 @@ const { file } = require("tmp-promise");
const { writeFile } = require("fs-extra");
const toneJson = require("../../docs/tone.json");
const testSplit = parseInt(process.env.TEST_EXAMPLES || "0");
/**
* Get all of the examples
*/
@ -70,7 +72,15 @@ async function testExampleString(str) {
}
async function main() {
const examples = findExamples(toneJson);
let examples = findExamples(toneJson);
if (testSplit > 0) {
// split it in half and choose either the first or second half
const halfLength = Math.ceil(examples.length / 2);
const splitStart = (testSplit - 1) * halfLength;
const splitEnd = (testSplit) * halfLength;
examples = examples.slice(splitStart, splitEnd);
console.log(`texting examples ${splitStart} - ${splitEnd}`);
}
let passed = 0;
for (let i = 0; i < examples.length; i++) {
const example = examples[i];