From 7b1d50adc48d6e072e124b9bc80d411c863b6e12 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Fri, 6 Dec 2024 18:00:20 -0800 Subject: [PATCH] feat: doctor checks for "set -e" in test scripts --- packages/synthetic-chain/src/cli/doctor.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/synthetic-chain/src/cli/doctor.ts b/packages/synthetic-chain/src/cli/doctor.ts index 597c3e92..53817e2f 100644 --- a/packages/synthetic-chain/src/cli/doctor.ts +++ b/packages/synthetic-chain/src/cli/doctor.ts @@ -4,8 +4,20 @@ import { ProposalInfo } from './proposals.js'; import assert from 'node:assert'; import { execSync } from 'node:child_process'; +const checkTestScript = (proposalPath: string) => { + const testScript = path.join(proposalPath, 'test.sh'); + if (fs.existsSync(testScript)) { + const content = fs.readFileSync(testScript, 'utf-8'); + assert( + content.includes('set -e'), + 'test.sh must include "set -e"; otherwise lines may fail silently. "set -euo pipefail" is recommended.', + ); + } +}; + const fixupProposal = (proposal: ProposalInfo) => { const proposalPath = path.join('proposals', proposal.path); + checkTestScript(proposalPath); const packageJson = JSON.parse( fs.readFileSync(path.join(proposalPath, 'package.json'), 'utf-8'), );