fix: keep SMS smoke progress visible with artifact output

This commit is contained in:
Codex
2026-07-03 23:38:15 +08:00
parent 03f9aa7ee8
commit bafaee48d5
2 changed files with 16 additions and 4 deletions

View File

@@ -79,11 +79,16 @@ const server = http.createServer(async (req, res) => {
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
function runCliSmoke(address) {
function runCliSmoke(address, args = ['--json', '--write']) {
return new Promise(resolve => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tiku-sms-smoke-'));
const writePath = path.join(tempDir, 'nested', 'sms-pnvs-remote-smoke.json');
const child = spawn(process.execPath, ['scripts/remote-sms-login-smoke.js', '--json', '--write', writePath], {
const childArgs = ['scripts/remote-sms-login-smoke.js'];
for (const arg of args) {
if (arg === '--write') childArgs.push('--write', writePath);
else childArgs.push(arg);
}
const child = spawn(process.execPath, childArgs, {
cwd: process.cwd(),
env: {
...process.env,
@@ -149,6 +154,14 @@ try {
assert.deepEqual(artifactSummary, cliSummary);
assert.doesNotMatch(cliResult.stdout, /Enter received/, 'CLI --json stdout must stay machine-readable JSON');
assert.doesNotMatch(cliResult.artifact, /Enter received/, 'CLI --write artifact must stay machine-readable JSON');
const writeOnlyCliResult = await runCliSmoke(address, ['--write']);
assert.equal(writeOnlyCliResult.status, 0, `CLI --write smoke should pass: ${writeOnlyCliResult.stdout} ${writeOnlyCliResult.stderr}`);
assert.match(writeOnlyCliResult.stdout, /PASS sms\.send provider=aliyun-pnvs/, 'CLI --write should keep human PASS output');
assert.match(writeOnlyCliResult.stdout, /PASS auth\.me/, 'CLI --write should keep auth.me PASS output');
const writeOnlyArtifactSummary = JSON.parse(writeOnlyCliResult.artifact);
assert.equal(writeOnlyArtifactSummary.provider, 'aliyun-pnvs');
assert.equal(writeOnlyArtifactSummary.bindProvider, 'aliyun-pnvs');
console.log('[PASS] remote SMS login smoke script');
} finally {
await new Promise(resolve => server.close(resolve));

View File

@@ -229,8 +229,7 @@ async function runRemoteSmsLoginSmoke(inputConfig, options = {}) {
async function main() {
const options = parseArgs(process.argv.slice(2));
try {
const machineOutput = options.json || Boolean(options.writePath);
const result = await runRemoteSmsLoginSmoke({ ...buildConfig(), jsonOutput: machineOutput }, { quiet: options.quiet || machineOutput });
const result = await runRemoteSmsLoginSmoke({ ...buildConfig(), jsonOutput: options.json }, { quiet: options.quiet || options.json });
if (options.writePath) {
const resolvedPath = path.resolve(process.cwd(), options.writePath);
fs.mkdirSync(path.dirname(resolvedPath), { recursive: true });