Skip to content

Commit

Permalink
chore(tests): Fix broken validation script
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Jan 1, 2025
1 parent eb504ba commit ccd0737
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
24 changes: 0 additions & 24 deletions scripts/spawn-async.ts

This file was deleted.

30 changes: 28 additions & 2 deletions test/validate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { glob, mkdtemp, readFile, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { spawn } from 'node:child_process';
import { basename, join, sep } from 'node:path';
import { tmpdir } from 'node:os';
import test from 'ava';
import { read, write } from 'ktx-parse';
import { type SpawnResult, spawnAsync } from '../scripts/spawn-async.js';

const tmpDir = await mkdtemp(`${tmpdir()}${sep}`);

Expand All @@ -25,3 +25,29 @@ for await (const srcPath of glob(join('test', 'data', 'reference', '*.ktx2'))) {
t.pass('ok');
});
}

///////////////////////////////////////////////////////////////////////////////
// UTILITIES

type SpawnResult = { code: number; stdout: string; stderr: string };

function spawnAsync(command: string, args: string[]): Promise<SpawnResult> {
return new Promise((resolve) => {
const p = spawn(command, args);

let stdout = '';
let stderr = '';

p.stdout.on('data', (x) => {
stdout += x.toString();
});

p.stderr.on('data', (x) => {
stderr += x.toString();
});

p.on('exit', (code) => {
resolve({ code: code ?? 0, stdout, stderr });
});
});
}

0 comments on commit ccd0737

Please sign in to comment.