Download task_008/tests/validate_ui_behavior.js from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_008/tests/validate_ui_behavior.js
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_008/tests/validate_ui_behavior.js
-
curl -L -o validate_ui_behavior.js https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_008/tests/validate_ui_behavior.js
1.37 kB
| const fs = require('fs'); | |
| const os = require('os'); | |
| const path = require('path'); | |
| const cp = require('child_process'); | |
| (async () => { | |
| const converter = path.join(process.cwd(), 'convert.js'); | |
| const samples = path.join(process.cwd(), 'samples'); | |
| if (!fs.existsSync(converter) || !fs.existsSync(samples)) throw Error('convert.js and samples are required'); | |
| const output = fs.mkdtempSync(path.join(os.tmpdir(), 'ux009-api-')); | |
| try { | |
| const mod = require(converter); | |
| if (typeof mod.convertBatch !== 'function') throw Error('convert.js must export convertBatch'); | |
| await mod.convertBatch(samples, output); | |
| const pdf = path.join(output, 'math.pdf'); | |
| for (const [command, args] of [['pdfinfo', [pdf]], ['pdftotext', [pdf, '-']]]) { | |
| const result = cp.spawnSync(command, args, {encoding: 'utf8', timeout: 15000}); | |
| if (result.status !== 0) throw Error(`${command} rejected PDF: ${result.stderr}`); | |
| if (command === 'pdftotext') { | |
| if (!/(√2|sqrt\(?2\)?)/i.test(result.stdout.replace(/\s/g, ''))) throw Error('rendered sqrt(2) is missing'); | |
| if (/\\sqrt|\\\(|\\\)/.test(result.stdout)) throw Error('raw LaTeX is visible'); | |
| } | |
| } | |
| console.log('Parsed batch PDF export passed'); | |
| } finally { fs.rmSync(output, {recursive: true, force: true}); } | |
| })().catch(error => { console.error(error); process.exit(1); }); | |