экономика
This commit is contained in:
1 parent
296988b199
commit
58ae93f9e6
28 files changed
+6503
-299
No files matched your search
@@ -0,0 +1,28 @@
|
||||
// Тесты экономики в открытом Studio (Rojo подключён): node tools/run-tests.js [имя]
|
||||
// Каждый tests/*.spec.lua выполняется в Edit-режиме через Studio MCP вместе с tests/lib.lua.
|
||||
// Код плейса не меняется: модули клонируются во временную папку ServerStorage и удаляются после прогона.
|
||||
const { execFileSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const tests = path.join(root, 'tests');
|
||||
const only = process.argv[2];
|
||||
const lib = fs.readFileSync(path.join(tests, 'lib.lua'), 'utf8').replace(/^/, '');
|
||||
const specs = fs.readdirSync(tests).filter(f => f.endsWith('.spec.lua') && (!only || f.includes(only)));
|
||||
const outDir = path.join(tests, '.out');
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
const steps = specs.map(f => ({
|
||||
tool: 'execute_luau',
|
||||
args: {
|
||||
datamodel_type: 'Edit',
|
||||
code: 'local T = (function()\n' + lib + '\nend)()\n' + fs.readFileSync(path.join(tests, f), 'utf8').replace(/^/, ''),
|
||||
},
|
||||
}));
|
||||
const stepsFile = path.join(outDir, 'steps.json');
|
||||
fs.writeFileSync(stepsFile, JSON.stringify(steps));
|
||||
const out = execFileSync('node', [path.join(__dirname, 'mcp', 'run.js'), stepsFile], { maxBuffer: 1 << 26 }).toString('utf8');
|
||||
process.stdout.write(out + '\n');
|
||||
const failed = [...out.matchAll(/(\d+) passed, (\d+) failed/g)];
|
||||
const bad = failed.length < specs.length || failed.some(m => m[2] !== '0') || /\(ERROR\)/.test(out);
|
||||
console.log(bad ? 'TESTS FAILED' : `ALL ${specs.length} SUITES PASSED`);
|
||||
process.exit(bad ? 1 : 0);
|
||||
Reference in new issue
Block a user