ui5-test-runner 2.0.1 → 2.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui5-test-runner",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Standalone test runner for UI5",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -95,4 +95,4 @@
95
95
  }
96
96
  }
97
97
  }
98
- }
98
+ }
@@ -1,8 +1,10 @@
1
1
  'use strict'
2
2
 
3
+ // Based on specification from llg[.]cubic[.]org/docs/junit/
4
+
3
5
  const { join } = require('path')
4
6
  const { writeFile } = require('fs').promises
5
- const [,, reportDir] = process.argv
7
+ const [, , reportDir] = process.argv
6
8
 
7
9
  const output = []
8
10
  function o (text) {
@@ -38,12 +40,17 @@ async function main () {
38
40
  if (test.skip) {
39
41
  o(' <skipped></skipped>')
40
42
  } else if (test.report.failed) {
41
- const log = test.logs.filter(({ result }) => !result)[0]
42
- o(` <failure
43
+ test.logs
44
+ .filter(({ result }) => !result)
45
+ .forEach(log => {
46
+ o(` <failure
43
47
  message="${xmlEscape(log.message)}"
44
48
  >`)
45
- o(xmlEscape(log.source))
46
- o(' </failure>')
49
+ if (log.source) {
50
+ o(xmlEscape(log.source))
51
+ }
52
+ o(' </failure>')
53
+ })
47
54
  }
48
55
  o(' </testcase>')
49
56
  }
@@ -3,6 +3,7 @@
3
3
  const { join } = require('path')
4
4
  const { readFile, writeFile } = require('fs').promises
5
5
  const [,, reportDir] = process.argv
6
+ const { resolveDependencyPath } = require('../npm.js')
6
7
 
7
8
  const defaultDir = join(__dirname, 'report')
8
9
 
@@ -11,7 +12,7 @@ async function readDefault (name) {
11
12
  }
12
13
 
13
14
  async function readDependency (name) {
14
- return (await readFile(join(__dirname, '../../node_modules', name, 'dist', `${name}.js`))).toString()
15
+ return (await readFile(resolveDependencyPath(name))).toString()
15
16
  }
16
17
 
17
18
  function minifyJs (src) {
package/src/endpoints.js CHANGED
@@ -10,6 +10,10 @@ const { addTestPages } = require('./add-test-pages')
10
10
  const { getJobProgress } = require('./get-job-progress')
11
11
  const { readFile } = require('fs/promises')
12
12
  const { TextEncoder } = require('util')
13
+ const { resolveDependencyPath } = require('./npm.js')
14
+
15
+ const punyexprBinPath = resolveDependencyPath('punyexpr')
16
+ const punybindBinPath = resolveDependencyPath('punybind')
13
17
 
14
18
  module.exports = job => {
15
19
  async function endpointImpl (api, implementation, request) {
@@ -131,11 +135,11 @@ module.exports = job => {
131
135
  }, {
132
136
  // punybind
133
137
  match: '^/_/punybind.js',
134
- file: join(__dirname, '../node_modules/punybind/dist/punybind.js')
138
+ file: punybindBinPath
135
139
  }, {
136
140
  // punyexpr
137
141
  match: '^/_/punyexpr.js',
138
- file: join(__dirname, '../node_modules/punyexpr/dist/punyexpr.js')
142
+ file: punyexprBinPath
139
143
  }, {
140
144
  // Endpoint to follow progress
141
145
  match: '^/_/progress(?:\\?page=([^&]*)(?:&test=([^&]*))?)?',
package/src/job.js CHANGED
@@ -258,7 +258,10 @@ function finalize (job) {
258
258
  function fromCmdLine (cwd, args) {
259
259
  let job = parse(cwd, args)
260
260
 
261
- const defaultPath = join(job.cwd, 'ui5-test-runner.json')
261
+ let defaultPath = join(job.cwd, 'ui5-test-runner.json')
262
+ if (!isAbsolute(defaultPath)) {
263
+ defaultPath = join(job.initialCwd, defaultPath)
264
+ }
262
265
  let hasDefaultSettings = false
263
266
  try {
264
267
  checkAccess({ path: defaultPath, file: true })
package/src/npm.js CHANGED
@@ -32,6 +32,11 @@ let localRoot
32
32
  let globalRoot
33
33
 
34
34
  module.exports = {
35
+ resolveDependencyPath (name) {
36
+ require(name)
37
+ return Object.keys(require.cache).filter(path => path.endsWith(`${name}.js`))[0]
38
+ },
39
+
35
40
  async resolvePackage (job, name) {
36
41
  if (!localRoot) {
37
42
  [localRoot, globalRoot] = await Promise.all([
package/src/output.js CHANGED
@@ -345,27 +345,33 @@ function build (job) {
345
345
  log(job, p`└──────────${pad.x('─')}┘`)
346
346
  }),
347
347
 
348
- monitor (childProcess) {
348
+ monitor (childProcess, live = true) {
349
+ const defaults = {
350
+ stdout: { buffer: [], method: log },
351
+ stderr: { buffer: [], method: err }
352
+ };
349
353
  ['stdout', 'stderr'].forEach(channel => {
350
- const defaults = {
351
- stdout: { buffer: [], method: log },
352
- stderr: { buffer: [], method: err }
353
- }
354
354
  childProcess[channel].on('data', chunk => {
355
355
  const { buffer, method } = defaults[channel]
356
356
  const text = chunk.toString()
357
- if (!text.includes('\n')) {
357
+ if (live) {
358
+ if (!text.includes('\n')) {
359
+ buffer.push(text)
360
+ return
361
+ }
362
+ const cached = buffer.join('')
363
+ const last = text.split('\n').slice(-1)
364
+ buffer.length = 0
365
+ if (last) {
366
+ buffer.push(last)
367
+ }
368
+ wrap(() => method(job, cached + text.split('\n').slice(0, -1).join('\n')))()
369
+ } else {
358
370
  buffer.push(text)
359
- return
360
371
  }
361
- const cached = buffer.join('')
362
- const last = text.split('\n').slice(-1)
363
- buffer.length = 0
364
- if (last) {
365
- buffer.push(last)
366
- }
367
- wrap(() => method(job, cached + text.split('\n').slice(0, -1).join('\n')))()
368
372
  })
373
+ })
374
+ if (live) {
369
375
  childProcess.on('close', () => {
370
376
  ['stdout', 'stderr'].forEach(channel => {
371
377
  const { buffer, method } = defaults[channel]
@@ -374,7 +380,11 @@ function build (job) {
374
380
  }
375
381
  })
376
382
  })
377
- })
383
+ }
384
+ return {
385
+ stdout: defaults.stdout.buffer,
386
+ stderr: defaults.stderr.buffer
387
+ }
378
388
  },
379
389
 
380
390
  nyc: wrap((...args) => {
@@ -499,6 +509,19 @@ function build (job) {
499
509
  }
500
510
  }),
501
511
 
512
+ reportGeneratorFailed: wrap((generator, exitCode, buffers) => {
513
+ const p = p80()
514
+ log(job, p`┌──────────${pad.x('─')}┐`)
515
+ log(job, p`│ REPORT GENERATOR FAILED ${pad.x(' ')} │`)
516
+ log(job, p`├───────────┬─${pad.x('─')}──┤`)
517
+ log(job, p`│ generator │ ${pad.lt(generator)} │`)
518
+ log(job, p`├───────────┼─${pad.x('─')}──┤`)
519
+ log(job, p`│ exit code │ ${pad.lt(exitCode.toString())} │`)
520
+ log(job, p`├───────────┴─${pad.x('─')}──┤`)
521
+ log(job, p`│ ${pad.w(buffers.stderr.join(''))} │`)
522
+ log(job, p`└──────────${pad.x('─')}┘`)
523
+ }),
524
+
502
525
  stop () {
503
526
  if (this.reportIntervalId) {
504
527
  clearInterval(this.reportIntervalId)
package/src/report.js CHANGED
@@ -33,10 +33,14 @@ module.exports = {
33
33
  await save(job)
34
34
  const promises = job.reportGenerator.map(generator => {
35
35
  const { promise, resolve } = allocPromise()
36
- const childProcess = fork(generator, [job.reportDir], {
37
- stdio: [0, 0, 0, 'ipc']
36
+ const childProcess = fork(generator, [job.reportDir], { stdio: 'pipe' })
37
+ const buffers = output.monitor(childProcess, false)
38
+ childProcess.on('close', exitCode => {
39
+ if (exitCode !== 0) {
40
+ output.reportGeneratorFailed(generator, exitCode, buffers)
41
+ }
42
+ resolve()
38
43
  })
39
- childProcess.on('close', resolve)
40
44
  return promise
41
45
  })
42
46
  promises.push(generateCoverageReport(job))