ui5-test-runner 5.13.0 → 6.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/Npm.js +80 -0
- package/dist/browsers/IBrowser.js +1 -0
- package/dist/browsers/factory.js +9 -0
- package/dist/browsers/puppeteer.js +158 -0
- package/dist/cli.js +17 -0
- package/dist/configuration/CommandLine.js +112 -0
- package/dist/configuration/Configuration.js +1 -0
- package/dist/configuration/ConfigurationValidator.js +79 -0
- package/dist/configuration/Option.js +1 -0
- package/dist/configuration/OptionValidationError.js +15 -0
- package/dist/configuration/indexedOptions.js +13 -0
- package/dist/configuration/options.js +191 -0
- package/dist/configuration/validators/OptionValidator.js +1 -0
- package/dist/configuration/validators/boolean.js +15 -0
- package/dist/configuration/validators/browser.js +11 -0
- package/dist/configuration/validators/fsEntry.js +70 -0
- package/dist/configuration/validators/index.js +20 -0
- package/dist/configuration/validators/integer.js +10 -0
- package/dist/configuration/validators/percent.js +17 -0
- package/dist/configuration/validators/regexp.js +20 -0
- package/dist/configuration/validators/string.js +7 -0
- package/dist/configuration/validators/timeout.js +24 -0
- package/dist/configuration/validators/url.js +8 -0
- package/dist/modes/ModeFunction.js +1 -0
- package/dist/modes/Modes.js +9 -0
- package/dist/modes/execute.js +27 -0
- package/dist/modes/help.js +3 -0
- package/dist/modes/log/ILogStorage.js +1 -0
- package/dist/modes/log/LogMetrics.js +9 -0
- package/dist/modes/log/LogReader.js +37 -0
- package/dist/modes/log/LogStorage.js +68 -0
- package/dist/modes/log/REserve.js +101 -0
- package/dist/modes/log/index.js +58 -0
- package/dist/modes/test/REserve.js +31 -0
- package/dist/modes/test/agent.js +8 -0
- package/dist/modes/test/browser.js +37 -0
- package/dist/modes/test/index.js +66 -0
- package/dist/modes/test/pageTask.js +145 -0
- package/dist/modes/test/report.js +3 -0
- package/dist/modes/test/server.js +109 -0
- package/dist/modes/version.js +11 -0
- package/dist/platform/Exit.js +139 -0
- package/dist/platform/FileSystem.js +13 -0
- package/dist/platform/Host.js +10 -0
- package/dist/platform/Http.js +38 -0
- package/dist/platform/Path.js +5 -0
- package/dist/platform/Process.js +133 -0
- package/dist/platform/Terminal.js +47 -0
- package/dist/platform/Thread.js +43 -0
- package/dist/platform/ZLib.js +7 -0
- package/dist/platform/assert.js +17 -0
- package/dist/platform/constants.js +5 -0
- package/dist/platform/environment.js +28 -0
- package/dist/platform/index.js +13 -0
- package/dist/platform/logger/ILogger.js +1 -0
- package/dist/platform/logger/allCompressed.js +54 -0
- package/dist/platform/logger/compress.js +277 -0
- package/dist/platform/logger/output/BaseLoggerOutput.js +158 -0
- package/dist/platform/logger/output/InteractiveLoggerOutput.js +102 -0
- package/dist/platform/logger/output/StaticLoggerOutput.js +32 -0
- package/dist/platform/logger/output/factory.js +10 -0
- package/dist/platform/logger/output.js +58 -0
- package/dist/platform/logger/proxy.js +6 -0
- package/dist/platform/logger/toInternalLogAttributes.js +22 -0
- package/dist/platform/logger/types.js +7 -0
- package/dist/platform/logger.js +138 -0
- package/dist/platform/mock.js +104 -0
- package/dist/platform/version.js +8 -0
- package/dist/platform/workerBootstrap.js +21 -0
- package/dist/reports/html.js +46 -0
- package/dist/types/AgentState.js +1 -0
- package/dist/types/CommonTestReportFormat.js +50 -0
- package/dist/types/IError.js +1 -0
- package/dist/types/IUserInterfaceController.js +1 -0
- package/dist/types/typeUtilities.js +1 -0
- package/dist/ui/agent.js +3 -0
- package/dist/ui/html-report.js +2 -0
- package/dist/ui/lib.js +1 -0
- package/dist/ui/log-viewer.js +2 -0
- package/dist/utils/node/Folder.js +28 -0
- package/dist/utils/node/FramedStreamReader.js +86 -0
- package/dist/utils/node/FramedStreamWriter.js +27 -0
- package/dist/utils/shared/ProgressBar.js +43 -0
- package/dist/utils/shared/TestReportBuilder.js +48 -0
- package/dist/utils/shared/memoize.js +19 -0
- package/dist/utils/shared/object.js +8 -0
- package/dist/utils/shared/parallelize.js +59 -0
- package/dist/utils/shared/string.js +23 -0
- package/dist/utils/shared/toIError.js +17 -0
- package/package.json +73 -50
- package/.releaserc +0 -5
- package/index.js +0 -175
- package/jest.config.json +0 -31
- package/src/add-test-pages.js +0 -67
- package/src/batch.js +0 -214
- package/src/browsers.js +0 -319
- package/src/capabilities/index.js +0 -204
- package/src/capabilities/tests/basic/iframe.html +0 -8
- package/src/capabilities/tests/basic/index.html +0 -12
- package/src/capabilities/tests/basic/index.js +0 -20
- package/src/capabilities/tests/basic/ui5.html +0 -24
- package/src/capabilities/tests/dynamic-include/index.js +0 -21
- package/src/capabilities/tests/dynamic-include/mix.html +0 -11
- package/src/capabilities/tests/dynamic-include/one.html +0 -11
- package/src/capabilities/tests/dynamic-include/post.js +0 -3
- package/src/capabilities/tests/dynamic-include/test.js +0 -1
- package/src/capabilities/tests/dynamic-include/two.html +0 -11
- package/src/capabilities/tests/index.js +0 -16
- package/src/capabilities/tests/local-storage/index.html +0 -16
- package/src/capabilities/tests/local-storage/index.js +0 -21
- package/src/capabilities/tests/screenshot/index.html +0 -23
- package/src/capabilities/tests/screenshot/index.js +0 -24
- package/src/capabilities/tests/scripts/coverage.html +0 -32
- package/src/capabilities/tests/scripts/iframe.html +0 -18
- package/src/capabilities/tests/scripts/index.js +0 -59
- package/src/capabilities/tests/scripts/qunit.html +0 -22
- package/src/capabilities/tests/scripts/testsuite.html +0 -10
- package/src/capabilities/tests/scripts/testsuite.js +0 -8
- package/src/capabilities/tests/timeout/index.html +0 -21
- package/src/capabilities/tests/timeout/index.js +0 -19
- package/src/capabilities/tests/traces/index.html +0 -18
- package/src/capabilities/tests/traces/index.js +0 -81
- package/src/capabilities/tests/ui5/focus.html +0 -89
- package/src/capabilities/tests/ui5/index.js +0 -39
- package/src/capabilities/tests/ui5/language.html +0 -50
- package/src/capabilities/tests/ui5/timezone.html +0 -27
- package/src/clean.js +0 -22
- package/src/cors.js +0 -21
- package/src/coverage.js +0 -384
- package/src/csv-reader.js +0 -36
- package/src/csv-writer.js +0 -55
- package/src/defaults/.nycrc.json +0 -4
- package/src/defaults/browser.js +0 -217
- package/src/defaults/happy-dom.js +0 -123
- package/src/defaults/jsdom/compatibility.js +0 -163
- package/src/defaults/jsdom/debug.js +0 -23
- package/src/defaults/jsdom/resource-loader.js +0 -44
- package/src/defaults/jsdom/sap.ui.test.matchers.visible.js +0 -39
- package/src/defaults/jsdom.js +0 -95
- package/src/defaults/json-report.js +0 -36
- package/src/defaults/junit-xml-report.js +0 -90
- package/src/defaults/playwright.js +0 -142
- package/src/defaults/puppeteer.js +0 -124
- package/src/defaults/report/common.js +0 -38
- package/src/defaults/report/decompress.js +0 -19
- package/src/defaults/report/default.html +0 -99
- package/src/defaults/report/main.js +0 -69
- package/src/defaults/report/progress.js +0 -60
- package/src/defaults/report/styles.css +0 -66
- package/src/defaults/report.js +0 -91
- package/src/defaults/scan-ui5.js +0 -26
- package/src/defaults/selenium-webdriver/chrome.js +0 -39
- package/src/defaults/selenium-webdriver/edge.js +0 -24
- package/src/defaults/selenium-webdriver/firefox.js +0 -30
- package/src/defaults/selenium-webdriver.js +0 -129
- package/src/defaults/text-report.js +0 -108
- package/src/defaults/webdriverio.js +0 -80
- package/src/end.js +0 -62
- package/src/endpoints.js +0 -219
- package/src/error.js +0 -54
- package/src/get-job-progress.js +0 -78
- package/src/handle.js +0 -43
- package/src/if.js +0 -10
- package/src/inject/jest2qunit.js +0 -289
- package/src/inject/opa-iframe-coverage.js +0 -22
- package/src/inject/post.js +0 -141
- package/src/inject/qunit-hooks.js +0 -107
- package/src/inject/qunit-redirect.js +0 -65
- package/src/inject/ui5-coverage.js +0 -33
- package/src/job-mode.js +0 -65
- package/src/job.js +0 -493
- package/src/npm.js +0 -136
- package/src/options.js +0 -95
- package/src/output.js +0 -739
- package/src/parallelize.js +0 -63
- package/src/qunit-hooks.js +0 -219
- package/src/report.js +0 -89
- package/src/reserve.js +0 -25
- package/src/start.js +0 -129
- package/src/symbols.js +0 -8
- package/src/tests.js +0 -183
- package/src/timeout.js +0 -53
- package/src/tools.js +0 -179
- package/src/ui5.js +0 -199
- package/src/unhandled.js +0 -32
package/src/parallelize.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const { allocPromise } = require('./tools')
|
|
2
|
-
|
|
3
|
-
function complete (task) {
|
|
4
|
-
++task.completed
|
|
5
|
-
if (--task.active === 0) {
|
|
6
|
-
task.resolve()
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async function run (task) {
|
|
11
|
-
const {
|
|
12
|
-
method,
|
|
13
|
-
list,
|
|
14
|
-
parallel,
|
|
15
|
-
started,
|
|
16
|
-
completed,
|
|
17
|
-
stop,
|
|
18
|
-
reject
|
|
19
|
-
} = task
|
|
20
|
-
const { length } = list
|
|
21
|
-
if (stop || completed === length || started === length) {
|
|
22
|
-
complete(task)
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
if (task.active < parallel && length - started > task.active) {
|
|
26
|
-
++task.active
|
|
27
|
-
run(task)
|
|
28
|
-
}
|
|
29
|
-
const index = task.started++
|
|
30
|
-
const parameter = list[index]
|
|
31
|
-
try {
|
|
32
|
-
await method(parameter, index, list)
|
|
33
|
-
} catch (error) {
|
|
34
|
-
task.stop = true
|
|
35
|
-
reject(error)
|
|
36
|
-
}
|
|
37
|
-
let remaining = list.length - task.started
|
|
38
|
-
while (task.active < (parallel + 1) && remaining) {
|
|
39
|
-
--remaining
|
|
40
|
-
++task.active
|
|
41
|
-
run(task)
|
|
42
|
-
}
|
|
43
|
-
complete(task)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function parallelize (method, list, parallel) {
|
|
47
|
-
const { promise, resolve, reject } = allocPromise()
|
|
48
|
-
const task = {
|
|
49
|
-
method,
|
|
50
|
-
list,
|
|
51
|
-
parallel,
|
|
52
|
-
started: 0,
|
|
53
|
-
completed: 0,
|
|
54
|
-
active: 1,
|
|
55
|
-
stop: false,
|
|
56
|
-
resolve,
|
|
57
|
-
reject
|
|
58
|
-
}
|
|
59
|
-
run(task)
|
|
60
|
-
return promise
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = { parallelize }
|
package/src/qunit-hooks.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { screenshot, stop } = require('./browsers')
|
|
4
|
-
const { collect } = require('./coverage')
|
|
5
|
-
const { UTRError } = require('./error')
|
|
6
|
-
const { getOutput } = require('./output')
|
|
7
|
-
const { basename } = require('path')
|
|
8
|
-
const { filename, stripUrlHash, allocPromise } = require('./tools')
|
|
9
|
-
const { $browsers } = require('./symbols')
|
|
10
|
-
const $doneResolve = Symbol('doneResolve')
|
|
11
|
-
const $doneTimeout = Symbol('doneTimeout')
|
|
12
|
-
|
|
13
|
-
function error (job, url, details = '') {
|
|
14
|
-
stop(job, url)
|
|
15
|
-
job.failed = true
|
|
16
|
-
throw UTRError.QUNIT_ERROR(details)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function invalidTestId (job, url, testId) {
|
|
20
|
-
error(job, url, `No QUnit unit test found with id ${testId}`)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function merge (targetModules, modules) {
|
|
24
|
-
modules.forEach(module => {
|
|
25
|
-
const { name } = module
|
|
26
|
-
const targetModule = targetModules.filter(({ name: targetName }) => name === targetName)[0]
|
|
27
|
-
if (targetModule === undefined) {
|
|
28
|
-
targetModules.push(module)
|
|
29
|
-
} else {
|
|
30
|
-
module.tests.forEach(test => {
|
|
31
|
-
const targetTest = targetModule.tests.filter(({ testId }) => test.testId === testId)[0]
|
|
32
|
-
if (!targetTest) {
|
|
33
|
-
targetModule.tests.push(test)
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function filterModules (modules, url) {
|
|
41
|
-
const moduleIdMatch = url.match(/\?.*\bmoduleId=([^&]+)/)
|
|
42
|
-
if (moduleIdMatch) {
|
|
43
|
-
const [, moduleId] = moduleIdMatch
|
|
44
|
-
return modules.filter(module => module.moduleId === moduleId)
|
|
45
|
-
}
|
|
46
|
-
const moduleNameMatch = url.match(/\?.*\bmodule=([^&]+)/)
|
|
47
|
-
if (moduleNameMatch) {
|
|
48
|
-
const [, escapedModuleName] = moduleNameMatch
|
|
49
|
-
const moduleName = decodeURIComponent(escapedModuleName)
|
|
50
|
-
return modules.filter(module => module.name === moduleName)
|
|
51
|
-
}
|
|
52
|
-
return modules
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function get (job, urlWithHash, { testId, modules, isOpa } = {}) {
|
|
56
|
-
const url = stripUrlHash(urlWithHash)
|
|
57
|
-
const page = job.qunitPages && job.qunitPages[url]
|
|
58
|
-
if (!page) {
|
|
59
|
-
error(job, url, `No QUnit page found for ${urlWithHash}`)
|
|
60
|
-
}
|
|
61
|
-
const progress = (job[$browsers] && job[$browsers][url] && job[$browsers][url].progress) || { total: 0, count: 0 }
|
|
62
|
-
merge(page.modules, filterModules(modules || [], url))
|
|
63
|
-
progress.total = page.count = page.modules.reduce((total, { tests }) => total + tests.length, 0)
|
|
64
|
-
if (!page.isOpa && isOpa) {
|
|
65
|
-
page.isOpa = true
|
|
66
|
-
}
|
|
67
|
-
let testModule
|
|
68
|
-
let test
|
|
69
|
-
if (testId !== undefined) {
|
|
70
|
-
page.modules.every(module => {
|
|
71
|
-
test = module.tests.find(test => test.testId === testId)
|
|
72
|
-
if (test === undefined) {
|
|
73
|
-
return true
|
|
74
|
-
} else {
|
|
75
|
-
testModule = module
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
if (!test) {
|
|
80
|
-
invalidTestId(job, url, testId)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return { url, page, testModule, test, progress }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async function done (job, urlWithHash, report) {
|
|
87
|
-
const { url, page } = get(job, urlWithHash)
|
|
88
|
-
if (page.count === 0) {
|
|
89
|
-
return // wait
|
|
90
|
-
}
|
|
91
|
-
const { promise, resolve } = allocPromise()
|
|
92
|
-
page[$doneResolve] = resolve
|
|
93
|
-
page[$doneTimeout] = setTimeout(async () => {
|
|
94
|
-
if (job.browserCapabilities.screenshot && job.screenshot) {
|
|
95
|
-
try {
|
|
96
|
-
await screenshot(job, url, 'done')
|
|
97
|
-
} catch (error) {
|
|
98
|
-
getOutput(job).genericError(error, url)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
page.end = new Date()
|
|
102
|
-
if (report.__coverage__) {
|
|
103
|
-
await collect(job, url, report.__coverage__)
|
|
104
|
-
delete report.__coverage__
|
|
105
|
-
} else if (job.coverage) {
|
|
106
|
-
getOutput(job).coverageNotFound()
|
|
107
|
-
}
|
|
108
|
-
page.report = report
|
|
109
|
-
stop(job, url)
|
|
110
|
-
resolve()
|
|
111
|
-
}, job.pageCloseTimeout)
|
|
112
|
-
return promise
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
module.exports = {
|
|
116
|
-
get,
|
|
117
|
-
|
|
118
|
-
async begin (job, urlWithHash, details) {
|
|
119
|
-
getOutput(job).debug('qunit/begin', 'begin', urlWithHash, details)
|
|
120
|
-
const { isOpa, modules } = details
|
|
121
|
-
const url = stripUrlHash(urlWithHash)
|
|
122
|
-
if (!job.qunitPages) {
|
|
123
|
-
job.qunitPages = {}
|
|
124
|
-
}
|
|
125
|
-
const qunitPage = {
|
|
126
|
-
id: filename(url),
|
|
127
|
-
start: new Date(),
|
|
128
|
-
isOpa: !!isOpa,
|
|
129
|
-
failed: 0,
|
|
130
|
-
passed: 0,
|
|
131
|
-
count: 0,
|
|
132
|
-
modules: []
|
|
133
|
-
}
|
|
134
|
-
job.qunitPages[url] = qunitPage
|
|
135
|
-
const { page, progress } = get(job, url, { modules })
|
|
136
|
-
progress.count = 0
|
|
137
|
-
progress.total = page.count
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
async testStart (job, urlWithHash, details) {
|
|
141
|
-
getOutput(job).debug('qunit/testStart', 'testStart', urlWithHash, details)
|
|
142
|
-
const { page, test } = get(job, urlWithHash, details)
|
|
143
|
-
const { [$doneTimeout]: doneTimeout, [$doneResolve]: doneResolve } = page
|
|
144
|
-
if (doneTimeout) {
|
|
145
|
-
clearTimeout(doneTimeout)
|
|
146
|
-
doneResolve()
|
|
147
|
-
}
|
|
148
|
-
test.start = new Date()
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
async log (job, urlWithHash, details) {
|
|
152
|
-
getOutput(job).debug('qunit/log', 'log', urlWithHash, details)
|
|
153
|
-
const { url, page, test } = get(job, urlWithHash, details)
|
|
154
|
-
const { isOpa, modules, module, name, testId, ...log } = details
|
|
155
|
-
if (!test) {
|
|
156
|
-
invalidTestId(job, url, testId)
|
|
157
|
-
}
|
|
158
|
-
if (!test.logs) {
|
|
159
|
-
test.logs = []
|
|
160
|
-
}
|
|
161
|
-
test.logs.push(log)
|
|
162
|
-
if (page.isOpa && job.browserCapabilities.screenshot && job.screenshot) {
|
|
163
|
-
try {
|
|
164
|
-
const absoluteName = await screenshot(job, url, `${testId}-${log.runtime}`)
|
|
165
|
-
log.screenshot = basename(absoluteName)
|
|
166
|
-
} catch (error) {
|
|
167
|
-
getOutput(job).genericError(error, url)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
async testDone (job, urlWithHash, details) {
|
|
173
|
-
getOutput(job).debug('qunit/testDone', 'testDone', urlWithHash, details)
|
|
174
|
-
const { name, module, testId, assertions, ...report } = details
|
|
175
|
-
const { failed } = report
|
|
176
|
-
const { url, page, test, progress } = get(job, urlWithHash, { testId })
|
|
177
|
-
if (!test) {
|
|
178
|
-
invalidTestId(job, url, testId)
|
|
179
|
-
}
|
|
180
|
-
++progress.count
|
|
181
|
-
if (failed) {
|
|
182
|
-
if (job.browserCapabilities.screenshot && job.screenshotOnFailure) {
|
|
183
|
-
try {
|
|
184
|
-
const absoluteName = await screenshot(job, url, testId)
|
|
185
|
-
test.screenshot = basename(absoluteName)
|
|
186
|
-
} catch (error) {
|
|
187
|
-
getOutput(job).genericError(error, url)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
++page.failed
|
|
191
|
-
job.failed = true
|
|
192
|
-
} else {
|
|
193
|
-
++page.passed
|
|
194
|
-
}
|
|
195
|
-
test.end = new Date()
|
|
196
|
-
test.report = report
|
|
197
|
-
if (job.failOpaFast && failed) {
|
|
198
|
-
// skip remaining tests
|
|
199
|
-
page.modules.forEach(module => {
|
|
200
|
-
module.tests.forEach(test => {
|
|
201
|
-
if (!test.report) {
|
|
202
|
-
test.skip = true
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
})
|
|
206
|
-
await done(job, urlWithHash, {
|
|
207
|
-
failed: page.failed,
|
|
208
|
-
passed: page.passed,
|
|
209
|
-
total: page.count,
|
|
210
|
-
runtime: 0
|
|
211
|
-
})
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
async done (job, urlWithHash, report) {
|
|
216
|
-
getOutput(job).debug('qunit/done', 'done', urlWithHash, report)
|
|
217
|
-
await done(job, urlWithHash, report)
|
|
218
|
-
}
|
|
219
|
-
}
|
package/src/report.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { join } = require('path')
|
|
4
|
-
const { writeFile } = require('fs').promises
|
|
5
|
-
const { generateCoverageReport } = require('./coverage')
|
|
6
|
-
const { filename, allocPromise } = require('./tools')
|
|
7
|
-
const { fork } = require('child_process')
|
|
8
|
-
const { getOutput } = require('./output')
|
|
9
|
-
|
|
10
|
-
async function save (job) {
|
|
11
|
-
// Ensure the file is treated as CommonJS
|
|
12
|
-
await writeFile(join(job.reportDir, 'package.json'), '{"type": "commonjs"}')
|
|
13
|
-
await writeFile(join(job.reportDir, 'job.js'), `module.exports = ${JSON.stringify(job, (key, value) => {
|
|
14
|
-
if (value && value instanceof RegExp) {
|
|
15
|
-
return value.toString()
|
|
16
|
-
}
|
|
17
|
-
return value
|
|
18
|
-
}, 2)}`)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function generateTextReport (job) {
|
|
22
|
-
const { promise, resolve } = allocPromise()
|
|
23
|
-
const childProcess = fork(
|
|
24
|
-
join(__dirname, 'defaults/text-report.js'),
|
|
25
|
-
[job.reportDir, process.stdout.columns || ''],
|
|
26
|
-
{
|
|
27
|
-
stdio: 'pipe',
|
|
28
|
-
env: {
|
|
29
|
-
...process.env,
|
|
30
|
-
...job.env
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
getOutput(job).monitor(childProcess, true)
|
|
35
|
-
childProcess.on('close', resolve)
|
|
36
|
-
return promise
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
save,
|
|
41
|
-
|
|
42
|
-
async generate (job) {
|
|
43
|
-
const output = getOutput(job)
|
|
44
|
-
try {
|
|
45
|
-
await generateCoverageReport(job)
|
|
46
|
-
} catch (e) {
|
|
47
|
-
output.genericError(e)
|
|
48
|
-
job.failed = true
|
|
49
|
-
}
|
|
50
|
-
job.status = 'Generating reports'
|
|
51
|
-
job.end = new Date()
|
|
52
|
-
job.failed = !!job.failed
|
|
53
|
-
job.testPageHashes = job.testPageUrls.map(url => filename(url))
|
|
54
|
-
output.debug('report', 'saving job...')
|
|
55
|
-
await save(job)
|
|
56
|
-
output.debug('report', 'job saved.')
|
|
57
|
-
output.debug('report', 'generating text report...')
|
|
58
|
-
await generateTextReport(job)
|
|
59
|
-
output.debug('report', 'text report generated.')
|
|
60
|
-
const promises = job.reportGenerator.map(generator => {
|
|
61
|
-
output.debug('report', 'launching', generator, '...')
|
|
62
|
-
const { promise, resolve } = allocPromise()
|
|
63
|
-
const childProcess = fork(
|
|
64
|
-
generator,
|
|
65
|
-
[job.reportDir],
|
|
66
|
-
{
|
|
67
|
-
stdio: 'pipe',
|
|
68
|
-
env: {
|
|
69
|
-
...process.env,
|
|
70
|
-
...job.env
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
const buffers = output.monitor(childProcess, false)
|
|
75
|
-
childProcess.on('close', exitCode => {
|
|
76
|
-
output.debug('report', generator, 'ended with exit code', exitCode)
|
|
77
|
-
if (exitCode !== 0) {
|
|
78
|
-
output.reportGeneratorFailed(generator, exitCode, buffers)
|
|
79
|
-
}
|
|
80
|
-
resolve()
|
|
81
|
-
output.debug('report', generator, 'resolved')
|
|
82
|
-
})
|
|
83
|
-
return promise
|
|
84
|
-
})
|
|
85
|
-
output.debug('report', 'generators count:', promises.length)
|
|
86
|
-
await Promise.all(promises)
|
|
87
|
-
job.status = 'Reports generated'
|
|
88
|
-
}
|
|
89
|
-
}
|
package/src/reserve.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const cors = require('./cors')
|
|
2
|
-
const endpoints = require('./endpoints')
|
|
3
|
-
const { mappings: coverage } = require('./coverage')
|
|
4
|
-
const { mappings: ui5 } = require('./ui5')
|
|
5
|
-
const { check } = require('reserve')
|
|
6
|
-
const unhandled = require('./unhandled')
|
|
7
|
-
|
|
8
|
-
module.exports = async job => check({
|
|
9
|
-
port: job.port,
|
|
10
|
-
mappings: [
|
|
11
|
-
cors,
|
|
12
|
-
...job.mappings ?? [],
|
|
13
|
-
...job.serveOnly ? [] : endpoints(job),
|
|
14
|
-
...await ui5(job),
|
|
15
|
-
...job.serveOnly ? [] : await coverage(job),
|
|
16
|
-
{
|
|
17
|
-
// Project mapping
|
|
18
|
-
match: /^\/(.*)/,
|
|
19
|
-
cwd: job.webapp,
|
|
20
|
-
file: '$1',
|
|
21
|
-
static: !job.watch && !job.debugDevMode
|
|
22
|
-
},
|
|
23
|
-
...job.serveOnly ? [{ status: 404 }] : unhandled(job)
|
|
24
|
-
]
|
|
25
|
-
})
|
package/src/start.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process')
|
|
2
|
-
const { readFile, access, constants } = require('fs/promises')
|
|
3
|
-
const { join } = require('path')
|
|
4
|
-
const { getOutput } = require('./output')
|
|
5
|
-
const { platform } = require('os')
|
|
6
|
-
const { allocPromise } = require('./tools')
|
|
7
|
-
|
|
8
|
-
async function start (job) {
|
|
9
|
-
const { startWaitUrl: url, startWaitMethod: method } = job
|
|
10
|
-
const { startCommand: start } = job
|
|
11
|
-
const output = getOutput(job)
|
|
12
|
-
let [command, ...parameters] = start.split(' ')
|
|
13
|
-
|
|
14
|
-
job.status = 'Executing start command'
|
|
15
|
-
|
|
16
|
-
// check if existing NPM script
|
|
17
|
-
if (command !== 'node' && parameters.length === 0) {
|
|
18
|
-
const packagePath = join(job.cwd, 'package.json')
|
|
19
|
-
try {
|
|
20
|
-
await access(packagePath, constants.F_OK)
|
|
21
|
-
output.debug('start', 'Found package.json in cwd')
|
|
22
|
-
const packageFile = JSON.parse(await readFile(packagePath, 'utf-8'))
|
|
23
|
-
if (packageFile.scripts[command]) {
|
|
24
|
-
output.debug('start', 'Found matching script in package.json')
|
|
25
|
-
// grab npm-cli path
|
|
26
|
-
const { promise, resolve } = allocPromise()
|
|
27
|
-
const npmChildProcess = spawn('npm', {
|
|
28
|
-
shell: true,
|
|
29
|
-
encoding: 'utf8'
|
|
30
|
-
})
|
|
31
|
-
npmChildProcess.on('close', resolve)
|
|
32
|
-
const npmOutput = []
|
|
33
|
-
npmChildProcess.stdout.on('data', (data) => npmOutput.push(data.toString()))
|
|
34
|
-
await promise
|
|
35
|
-
const [, version, path] = /^npm@([^ ]+) (.*)$/gm.exec(npmOutput.join(''))
|
|
36
|
-
output.debug('start', `npm@${version} ${path}`)
|
|
37
|
-
parameters = [join(path, 'bin/npm-cli.js'), 'run', command]
|
|
38
|
-
command = 'node'
|
|
39
|
-
}
|
|
40
|
-
} catch (e) {
|
|
41
|
-
output.debug('start', 'Missing or invalid package.json in cwd', e)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (command === 'node') {
|
|
46
|
-
const [node] = process.argv
|
|
47
|
-
output.debug('start', `Replacing node with ${node}`)
|
|
48
|
-
command = node
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let startProcessExited = false
|
|
52
|
-
output.debug('start', 'Spawning', [command, ...parameters])
|
|
53
|
-
const startProcess = spawn(command, parameters, {
|
|
54
|
-
cwd: job.cwd,
|
|
55
|
-
windowsHide: true,
|
|
56
|
-
detached: true
|
|
57
|
-
})
|
|
58
|
-
startProcess.on('close', () => {
|
|
59
|
-
output.debug('start', 'Start command process exited')
|
|
60
|
-
startProcessExited = true
|
|
61
|
-
})
|
|
62
|
-
output.monitor(startProcess)
|
|
63
|
-
output.debug('start', `Spawned process id ${startProcess.pid}`)
|
|
64
|
-
|
|
65
|
-
job.status = 'Waiting for URL to be reachable'
|
|
66
|
-
|
|
67
|
-
const begin = Date.now()
|
|
68
|
-
let lastError
|
|
69
|
-
// eslint-disable-next-line no-unmodified-loop-condition
|
|
70
|
-
while (!startProcessExited && Date.now() - begin <= job.startTimeout) {
|
|
71
|
-
try {
|
|
72
|
-
const response = await fetch(url, { method })
|
|
73
|
-
output.debug('start', url, response.status)
|
|
74
|
-
if (response.status === 200) {
|
|
75
|
-
break
|
|
76
|
-
}
|
|
77
|
-
} catch (e) {
|
|
78
|
-
if (e.toString() !== lastError) {
|
|
79
|
-
output.debug('start', url, e)
|
|
80
|
-
lastError = e.toString()
|
|
81
|
-
}
|
|
82
|
-
await new Promise(resolve => setTimeout(resolve, 250))
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (startProcessExited) {
|
|
87
|
-
throw new Error(`Start command failed with exit code ${startProcess.exitCode}`)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const stop = async () => {
|
|
91
|
-
job.status = 'Terminating start command'
|
|
92
|
-
if (platform() === 'win32') {
|
|
93
|
-
const killProcess = spawn('taskkill', ['/F', '/T', '/PID', startProcess.pid], {
|
|
94
|
-
windowsHide: true
|
|
95
|
-
})
|
|
96
|
-
const { promise, resolve } = allocPromise()
|
|
97
|
-
killProcess.on('close', resolve)
|
|
98
|
-
output.monitor(killProcess)
|
|
99
|
-
await promise
|
|
100
|
-
} else {
|
|
101
|
-
try {
|
|
102
|
-
process.kill(-startProcess.pid)
|
|
103
|
-
} catch (error) {
|
|
104
|
-
output.genericError(error)
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const begin = Date.now()
|
|
109
|
-
// eslint-disable-next-line no-unmodified-loop-condition
|
|
110
|
-
while (!startProcessExited && Date.now() - begin <= job.startTimeout) {
|
|
111
|
-
await new Promise(resolve => setTimeout(resolve, 250))
|
|
112
|
-
}
|
|
113
|
-
if (startProcessExited) {
|
|
114
|
-
// Additional waiting time to release handles
|
|
115
|
-
await new Promise(resolve => setTimeout(resolve, 250))
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (Date.now() - begin > job.startTimeout) {
|
|
120
|
-
await stop()
|
|
121
|
-
throw new Error(`Timeout while waiting for ${url}`)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
stop
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = { start }
|
package/src/symbols.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
$browsers: Symbol('browsers'),
|
|
3
|
-
$valueSources: Symbol('valueSources'),
|
|
4
|
-
$remoteOnLegacy: Symbol('remoteOnLegacy'),
|
|
5
|
-
$proxifiedUrls: Symbol('proxifiedUrls'),
|
|
6
|
-
$statusProgressCount: Symbol('statusProgressCount'),
|
|
7
|
-
$statusProgressTotal: Symbol('statusProgressTotal')
|
|
8
|
-
}
|