From 31d0ace631629ad5914f1805272fde46a3af60f0 Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 30 Dec 2020 23:03:38 +0000 Subject: [PATCH] added support for example versioning in tests --- test/Browser.spec.js | 9 ++++++++- test/Examples.spec.js | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/test/Browser.spec.js b/test/Browser.spec.js index e927160..bcc8c27 100644 --- a/test/Browser.spec.js +++ b/test/Browser.spec.js @@ -5,9 +5,16 @@ jest.setTimeout(120 * 1000); const puppeteer = require('puppeteer-core'); const Example = require('../examples/index'); +const MatterBuild = require('../build/matter'); +const { versionSatisfies } = require('../src/core/Plugin'); const fs = require('fs'); -const examples = Object.keys(Example); +const examples = Object.keys(Example).filter(key => { + const buildVersion = MatterBuild.version; + const exampleFor = Example[key].for; + return versionSatisfies(buildVersion, exampleFor); +}); + const browserPath = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'; const demoPagePath = 'http://localhost:8000/'; const totalUpdates = 5; diff --git a/test/Examples.spec.js b/test/Examples.spec.js index 289cd2b..3bf3a64 100644 --- a/test/Examples.spec.js +++ b/test/Examples.spec.js @@ -7,13 +7,21 @@ const { comparisonReport, toMatchExtrinsics, toMatchIntrinsics } = require('./Te const Example = require('../examples/index'); const MatterBuild = require('../build/matter'); +const { versionSatisfies } = require('../src/core/Plugin'); const Worker = require('jest-worker').default; const testComparison = process.env.COMPARE === 'true'; const saveComparison = process.env.SAVE === 'true'; const excludeExamples = ['svg', 'terrain']; const excludeJitter = ['stack', 'circleStack', 'restitution', 'staticFriction', 'friction', 'newtonsCradle', 'catapult']; -const examples = Object.keys(Example).filter(key => !excludeExamples.includes(key)); + +const examples = Object.keys(Example).filter(key => { + const excluded = excludeExamples.includes(key); + const buildVersion = MatterBuild.version; + const exampleFor = Example[key].for; + const supported = versionSatisfies(buildVersion, exampleFor); + return !excluded && supported; +}); const runExamples = async useDev => { const worker = new Worker(require.resolve('./ExampleWorker'), {