mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 23:36:15 -08:00
ci: [CI-BROWSER-01] separate source and installed browser scopes
This commit is contained in:
1 parent
765ddb816f
commit
492e58a345
20 files changed
+1920
-15
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import fs from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
// eslint-disable-next-line test/no-import-node-test -- Validate real runner exit codes and scope boundaries.
|
||||
import test from 'node:test'
|
||||
import { browserInvocation, browserScopeConfig, installedTests } from '../scripts/browser-validation/scope.ts'
|
||||
|
||||
test('Source invocation clears inherited artifact selection without changing caller environment', () => {
|
||||
const environment = { ARTPLAYER_BROWSER_ARTIFACTS: '/installed/map.json', KEEP: 'value' }
|
||||
const source = browserInvocation('source', ['--project=chromium'], environment)
|
||||
assert.equal(source.env.ARTPLAYER_BROWSER_ARTIFACTS, undefined)
|
||||
assert.equal(source.env.KEEP, 'value')
|
||||
assert.equal(environment.ARTPLAYER_BROWSER_ARTIFACTS, '/installed/map.json')
|
||||
assert.deepEqual(browserScopeConfig('source').testMatch, ['**/*.spec.js'])
|
||||
const installed = browserInvocation('installed', [], environment)
|
||||
assert.equal(installed.env.ARTPLAYER_BROWSER_ARTIFACTS, environment.ARTPLAYER_BROWSER_ARTIFACTS)
|
||||
assert.notEqual(source.directory, installed.directory)
|
||||
assert(installedTests.includes('ambilight-proxy.spec.js'))
|
||||
assert(installedTests.includes('canvas-lifecycle.spec.js'))
|
||||
for (const file of installedTests)
|
||||
assert(fs.existsSync(path.resolve('test/browser', file)))
|
||||
})
|
||||
|
||||
test('Browser invocation rejects ambiguous scopes and output/configuration overrides', () => {
|
||||
assert.throws(() => browserInvocation('unknown', [], {}), /Choose/)
|
||||
assert.throws(() => browserInvocation('installed', [], {}), /require ARTPLAYER/)
|
||||
for (const flag of ['--config=other.js', '--config', '-c', '-cother.js', '--reporter=json', '--output=elsewhere', '--pass-with-no-tests'])
|
||||
assert.throws(() => browserInvocation('source', [flag], {}), /Do not override/)
|
||||
})
|
||||
|
||||
for (const code of [0, 17]) {
|
||||
test(`Browser runner preserves actual child exit ${code} and source input identity`, () => {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'artplayer-browser-runner-'))
|
||||
try {
|
||||
const cli = path.join(root, 'node_modules/@playwright/test/cli.js')
|
||||
fs.mkdirSync(path.dirname(cli), { recursive: true })
|
||||
fs.writeFileSync(cli, `require('node:assert/strict').equal(process.env.ARTPLAYER_BROWSER_ARTIFACTS, undefined); process.exit(${code});`)
|
||||
const run = spawnSync(process.execPath, [path.resolve('scripts/browser-check.mjs'), 'source'], { cwd: root, env: { ...process.env, ARTPLAYER_BROWSER_ARTIFACTS: '/unwanted/map.json' }, encoding: 'utf8', windowsHide: true, timeout: 10000 })
|
||||
assert.equal(run.status, code, run.stderr)
|
||||
const directory = path.join(root, 'refactor/.cache/browser-source')
|
||||
const invocation = JSON.parse(fs.readFileSync(path.join(directory, 'invocation.json')))
|
||||
const result = JSON.parse(fs.readFileSync(path.join(directory, 'result.json')))
|
||||
assert.equal(invocation.artifactMap, null)
|
||||
assert.equal(result.exitCode, code)
|
||||
assert.equal(result.scope, 'source')
|
||||
assert(!fs.existsSync(path.join(root, 'refactor/.cache/browser-installed')))
|
||||
}
|
||||
finally {
|
||||
assert.equal(path.dirname(root), path.resolve(os.tmpdir()))
|
||||
assert(path.basename(root).startsWith('artplayer-browser-runner-'))
|
||||
fs.rmSync(root, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
# Browser regression entry
|
||||
|
||||
CI uses `yarn test:browser:source` for the complete source suite and
|
||||
`yarn test:browser:installed` for the reviewed installed-package subset. The source
|
||||
launcher clears inherited ARTPLAYER_BROWSER_ARTIFACTS; the installed launcher and
|
||||
config verify all required package hashes and build inputs. Reports live separately
|
||||
under browser-source/ and browser-installed/. See
|
||||
[scope maintenance](../../scripts/browser-validation/README.md) before adding an
|
||||
installed test or interpreting `--list` output as execution evidence. Existing
|
||||
`yarn test:browser` commands retain their ad hoc behavior and browser/ output.
|
||||
|
||||
`library-development.spec.js` starts the actual JS dev CLI and typed runner on an
|
||||
atomically assigned fixture port. It checks generated TS/Less/SVG/inline-worker assets,
|
||||
automatic reload on edits and recovery after a compiler error in all three
|
||||
|
||||
Reference in new issue
Block a user