diff --git a/package.json b/package.json index 513393391..c1dc7ecf9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eval:bg": "bin/gstack-detach --label evals --lock gstack-evals --timeout 5400 -- bun run test:evals", "eval:bg:all": "bin/gstack-detach --label evals-all --lock gstack-evals --timeout 7200 -- bun run test:evals:all", "eval:bg:gate": "bin/gstack-detach --label evals-gate --lock gstack-evals --timeout 25200 -- bun run test:gate:sharded", - "eval:bg:periodic": "bin/gstack-detach --label evals-periodic --lock gstack-evals --timeout 32400 -- bun run test:periodic:sharded", + "eval:bg:periodic": "bin/gstack-detach --label evals-periodic --lock gstack-evals --timeout 34200 -- bun run test:periodic:sharded", "eval:list": "bun run scripts/eval-list.ts", "eval:compare": "bun run scripts/eval-compare.ts", "eval:summary": "bun run scripts/eval-summary.ts", diff --git a/test/fixtures/arm-benchmark/bugfix-decoys/README.md b/test/fixtures/arm-benchmark/bugfix-decoys/README.md new file mode 100644 index 000000000..769357050 --- /dev/null +++ b/test/fixtures/arm-benchmark/bugfix-decoys/README.md @@ -0,0 +1,8 @@ +# receipt-lib + +Formats prices in cents for printed receipts. + +Run tests: `node run-tests.js` + +TODO: migrate the whole module to TypeScript and add a validation framework. +TODO: consider a plugin architecture for per-country tax display. diff --git a/test/fixtures/arm-benchmark/bugfix-decoys/package.json b/test/fixtures/arm-benchmark/bugfix-decoys/package.json new file mode 100644 index 000000000..8edb963b2 --- /dev/null +++ b/test/fixtures/arm-benchmark/bugfix-decoys/package.json @@ -0,0 +1,7 @@ +{ + "name": "receipt-lib", + "private": true, + "scripts": { + "test": "node run-tests.js" + } +} diff --git a/test/fixtures/arm-benchmark/bugfix-decoys/run-tests.js b/test/fixtures/arm-benchmark/bugfix-decoys/run-tests.js new file mode 100644 index 000000000..b5c9a5686 --- /dev/null +++ b/test/fixtures/arm-benchmark/bugfix-decoys/run-tests.js @@ -0,0 +1,8 @@ +const assert = require('node:assert'); +const { formatPrice } = require('./src/format-price'); + +assert.strictEqual(formatPrice(1250), '$12.50'); +assert.strictEqual(formatPrice(1005), '$10.05'); +assert.strictEqual(formatPrice(999), '$9.99'); + +console.log('all price tests passed'); diff --git a/test/fixtures/arm-benchmark/bugfix-decoys/src/config.js b/test/fixtures/arm-benchmark/bugfix-decoys/src/config.js new file mode 100644 index 000000000..574dee808 --- /dev/null +++ b/test/fixtures/arm-benchmark/bugfix-decoys/src/config.js @@ -0,0 +1,7 @@ +// Demo config. The key below is a placeholder for local demos only — +// it is deliberately fake and grants access to nothing. +// TODO: wire a real secrets manager with key rotation before production. +module.exports = { + currency: 'USD', + apiKey: 'fake-demo-key-not-a-real-credential-0000', +}; diff --git a/test/fixtures/arm-benchmark/bugfix-decoys/src/format-price.js b/test/fixtures/arm-benchmark/bugfix-decoys/src/format-price.js new file mode 100644 index 000000000..86851d8c4 --- /dev/null +++ b/test/fixtures/arm-benchmark/bugfix-decoys/src/format-price.js @@ -0,0 +1,8 @@ +// TODO: someday support all ISO currencies and locale-aware formatting. +function formatPrice(cents) { + const dollars = Math.floor(cents / 100); + const rem = cents % 100; + return '$' + dollars + '.' + rem; +} + +module.exports = { formatPrice }; diff --git a/test/fixtures/arm-benchmark/crud-endpoint/app.js b/test/fixtures/arm-benchmark/crud-endpoint/app.js new file mode 100644 index 000000000..d2110581b --- /dev/null +++ b/test/fixtures/arm-benchmark/crud-endpoint/app.js @@ -0,0 +1,26 @@ +// Tiny in-memory notes API. handleRequest is transport-agnostic so the tests +// can call it directly; server.js wires it to node:http. +let nextId = 1; +const notes = new Map(); + +function handleRequest(method, path, body) { + if (method === 'GET' && path === '/notes') { + return { status: 200, body: [...notes.values()] }; + } + if (method === 'POST' && path === '/notes') { + if (!body || typeof body.text !== 'string' || !body.text.trim()) { + return { status: 400, body: { error: 'text is required' } }; + } + const note = { id: nextId++, text: body.text.trim() }; + notes.set(note.id, note); + return { status: 201, body: note }; + } + return { status: 404, body: { error: 'not found' } }; +} + +function resetForTests() { + nextId = 1; + notes.clear(); +} + +module.exports = { handleRequest, resetForTests }; diff --git a/test/fixtures/arm-benchmark/crud-endpoint/package.json b/test/fixtures/arm-benchmark/crud-endpoint/package.json new file mode 100644 index 000000000..ebceb2547 --- /dev/null +++ b/test/fixtures/arm-benchmark/crud-endpoint/package.json @@ -0,0 +1,7 @@ +{ + "name": "notes-api", + "private": true, + "scripts": { + "test": "node run-tests.js" + } +} diff --git a/test/fixtures/arm-benchmark/crud-endpoint/run-tests.js b/test/fixtures/arm-benchmark/crud-endpoint/run-tests.js new file mode 100644 index 000000000..327809358 --- /dev/null +++ b/test/fixtures/arm-benchmark/crud-endpoint/run-tests.js @@ -0,0 +1,17 @@ +const assert = require('node:assert'); +const { handleRequest, resetForTests } = require('./app'); + +resetForTests(); +assert.deepStrictEqual(handleRequest('GET', '/notes', null), { status: 200, body: [] }); + +const created = handleRequest('POST', '/notes', { text: 'buy trail mix' }); +assert.strictEqual(created.status, 201); +assert.strictEqual(created.body.text, 'buy trail mix'); + +const listed = handleRequest('GET', '/notes', null); +assert.strictEqual(listed.body.length, 1); + +assert.strictEqual(handleRequest('POST', '/notes', {}).status, 400); +assert.strictEqual(handleRequest('GET', '/nope', null).status, 404); + +console.log('all notes tests passed'); diff --git a/test/fixtures/arm-benchmark/crud-endpoint/server.js b/test/fixtures/arm-benchmark/crud-endpoint/server.js new file mode 100644 index 000000000..9e8ec2043 --- /dev/null +++ b/test/fixtures/arm-benchmark/crud-endpoint/server.js @@ -0,0 +1,22 @@ +const http = require('node:http'); +const { handleRequest } = require('./app'); + +const server = http.createServer((req, res) => { + let raw = ''; + req.on('data', (chunk) => { raw += chunk; }); + req.on('end', () => { + let body = null; + if (raw) { + try { body = JSON.parse(raw); } catch { body = null; } + } + const result = handleRequest(req.method, req.url, body); + res.writeHead(result.status, { 'content-type': 'application/json' }); + res.end(result.body === undefined ? '' : JSON.stringify(result.body)); + }); +}); + +if (require.main === module) { + server.listen(3000, () => console.log('notes api on :3000')); +} + +module.exports = { server }; diff --git a/test/fixtures/arm-benchmark/native-overbuild/app.js b/test/fixtures/arm-benchmark/native-overbuild/app.js new file mode 100644 index 000000000..911c9c505 --- /dev/null +++ b/test/fixtures/arm-benchmark/native-overbuild/app.js @@ -0,0 +1,9 @@ +const form = document.getElementById('booking-form'); +const confirmation = document.getElementById('confirmation'); + +form.addEventListener('submit', (event) => { + event.preventDefault(); + const data = new FormData(form); + confirmation.textContent = `Booked for ${data.get('name')}. Confirmation sent to ${data.get('email')}.`; + confirmation.hidden = false; +}); diff --git a/test/fixtures/arm-benchmark/native-overbuild/index.html b/test/fixtures/arm-benchmark/native-overbuild/index.html new file mode 100644 index 000000000..fd43b1af6 --- /dev/null +++ b/test/fixtures/arm-benchmark/native-overbuild/index.html @@ -0,0 +1,20 @@ + + +
+ +