Skip to content

Commit

Permalink
Test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Oct 17, 2023
1 parent 28a270c commit 7dfb596
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/bundle/html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import {describe, it} from 'node:test';
import {ok} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {fixtureFile} from '../util.spec';
import {cleanBundlesDir, fixtureFile} from '../util.spec';
import {Bundle} from '../bundle';

import {cleanBundlesDir} from './otto.spec';
import {BundleHtml} from './html';

const getDir = async (d: string) => cleanBundlesDir('html', d);
Expand Down
11 changes: 1 addition & 10 deletions src/bundle/otto.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import {basename, dirname, join as pathJoin} from 'node:path';
import {mkdir, rm, writeFile} from 'node:fs/promises';
import {mkdir, writeFile} from 'node:fs/promises';

import {trimExtension} from '../util';
import {ProjectorOttoDummy} from '../projector/otto.spec';

import {BundleOtto} from './otto';

export const specBundlesPath = pathJoin('spec', 'bundles');

export async function cleanBundlesDir(...path: string[]) {
const dir = pathJoin(specBundlesPath, ...path);
await rm(dir, {recursive: true, force: true});
await mkdir(dir, {recursive: true});
return dir;
}

export class BundleOttoDummy extends BundleOtto {
public readonly projector: ProjectorOttoDummy;

Expand Down
4 changes: 2 additions & 2 deletions src/bundle/otto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {join as pathJoin, dirname} from 'node:path';

import {fsLchmod, fsLutimes} from '@shockpkg/archive-files';

import {fixtureFile} from '../util.spec';
import {cleanBundlesDir, fixtureFile} from '../util.spec';
import {Bundle} from '../bundle';

import {BundleOttoDummy, cleanBundlesDir} from './otto.spec';
import {BundleOttoDummy} from './otto.spec';
import {BundleOtto} from './otto';

const getDir = async (d: string) => cleanBundlesDir('otto', 'dummy', d);
Expand Down
3 changes: 1 addition & 2 deletions src/bundle/otto/mac.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {ok} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {listSamples} from '../../projector/otto/mac.spec';
import {cleanBundlesDir} from '../otto.spec';
import {fixtureFile, getPackageFile} from '../../util.spec';
import {cleanBundlesDir, fixtureFile, getPackageFile} from '../../util.spec';
import {BundleOtto} from '../otto';

import {BundleOttoMac} from './mac';
Expand Down
3 changes: 1 addition & 2 deletions src/bundle/otto/windows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {ok} from 'node:assert';
import {join as pathJoin} from 'node:path';

import {listSamples, versionStrings} from '../../projector/otto/windows.spec';
import {cleanBundlesDir} from '../otto.spec';
import {fixtureFile, getPackageFile} from '../../util.spec';
import {cleanBundlesDir, fixtureFile, getPackageFile} from '../../util.spec';
import {BundleOtto} from '../otto';

import {BundleOttoWindows} from './windows';
Expand Down
8 changes: 8 additions & 0 deletions src/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function shouldTest(name: string) {

export const specFixturesPath = pathJoin('spec', 'fixtures');
export const specProjectorsPath = pathJoin('spec', 'projectors');
export const specBundlesPath = pathJoin('spec', 'bundles');

export function fixtureFile(name: string) {
return pathJoin(specFixturesPath, name);
Expand All @@ -32,6 +33,13 @@ export async function cleanProjectorDir(...path: string[]) {
return dir;
}

export async function cleanBundlesDir(...path: string[]) {
const dir = pathJoin(specBundlesPath, ...path);
await rm(dir, {recursive: true, force: true});
await mkdir(dir, {recursive: true});
return dir;
}

let getInstalledPackagesCache: string[] | null = null;
export function getInstalledPackagesSync() {
if (!getInstalledPackagesCache) {
Expand Down

0 comments on commit 7dfb596

Please sign in to comment.