Add Swoole alternative backend
This commit is contained in:
24
alt/swoole/manifest-smoke.mjs
Normal file
24
alt/swoole/manifest-smoke.mjs
Normal file
@@ -0,0 +1,24 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { createAssetManifest } from '../../server/asset-manifest.js';
|
||||
|
||||
const scenarios = [
|
||||
['default', true, true],
|
||||
['hashing-off', false, true],
|
||||
['asset-sync-off', true, false],
|
||||
];
|
||||
for (const [name, hashing, assetSync] of scenarios) {
|
||||
const php = spawnSync('php', ['-r', `require "alt/swoole/asset-manifest.php"; $m=new AssetManifest("frontend", ${hashing ? 'true' : 'false'}, ${assetSync ? 'true' : 'false'}); echo json_encode(["manifest"=>$m->manifest,"index"=>$m->index,"sw"=>$m->serviceWorker]);`], { encoding: 'utf8' });
|
||||
assert.equal(php.status, 0, php.stderr);
|
||||
const result = JSON.parse(php.stdout);
|
||||
const bun = createAssetManifest('./frontend', { hashing, assetSync });
|
||||
assert.equal(result.manifest.buildTag, bun.manifest.buildTag, `${name}: build tags match`);
|
||||
assert.deepEqual(result.manifest.files, bun.manifest.files, `${name}: manifest file entries match`);
|
||||
assert.deepEqual(result.manifest.groups, bun.manifest.groups, `${name}: asset groups match`);
|
||||
assert.equal(result.index, bun.index, `${name}: stamped index bytes match`);
|
||||
assert.equal(result.sw, bun.sw, `${name}: injected service worker bytes match`);
|
||||
assert.equal(result.manifest.files['/admin.html'], undefined, `${name}: admin is not in the runtime manifest`);
|
||||
assert.ok(result.index.includes(`<meta name="ytp-build" content="${result.manifest.buildTag}"`));
|
||||
assert.match(result.sw, new RegExp(result.manifest.buildTag));
|
||||
console.log(`manifest smoke passed (${name}): build=${result.manifest.buildTag}, files=${Object.keys(result.manifest.files).length}`);
|
||||
}
|
||||
Reference in New Issue
Block a user