From dc6b9940054d28bc34652d0593034be1710a4c3d Mon Sep 17 00:00:00 2001 From: Chris Oakman Date: Fri, 8 Nov 2024 17:01:42 -0600 Subject: [PATCH] automatically write test JSON files to Standard Clojure Style Lua if present --- scripts/generate-test-json-files.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/generate-test-json-files.js b/scripts/generate-test-json-files.js index 0c57abb..7d9f61f 100755 --- a/scripts/generate-test-json-files.js +++ b/scripts/generate-test-json-files.js @@ -53,11 +53,23 @@ enoFilesInDir('test_parse_ns/').forEach((f) => { parseNsTestCases = parseNsTestCases.concat(testCases) }) -fs.removeSync('test_cases_json') -fs.makeTreeSync('test_cases_json') -fs.writeFileSync('test_cases_json/format_tests.json', JSON.stringify(formatTestCases, null, 2)) -fs.writeFileSync('test_cases_json/parser_tests.json', JSON.stringify(parserTestCases, null, 2)) -fs.writeFileSync('test_cases_json/parse_ns_tests.json', JSON.stringify(parseNsTestCases, null, 2)) +const writeFilesToLocalDir = false +if (writeFilesToLocalDir) { + fs.removeSync('test_cases_json') + fs.makeTreeSync('test_cases_json') + fs.writeFileSync('test_cases_json/format_tests.json', JSON.stringify(formatTestCases, null, 2)) + fs.writeFileSync('test_cases_json/parser_tests.json', JSON.stringify(parserTestCases, null, 2)) + fs.writeFileSync('test_cases_json/parse_ns_tests.json', JSON.stringify(parseNsTestCases, null, 2)) +} + +// copy the files to standard-clojure-style-lua/test_cases if it exists +const luaTestFilesDir = path.join(rootDir, '../standard-clojure-style-lua/test_cases') +if (fs.isDirectorySync(luaTestFilesDir)) { + fs.writeFileSync(path.join(luaTestFilesDir, 'format_tests.json'), JSON.stringify(formatTestCases, null, 2) + '\n') + fs.writeFileSync(path.join(luaTestFilesDir, 'parser_tests.json'), JSON.stringify(parserTestCases, null, 2) + '\n') + fs.writeFileSync(path.join(luaTestFilesDir, 'parse_ns_tests.json'), JSON.stringify(parseNsTestCases, null, 2) + '\n') + console.log('Wrote test files to ' + luaTestFilesDir) +} // ----------------------------------------------------------------------------- // Util