验证样例文章验收冒烟流程
This commit is contained in:
@@ -46,7 +46,7 @@ export async function main(rawArgs = process.argv.slice(2)) {
|
||||
mkdirSync(reportDir, { recursive: true });
|
||||
|
||||
const port = args.port ? Number(args.port) : await findAvailablePort(3000);
|
||||
const baseURL = args.baseURL || `http://127.0.0.1:${port}`;
|
||||
const baseURL = args.baseURL || baseURLForPort(port);
|
||||
const appDataDir = join(reportDir, "app-data");
|
||||
mkdirSync(appDataDir, { recursive: true });
|
||||
|
||||
@@ -70,7 +70,7 @@ export async function main(rawArgs = process.argv.slice(2)) {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
captureServerLogs(serverProcess, reportDir, runEnv);
|
||||
await waitForServer(baseURL, 120000);
|
||||
await waitForServer(baseURL, 120000, serverProcess);
|
||||
}
|
||||
|
||||
status = await runPlaywright(runEnv, Boolean(args.headed));
|
||||
@@ -108,6 +108,10 @@ export function parseArgs(rawArgs) {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
export function baseURLForPort(port) {
|
||||
return `http://localhost:${port}`;
|
||||
}
|
||||
|
||||
export function parseEnvFile(content) {
|
||||
const values = {};
|
||||
for (const line of content.split(/\r?\n/)) {
|
||||
@@ -177,9 +181,14 @@ export function redact(text, secrets) {
|
||||
return next;
|
||||
}
|
||||
|
||||
async function waitForServer(baseURL, timeoutMs) {
|
||||
export async function waitForServer(baseURL, timeoutMs, serverProcess = null) {
|
||||
const started = Date.now();
|
||||
while (Date.now() - started < timeoutMs) {
|
||||
if (serverProcess?.exitCode !== null) {
|
||||
throw new Error(
|
||||
`dev server exited before ${baseURL} became ready; see server.log in the report directory`,
|
||||
);
|
||||
}
|
||||
try {
|
||||
const response = await fetch(baseURL, { method: "HEAD" });
|
||||
if (response.ok) return;
|
||||
|
||||
Reference in New Issue
Block a user