mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
test(ci): [CI-JASSUB-SOURCE-01] include source in native JASSUB checks
This commit is contained in:
1 parent
5862f60b0e
commit
5e0447fc51
12 files changed
+6113
-31
No files matched your search
@@ -8,6 +8,46 @@ import process from 'node:process'
|
||||
import test from 'node:test'
|
||||
import { browserInvocation, browserScopeConfig, installedTests } from '../scripts/browser-validation/scope.ts'
|
||||
|
||||
function collectNativeJassub(overrides = {}) {
|
||||
const env = { ...process.env }
|
||||
for (const name of Object.keys(env)) {
|
||||
if (name.startsWith('ARTPLAYER_JASSUB_') || name === 'ARTPLAYER_BROWSER_ARTIFACTS' || name.startsWith('PLAYWRIGHT_JSON_OUTPUT'))
|
||||
delete env[name]
|
||||
}
|
||||
return spawnSync(process.execPath, ['node_modules/@playwright/test/cli.js', 'test', '--config=playwright.config.js', 'test/browser/jassub-native.spec.js', '--list', '--reporter=json', '--project=chromium'], {
|
||||
encoding: 'utf8',
|
||||
env: { ...env, ...overrides },
|
||||
windowsHide: true,
|
||||
timeout: 60000,
|
||||
maxBuffer: 8 * 1024 * 1024,
|
||||
})
|
||||
}
|
||||
|
||||
test('Native JASSUB collection includes current source and published controls for every core', () => {
|
||||
const source = collectNativeJassub()
|
||||
assert.equal(source.status, 0, source.stderr || source.stdout)
|
||||
const titles = JSON.parse(source.stdout).suites.flatMap(suite => suite.specs.map(spec => spec.title)).sort()
|
||||
const cores = ['candidate', 'published', 'published-5.3.1-beta.1']
|
||||
const expected = ['candidate source-build', 'published 1.1.0'].flatMap(input => cores.map(core => `JASSUB ${input} renders actual WASM subtitles through seek and layout with ${core} core, customCanvas=false, defaultOffscreen=false`)).sort()
|
||||
assert.deepEqual(titles, expected)
|
||||
|
||||
const explicit = collectNativeJassub({ ARTPLAYER_JASSUB_ARTIFACT: path.resolve('packages/artplayer-plugin-jassub/dist/artplayer-plugin-jassub.js') })
|
||||
assert.equal(explicit.status, 0, explicit.stderr || explicit.stdout)
|
||||
const selected = JSON.parse(explicit.stdout).suites.flatMap(suite => suite.specs.map(spec => spec.title)).sort()
|
||||
assert.deepEqual(selected, cores.map(core => `JASSUB candidate artifact renders actual WASM subtitles through seek and layout with ${core} core, customCanvas=false, defaultOffscreen=false`).sort())
|
||||
})
|
||||
|
||||
test('Native JASSUB rejects missing explicit artifacts and mixed installed selection without fallback', () => {
|
||||
const missing = path.resolve('refactor/.cache/absent-jassub-native-artifact.js')
|
||||
assert(!fs.existsSync(missing))
|
||||
const explicit = collectNativeJassub({ ARTPLAYER_JASSUB_ARTIFACT: missing })
|
||||
assert.equal(explicit.status, 1)
|
||||
assert.match(explicit.stdout + explicit.stderr, /ENOENT/)
|
||||
const mixed = collectNativeJassub({ ARTPLAYER_JASSUB_ARTIFACT: missing, ARTPLAYER_BROWSER_ARTIFACTS: '/unused/installed-map.json' })
|
||||
assert.equal(mixed.status, 1)
|
||||
assert.match(mixed.stdout + mixed.stderr, /Installed browser checks cannot override artplayer-plugin-jassub artifact/)
|
||||
})
|
||||
|
||||
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)
|
||||
|
||||
+12
-6
@@ -326,10 +326,14 @@ candidate plugins to the exact main/legacy files being tested.
|
||||
Frozen-plugin retained DOM, candidate cleanup and unsupported API outcomes remain
|
||||
distinct; the old plugin's observed loss is not complete-delivery acceptance.
|
||||
|
||||
`jassub-native.spec.js` runs actual published JASSUB 1.1.0, its native Worker,
|
||||
fixed local WASM/font and authored ASS cues with offscreenRender=false. It checks
|
||||
real canvas pixels before/after seek, CSS web fullscreen and normal destruction.
|
||||
Windows WebKit currently fails the default frame-clock path; the explicitly
|
||||
`jassub-native.spec.js` runs both published JASSUB 1.1.0 and current source by
|
||||
default, each on three cores, with native Worker, fixed local WASM/font and
|
||||
authored ASS cues with offscreenRender=false. It checks real canvas pixels
|
||||
before/after seek, CSS web fullscreen and destruction. Source candidates use
|
||||
direct instance destruction before host cleanup, just like explicit/installed
|
||||
candidates. Selected-input attachments distinguish source-build from published
|
||||
and installed artifacts; a missing source file path is not a historical identity.
|
||||
Windows WebKit currently fails the published default frame-clock path; the explicitly
|
||||
selected ARTPLAYER_JASSUB_ON_DEMAND=false diagnostic passes on the candidate core.
|
||||
This is a retained historical failure, not a waived browser gate. The server must
|
||||
serve WASM as application/wasm for native streaming compilation. Archive failed
|
||||
@@ -339,8 +343,10 @@ For candidate registration regressions, set ARTPLAYER_JASSUB_ARTIFACT to a built
|
||||
main/legacy global file. Those runs also destroy the exposed instance before host
|
||||
cleanup. ARTPLAYER_JASSUB_CUSTOM_CANVAS=true supplies a caller-owned canvas and
|
||||
asserts it remains connected after destroy(false). The native report records the
|
||||
artifact hash and both mode choices. This does not change the default published
|
||||
baseline or establish ESM/offscreen/device acceptance.
|
||||
artifact hash and both mode choices. An explicit file selects that input alone;
|
||||
normal source/installed runs retain the historical control alongside the candidate.
|
||||
The original historical failure is not waived. These checks do not establish
|
||||
ESM/offscreen/device acceptance.
|
||||
|
||||
`jassub-render-failure.spec.js` uses an actual Worker/WASM bitmap and native copies.
|
||||
It intentionally closes one bitmap to provoke native Canvas InvalidStateError,
|
||||
|
||||
@@ -14,8 +14,8 @@ const publishedCode = readMember(archive, member).toString()
|
||||
if (hash(publishedCode) !== release.files[member])
|
||||
throw new Error('Published JASSUB artifact changed')
|
||||
const published = { code: publishedCode, provenance: { kind: 'published', version: release.version, integrity: release.integrity, member, sha256: hash(publishedCode) } }
|
||||
const candidate = process.env.ARTPLAYER_BROWSER_ARTIFACTS || explicitArtifact ? await browserCandidate('artplayer-plugin-jassub', explicitArtifact) : null
|
||||
const inputs = process.env.ARTPLAYER_BROWSER_ARTIFACTS ? [published, candidate] : [candidate || published]
|
||||
const candidate = await browserCandidate('artplayer-plugin-jassub', explicitArtifact)
|
||||
const inputs = explicitArtifact ? [candidate] : [published, candidate]
|
||||
const customCanvas = process.env.ARTPLAYER_JASSUB_CUSTOM_CANVAS === 'true'
|
||||
const onDemandRender = process.env.ARTPLAYER_JASSUB_ON_DEMAND !== 'false'
|
||||
const defaultOffscreen = process.env.ARTPLAYER_JASSUB_OFFSCREEN === 'default'
|
||||
@@ -57,9 +57,10 @@ Dialogue: 0,${screenshotReadback ? '0:00:40.00,0:01:50.00' : '0:00:05.00,0:00:30
|
||||
const testedSubtitles = screenshotReadback ? subtitles.replace('&H00FFFFFF', '&H0000FF00') : subtitles
|
||||
|
||||
for (const { code, provenance } of inputs) {
|
||||
const artifact = provenance.kind !== 'published' ? provenance.file : null
|
||||
const isCandidate = provenance.kind !== 'published'
|
||||
const label = isCandidate ? (provenance.kind === 'source-build' ? 'candidate source-build' : 'candidate artifact') : `published ${release.version}`
|
||||
for (const core of ['candidate', 'published', 'published-5.3.1-beta.1']) {
|
||||
test(`JASSUB ${artifact ? 'candidate artifact' : `published ${release.version}`} renders actual WASM subtitles through seek and layout with ${core} core, customCanvas=${customCanvas}, defaultOffscreen=${defaultOffscreen}`, async ({ page, context }, testInfo) => {
|
||||
test(`JASSUB ${label} renders actual WASM subtitles through seek and layout with ${core} core, customCanvas=${customCanvas}, defaultOffscreen=${defaultOffscreen}`, async ({ page, context }, testInfo) => {
|
||||
await testInfo.attach('jassub-selected-input', { contentType: 'application/json', body: JSON.stringify({ core, provenance }) })
|
||||
const resources = []
|
||||
const external = []
|
||||
@@ -228,8 +229,18 @@ for (const { code, provenance } of inputs) {
|
||||
await pixels(page, 'restored')
|
||||
}
|
||||
await testInfo.attach('actual-jassub-page', { body: await page.screenshot(), contentType: 'image/png' })
|
||||
if (artifact)
|
||||
await page.evaluate(() => window.jassub.destroy())
|
||||
if (isCandidate) {
|
||||
const directDestroy = await page.evaluate(() => {
|
||||
window.jassub.destroy()
|
||||
return {
|
||||
coreAlive: !window.art.isDestroy && window.Artplayer.instances.includes(window.art),
|
||||
workers: window.jassubNative.workers.map(worker => worker.terminated),
|
||||
canvases: document.querySelectorAll('.JASSUB').length,
|
||||
}
|
||||
})
|
||||
await testInfo.attach('jassub-direct-destroy', { body: JSON.stringify(directDestroy), contentType: 'application/json' })
|
||||
expect(directDestroy).toEqual({ coreAlive: true, workers: [1], canvases: 0 })
|
||||
}
|
||||
await page.evaluate(() => window.art.destroy(false))
|
||||
if (customCanvas)
|
||||
expect(await page.evaluate(() => window.jassubUserCanvas.isConnected)).toBe(true)
|
||||
|
||||
Reference in new issue
Block a user