Skip to content

Commit

Permalink
tests ~ add bmp style testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Nov 5, 2023
1 parent 84c2933 commit cff01d1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/$shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,35 @@ export const test = createTestFn();

//===

// [`bmp`](https://deno.land/x/[email protected]); install (for Deno-v1.11+/[email protected]) <br> `dxi --allow-read=. --allow-write=. --allow-run=git -qf https://deno.land/x/[email protected]/cli.ts`

export const haveBmpVersion = () => {
try {
// deno-lint-ignore no-deprecated-deno-api
const process = Deno.run({
cmd: [...(isWinOS ? ['cmd', '/x/d/c'] : []), 'bmp', '--version'],
stdin: 'null',
stderr: 'null',
stdout: 'piped',
});
return Promise
.all([process.status(), process.output()])
.then(([status, out]) => {
// console.debug({ status: status, out: decode(out) });
return (status.success
? ((decode(out)?.match(/(?:^|@)(\d+(?:[.]\d+)+)/) || [])[1])
: undefined);
})
.finally(() => process.close());
} catch (_) {
return Promise.resolve(undefined);
}
};

export const haveBmp = () => {
return haveBmpVersion().then((version) => version != null);
};

// [`commitlint`](https://commitlint.js.org); install (for NodeJS v12+): `npm -g install @commitlint/cli@16 @commitlint/config-conventional@16`

export const haveCommitLintVersion = () => {
Expand Down
29 changes: 29 additions & 0 deletions tests/00.project.style.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// import { $colors } from './$deps.ts';
import { $args, $path, assert, assertEquals, equal } from './$deps.ts';
import {
haveBmp,
haveCommitLint,
haveCSpell,
haveCSpellVersion,
Expand Down Expand Up @@ -137,6 +138,34 @@ const projectNonBinaryFiles = projectFiles.filter((file) =>
// console.warn({ projectFiles, projectDirs });
// console.warn({ projectPath, projectDirs });

{
// ToDO: [2023-10-10; rivy] deal with CWD != projectPath
const command = 'bmp';
const haveCommand = await haveBmp();
const exeArgs = ['--info'];
const exeCmd = [command, ...exeArgs].join(' ');
const cmd = [...(isWinOS ? ['cmd', '/x/d/c'] : []), exeCmd];
const description = `style ~ \`${exeCmd}\``;
if (!haveCommand) {
test.skip(description + `...skipped (\`${command}\` not found)`);
} else {
test(description, async () => {
// deno-lint-ignore no-deprecated-deno-api
const p = Deno.run({ cmd, stdin: 'null', stdout: 'piped', stderr: 'piped' });
const [status, out, err] = await Promise
.all([p.status(), p.output(), p.stderrOutput()])
.finally(() => p.close());
// console.debug({ status, stdout: decode(out), stderr: decode(err) });
if (!status.success) {
console.warn(`\`${command}\` status`, status);
console.warn(decode(out).replace(/\r?\n$/ms, ''));
console.warn(decode(err).replace(/\r?\n$/ms, ''));
}
assert(status.success, `\`${command}\` check succeeds`);
});
}
}

{
// ToDO: [2023-10-03; rivy] add `--cwd <projectPath>` to commitlint command (as needed, if CWD != projectPath)
// ToDO: [2023-10-03; rivy] check for correct configuration; present and working config file (including plugins; may use `commitlint --config .commitlint.config.js --print-config`)
Expand Down

0 comments on commit cff01d1

Please sign in to comment.