Skip to content

Commit

Permalink
Run a very small subset of functional tests for the light build
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Walch committed Feb 18, 2021
1 parent 0312e77 commit c456521
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ jobs:
- name: run functional tests
run: |
npm run test:func
npm run test:func:light
env:
CI: true
SAUCE_TUNNEL_ID: ${{ github.run_id }}-${{ matrix.config }}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"test:unit": "karma start karma.conf.js",
"test:unit:watch": "karma start karma.conf.js --auto-watch --no-single-run",
"test:func": "BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit",
"test:func:light": "BABEL_ENV=development HLSJS_LIGHT=1 mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit",
"test:func:sauce": "SAUCE=1 UA=safari OS='OS X 10.15' BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch"
Expand Down
16 changes: 16 additions & 0 deletions tests/functional/auto/index-light.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<link rel="stylesheet" href="style.css" />
<script src="../../../dist/hls.light.min.js"></script>
<script src="testbench.js"></script>
</head>
<body id="hlsjs-functional-tests">
<video id="video"></video>
<div id="log">
<div class="inner"></div>
</div>
<script>
window.setupConsoleLogRedirection();
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion tests/functional/auto/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<head>
<link rel="stylesheet" href="style.css" />
<script src="/dist/hls.min.js"></script>
<script src="../../../dist/hls.min.js"></script>
<script src="testbench.js"></script>
</head>
<body id="hlsjs-functional-tests">
Expand Down
18 changes: 13 additions & 5 deletions tests/functional/auto/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require('chromedriver');
const HttpServer = require('http-server');
const streams = require('../../test-streams');
const useSauce = !!process.env.SAUCE || !!process.env.SAUCE_TUNNEL_ID;
const HlsjsLightBuild = !!process.env.HLSJS_LIGHT;
const chai = require('chai');
const expect = chai.expect;

Expand Down Expand Up @@ -505,8 +506,9 @@ describe(`testing hls.js playback in the browser on "${browserDescription}"`, fu
console.log('Loading test page...');
}
try {
const testPageExt = HlsjsLightBuild ? '-light' : '';
await browser.get(
`http://${hostname}:8000/tests/functional/auto/index.html`
`http://${hostname}:8000/tests/functional/auto/index${testPageExt}.html`
);
} catch (e) {
throw new Error('failed to open test page');
Expand Down Expand Up @@ -560,12 +562,18 @@ describe(`testing hls.js playback in the browser on "${browserDescription}"`, fu
}
});

Object.entries(streams)
const entries = Object.entries(streams);
if (HlsjsLightBuild) {
entries.length = 1;
}

entries
.filter(([name, stream]) => !stream.skipFunctionalTests)
.forEach(([name, stream]) => {
const url = stream.url;
const config = stream.config || {};
if (
!HlsjsLightBuild ||
!stream.blacklist_ua ||
stream.blacklist_ua.indexOf(browserConfig.name) === -1
) {
Expand All @@ -574,14 +582,14 @@ describe(`testing hls.js playback in the browser on "${browserDescription}"`, fu
testLoadedData.bind(null, url, config)
);

if (stream.startSeek) {
if (stream.startSeek && !HlsjsLightBuild) {
it(
`seek back to start and play for ${stream.description}`,
testSeekBackToStart.bind(null, url, config)
);
}

if (stream.abr) {
if (stream.abr && !HlsjsLightBuild) {
it(
`should "smooth switch" to highest level and still play(readyState === 4) after 12s for ${stream.description}`,
testSmoothSwitch.bind(null, url, config)
Expand All @@ -593,7 +601,7 @@ describe(`testing hls.js playback in the browser on "${browserDescription}"`, fu
`should seek near the end and receive video seeked event for ${stream.description}`,
testSeekOnLive.bind(null, url, config)
);
} else {
} else if (!HlsjsLightBuild) {
it(
`should buffer up to maxBufferLength or video.duration for ${stream.description}`,
testIdleBufferLength.bind(null, url, config)
Expand Down

0 comments on commit c456521

Please sign in to comment.