-
Notifications
You must be signed in to change notification settings - Fork 9.5k
tests(smokehouse): convert to ES modules #13046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e1bf999
tests(smokehouse): convert to ES modules
connorjclark 58bea15
fix
connorjclark f4dd5bc
interop for days
connorjclark 84b23eb
fixcrash
connorjclark 162e46c
fix windows
connorjclark 6b40515
pr
connorjclark c7eb150
lock
connorjclark d0267b4
fix
connorjclark 1128cfc
Merge remote-tracking branch 'origin/master' into esm-smokehouse
connorjclark 39cc2f8
fixmerge
connorjclark 6e3544e
fix static server test
connorjclark 359a0db
fix windows
connorjclark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,21 @@ | |
|
||
/* eslint-disable no-console */ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const cloneDeep = require('lodash.clonedeep'); | ||
const yargs = require('yargs'); | ||
const log = require('lighthouse-logger'); | ||
const {runSmokehouse} = require('../smokehouse.js'); | ||
const {updateTestDefnFormat} = require('./back-compat-util.js'); | ||
const {LH_ROOT} = require('../../../../root.js'); | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import url from 'url'; | ||
|
||
import cloneDeep from 'lodash.clonedeep'; | ||
import yargs from 'yargs'; | ||
import * as yargsHelpers from 'yargs/helpers'; | ||
import log from 'lighthouse-logger'; | ||
|
||
import {runSmokehouse} from '../smokehouse.js'; | ||
import {updateTestDefnFormat} from './back-compat-util.js'; | ||
import {LH_ROOT} from '../../../../root.js'; | ||
|
||
const coreTestDefnsPath = | ||
path.join(LH_ROOT, 'lighthouse-cli/test/smokehouse/test-definitions/core-tests.js'); | ||
`${LH_ROOT}/lighthouse-cli/test/smokehouse/test-definitions/core-tests.js`; | ||
|
||
/** | ||
* Possible Lighthouse runners. Loaded dynamically so e.g. a CLI run isn't | ||
|
@@ -115,7 +119,8 @@ function pruneExpectedNetworkRequests(testDefns, takeNetworkRequestUrls) { | |
* CLI entry point. | ||
*/ | ||
async function begin() { | ||
const rawArgv = yargs | ||
const y = yargs(yargsHelpers.hideBin(process.argv)); | ||
const rawArgv = y | ||
.help('help') | ||
.usage('node $0 [<options>] <test-ids>') | ||
.example('node $0 -j=1 pwa seo', 'run pwa and seo tests serially') | ||
|
@@ -159,7 +164,7 @@ async function begin() { | |
describe: 'Run all available tests except the ones provided', | ||
}, | ||
}) | ||
.wrap(yargs.terminalWidth()) | ||
.wrap(y.terminalWidth()) | ||
.argv; | ||
|
||
// Augmenting yargs type with auto-camelCasing breaks in [email protected] and @types/[email protected], | ||
|
@@ -173,13 +178,13 @@ async function begin() { | |
if (argv.runner === 'bundle') { | ||
console.log('\n✨ Be sure to have recently run this: yarn build-all'); | ||
} | ||
const lighthouseRunner = require(runnerPath).runLighthouse; | ||
const {runLighthouse} = await import(runnerPath); | ||
|
||
// Find test definition file and filter by requestedTestIds. | ||
let testDefnPath = argv.testsPath || coreTestDefnsPath; | ||
testDefnPath = path.resolve(process.cwd(), testDefnPath); | ||
const requestedTestIds = argv._; | ||
const rawTestDefns = require(testDefnPath); | ||
const {default: rawTestDefns} = await import(url.pathToFileURL(testDefnPath).href); | ||
const allTestDefns = updateTestDefnFormat(rawTestDefns); | ||
const invertMatch = argv.invertMatch; | ||
const testDefns = getDefinitionsToRun(allTestDefns, requestedTestIds, {invertMatch}); | ||
|
@@ -192,7 +197,7 @@ async function begin() { | |
try { | ||
// If running the core tests, spin up the test server. | ||
if (testDefnPath === coreTestDefnsPath) { | ||
({server, serverForOffline} = require('../../fixtures/static-server.js')); | ||
({server, serverForOffline} = await import('../../fixtures/static-server.js')); | ||
server.listen(10200, 'localhost'); | ||
serverForOffline.listen(10503, 'localhost'); | ||
takeNetworkRequestUrls = server.takeRequestUrls.bind(server); | ||
|
@@ -204,7 +209,7 @@ async function begin() { | |
retries, | ||
isDebug: argv.debug, | ||
useFraggleRock: argv.fraggleRock, | ||
lighthouseRunner, | ||
lighthouseRunner: runLighthouse, | ||
takeNetworkRequestUrls, | ||
}; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ class ChildProcessError extends Error { | |
} | ||
} | ||
|
||
module.exports = ChildProcessError; | ||
export {ChildProcessError}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,4 +123,4 @@ class ConcurrentMapper { | |
} | ||
} | ||
|
||
module.exports = ConcurrentMapper; | ||
export {ConcurrentMapper}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,4 +48,4 @@ class LocalConsole { | |
} | ||
} | ||
|
||
module.exports = LocalConsole; | ||
export {LocalConsole}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type": "module", | ||
"//": "Any directory that uses `import ... from` or `export ...` must be type module. Temporary file until root package.json is type: module" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.