-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add basic browser support (#26)
- use shims + browser field to support - add registerTestcaseResult to communicate end of test with a node runner when running in-browser - Expose getEnvParameters to let a client gather and move testground variables (used for browser support). - Supersede #25, having applies all the previous feedback.
- Loading branch information
Showing
14 changed files
with
286 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -51,6 +51,11 @@ | |
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"browser": { | ||
"os": "./src/shims/os.js", | ||
"./src/env/env": "./src/shims/env/env.js", | ||
"./src/runtime/logger": "./src/shims/runtime/logger.js" | ||
}, | ||
"aegir": { | ||
"test": { | ||
"target": [ | ||
|
@@ -66,6 +71,7 @@ | |
}, | ||
"contributors": [ | ||
"Henrique Dias <[email protected]>", | ||
"Laurent Senta <[email protected]>" | ||
"Laurent Senta <[email protected]>", | ||
"Glen De Cauwsemaecker <[email protected]>" | ||
] | ||
} |
This file contains 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,24 @@ | ||
'use strict' | ||
|
||
/** | ||
* Gets the environment that can be used by the environment | ||
* to create the runtime. | ||
* | ||
* @returns {Record<string, string|undefined>} | ||
*/ | ||
function getProcessEnv () { | ||
return process.env | ||
} | ||
|
||
/** | ||
* @param {unknown} _result | ||
*/ | ||
function registerTestcaseResult (_result) { | ||
// function is used in the browser shim | ||
// to gain the ability to wait until invokeMap is finished | ||
} | ||
|
||
module.exports = { | ||
getProcessEnv, | ||
registerTestcaseResult | ||
} |
This file contains 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,46 @@ | ||
'use strict' | ||
|
||
const runtime = require('./runtime') | ||
const sync = require('./sync') | ||
const { getProcessEnv } = require('./env') | ||
|
||
const ENV_TEST_PARAMETERS = [ | ||
runtime.ENV_TEST_BRANCH, | ||
runtime.ENV_TEST_CASE, | ||
runtime.ENV_TEST_GROUP_ID, | ||
runtime.ENV_TEST_GROUP_INSTANCE_COUNT, | ||
runtime.ENV_TEST_INSTANCE_COUNT, | ||
runtime.ENV_TEST_INSTANCE_PARAMS, | ||
runtime.ENV_TEST_INSTANCE_ROLE, | ||
runtime.ENV_TEST_OUTPUTS_PATH, | ||
runtime.ENV_TEST_PLAN, | ||
runtime.ENV_TEST_REPO, | ||
runtime.ENV_TEST_RUN, | ||
runtime.ENV_TEST_SIDECAR, | ||
runtime.ENV_TEST_START_TIME, | ||
runtime.ENV_TEST_SUBNET, | ||
runtime.ENV_TEST_TAG, | ||
|
||
sync.ENV_SYNC_SERVICE_HOST, | ||
sync.ENV_SYNC_SERVICE_PORT | ||
] | ||
|
||
/** | ||
* Gets the parameters from the environment | ||
* that can be used by the environment to create the runtime. | ||
* | ||
* @returns {Record<string, string|undefined>} | ||
*/ | ||
function getEnvParameters () { | ||
const env = getProcessEnv() | ||
return Object.keys(env) | ||
.filter(key => ENV_TEST_PARAMETERS.includes(key)) | ||
.reduce((/** @type {Record<string, string|undefined>} */params, key) => { | ||
params[key] = env[key] | ||
return params | ||
}, {}) | ||
} | ||
|
||
module.exports = { | ||
getEnvParameters | ||
} |
This file contains 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,35 @@ | ||
'use strict' | ||
|
||
const ENV_TEST_BRANCH = 'TEST_BRANCH' | ||
const ENV_TEST_CASE = 'TEST_CASE' | ||
const ENV_TEST_GROUP_ID = 'TEST_GROUP_ID' | ||
const ENV_TEST_GROUP_INSTANCE_COUNT = 'TEST_GROUP_INSTANCE_COUNT' | ||
const ENV_TEST_INSTANCE_COUNT = 'TEST_INSTANCE_COUNT' | ||
const ENV_TEST_INSTANCE_PARAMS = 'TEST_INSTANCE_PARAMS' | ||
const ENV_TEST_INSTANCE_ROLE = 'TEST_INSTANCE_ROLE' | ||
const ENV_TEST_OUTPUTS_PATH = 'TEST_OUTPUTS_PATH' | ||
const ENV_TEST_PLAN = 'TEST_PLAN' | ||
const ENV_TEST_REPO = 'TEST_REPO' | ||
const ENV_TEST_RUN = 'TEST_RUN' | ||
const ENV_TEST_SIDECAR = 'TEST_SIDECAR' | ||
const ENV_TEST_START_TIME = 'TEST_START_TIME' | ||
const ENV_TEST_SUBNET = 'TEST_SUBNET' | ||
const ENV_TEST_TAG = 'TEST_TAG' | ||
|
||
module.exports = { | ||
ENV_TEST_BRANCH, | ||
ENV_TEST_CASE, | ||
ENV_TEST_GROUP_ID, | ||
ENV_TEST_GROUP_INSTANCE_COUNT, | ||
ENV_TEST_INSTANCE_COUNT, | ||
ENV_TEST_INSTANCE_PARAMS, | ||
ENV_TEST_INSTANCE_ROLE, | ||
ENV_TEST_OUTPUTS_PATH, | ||
ENV_TEST_PLAN, | ||
ENV_TEST_REPO, | ||
ENV_TEST_RUN, | ||
ENV_TEST_SIDECAR, | ||
ENV_TEST_START_TIME, | ||
ENV_TEST_SUBNET, | ||
ENV_TEST_TAG | ||
} |
This file contains 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,9 @@ | ||
'use strict' | ||
|
||
const ENV_SYNC_SERVICE_HOST = 'SYNC_SERVICE_HOST' | ||
const ENV_SYNC_SERVICE_PORT = 'SYNC_SERVICE_PORT' | ||
|
||
module.exports = { | ||
ENV_SYNC_SERVICE_HOST, | ||
ENV_SYNC_SERVICE_PORT | ||
} |
This file contains 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 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 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 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 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,29 @@ | ||
'use strict' | ||
|
||
/** | ||
* Gets the environment that can be used by the environment | ||
* to create the runtime. | ||
* | ||
* @returns {Record<string, string|undefined>} | ||
*/ | ||
function getProcessEnv () { | ||
// @ts-ignore | ||
return (window.testground || {}).env | ||
} | ||
/** | ||
* @param {unknown} result | ||
*/ | ||
function registerTestcaseResult (result) { | ||
// @ts-ignore | ||
if (!window.testground) { | ||
// @ts-ignore | ||
window.testground = {} | ||
} | ||
// @ts-ignore | ||
window.testground.result = result | ||
} | ||
|
||
module.exports = { | ||
getProcessEnv, | ||
registerTestcaseResult | ||
} |
This file contains 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,20 @@ | ||
'use strict' | ||
|
||
/** | ||
* @returns {any[]} | ||
*/ | ||
function networkInterfaces () { | ||
return [] | ||
} | ||
|
||
/** | ||
* @returns {string} | ||
*/ | ||
function hostname () { | ||
return 'browser' | ||
} | ||
|
||
module.exports = { | ||
networkInterfaces, | ||
hostname | ||
} |
Oops, something went wrong.