From a1d46dca3ff89ddc32219beaaa9f78a6edd38f36 Mon Sep 17 00:00:00 2001 From: David Smadja <david.smadja@assemblee-nationale.fr> Date: Mon, 31 Mar 2025 11:37:31 +0200 Subject: [PATCH] Adjust max_spiral_loop --- src/scripts/generate_openfisca_tests_yaml.ts | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/scripts/generate_openfisca_tests_yaml.ts b/src/scripts/generate_openfisca_tests_yaml.ts index 369309bd4..fae7ddefd 100644 --- a/src/scripts/generate_openfisca_tests_yaml.ts +++ b/src/scripts/generate_openfisca_tests_yaml.ts @@ -726,6 +726,47 @@ async function main() { console.error(error) } } + + console.info("Adjusting max_spiral_loop") + while (ok && jsonForYamlOutput.max_spiral_loops > 1) { + jsonForYamlOutput.max_spiral_loops = + jsonForYamlOutput.max_spiral_loops - 1 + const yamlOutput = YAML.dump(jsonForYamlOutput, { + noCompatMode: true, + noRefs: true, + }) + const cleanedYaml = yamlOutput.replace(/'(\d{4})':/g, "$1:") + + await fs.writeFile(path.join(outdir, testCase.id + ".yml"), cleanedYaml) + + try { + const openFiscaTestResult = await runOpenFiscaTest( + openFiscaVenvPath, + path.join(outdir, testCase.id + ".yml"), + ) + if (!openFiscaTestResult.passed) { + ok = false + jsonForYamlOutput.max_spiral_loops = + jsonForYamlOutput.max_spiral_loops + 1 + const yamlOutput = YAML.dump(jsonForYamlOutput, { + noCompatMode: true, + noRefs: true, + }) + const cleanedYaml = yamlOutput.replace(/'(\d{4})':/g, "$1:") + + await fs.writeFile( + path.join(outdir, testCase.id + ".yml"), + cleanedYaml, + ) + console.info("YAML file written :", outdir, testCase.id + ".yml") + } else { + ok = true + } + } catch (error) { + console.error(error) + } + } + console.info("Processed test-case", processedCounter, "over", testCaseCount) } } -- GitLab