Skip to content

Commit

Permalink
test: re-enable conditional WPT Report for websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 7, 2023
1 parent 7b5c851 commit 8a898bd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/wpt/start-websockets.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { WPTRunner } from './runner/runner.mjs'
import { join } from 'path'
import { fileURLToPath } from 'url'
import { fork } from 'child_process'
import { fork, execSync } from 'child_process'
import { on } from 'events'
import { argv } from 'process'

const { WPT_REPORT } = process.env

function isExperimentalAvailable () {
return execSync(`${argv[0]} --expose-internals --print 'typeof require("internal/options").getOptionValue("--experimental-websocket") === "boolean"'`, { encoding: 'utf8' }) === 'true'
}

function isGlobalAvailable () {
if (typeof WebSocket !== 'undefined') {
return true
}

return process.execArgv.includes('--experimental-websocket')
return isExperimentalAvailable()
}

if (process.env.CI) {
Expand All @@ -30,7 +35,7 @@ child.on('exit', (code) => process.exit(code))
for await (const [message] of on(child, 'message')) {
if (message.server) {
const runner = new WPTRunner('websockets', message.server, {
appendReport: !!WPT_REPORT && isGlobalAvailable(),
appendReport: isGlobalAvailable() && !!WPT_REPORT,
reportPath: WPT_REPORT
})
runner.run()
Expand Down

0 comments on commit 8a898bd

Please sign in to comment.