Skip to content

Commit

Permalink
automatically write test JSON files to Standard Clojure Style Lua if …
Browse files Browse the repository at this point in the history
…present
  • Loading branch information
oakmac committed Nov 8, 2024
1 parent c86df4b commit dc6b994
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions scripts/generate-test-json-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc6b994

Please sign in to comment.