From b952a82d29661995d75c476501f977b716860e58 Mon Sep 17 00:00:00 2001 From: Francisco Date: Wed, 8 Mar 2023 18:16:37 -0300 Subject: [PATCH] Throw error when requested specs are not found (#4101) --- certora/run.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/certora/run.js b/certora/run.js index 161465258..172309e19 100644 --- a/certora/run.js +++ b/certora/run.js @@ -8,7 +8,7 @@ const MAX_PARALLEL = 4; -const specs = require(__dirname + '/specs.json'); +let specs = require(__dirname + '/specs.json'); const proc = require('child_process'); const { PassThrough } = require('stream'); @@ -20,12 +20,18 @@ if (request.startsWith('-')) { extraOptions.unshift(request); request = ''; } -const [reqSpec, reqContract] = request.split(':').reverse(); + +if (request) { + const [reqSpec, reqContract] = request.split(':').reverse(); + specs = Object.values(specs).filter(s => reqSpec === s.spec && (!reqContract || reqContract === s.contract)); + if (specs.length === 0) { + console.error(`Error: Requested spec '${request}' not found in specs.json`); + process.exit(1); + } +} for (const { spec, contract, files, options = [] } of Object.values(specs)) { - if ((!reqSpec || reqSpec === spec) && (!reqContract || reqContract === contract)) { - limit(runCertora, spec, contract, files, [...options, ...extraOptions]); - } + limit(runCertora, spec, contract, files, [...options, ...extraOptions]); } // Run certora, aggregate the output and print it at the end