Skip to content

Commit

Permalink
ci: fix c8 false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel committed May 19, 2024
1 parent 82db5ee commit cd83dfb
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 25 deletions.
10 changes: 1 addition & 9 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
{
"all": true,
"include": ["src/**"],
"exclude": [
"ci",
"src/@types/**",
"fixtures",
"lib",
"test",
"tools",
"website"
],
"exclude": ["ci", "fixtures", "lib", "test", "tools", "website"],
"extension": ["ts"],
"reporter": ["text", "lcov", "cobertura"],
"clean": true,
Expand Down
4 changes: 4 additions & 0 deletions src/@types/background-process.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* c8 ignore start */

import { Runner } from './runner.js';
import { Configs } from './poku.js';

Expand Down Expand Up @@ -48,3 +50,5 @@ export type StartServiceOptions = {
} & BackgroundProcessOptions;

export type End = (port?: number | number[]) => Promise<void>;

/* c8 ignore stop */
4 changes: 4 additions & 0 deletions src/@types/code.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/* c8 ignore start */

export type Code = 0 | 1;

/* c8 ignore stop */
9 changes: 9 additions & 0 deletions src/@types/list-files.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* c8 ignore start */

export type Configs = {
/**
* Filter by path to match only the files that should be performed.
Expand All @@ -12,3 +14,10 @@ export type Configs = {
*/
exclude?: RegExp | RegExp[];
};

export type FileResults = {
success: string[];
fail: string[];
};

/* c8 ignore stop */
4 changes: 4 additions & 0 deletions src/@types/poku.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* c8 ignore start */

import type { Configs as ListFilesConfigs } from './list-files.js';

export type Configs = {
Expand Down Expand Up @@ -92,3 +94,5 @@ export type Configs = {
*/
afterEach?: () => unknown | Promise<unknown>;
} & ListFilesConfigs;

/* c8 ignore stop */
4 changes: 4 additions & 0 deletions src/@types/runner.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/* c8 ignore start */

export type Runner = 'npm' | 'bun' | 'deno' | 'yarn' | 'pnpm';

/* c8 ignore stop */
2 changes: 2 additions & 0 deletions src/configs/each.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* c8 ignore start */

export type Control = {
pause: () => void;
continue: () => void;
Expand Down Expand Up @@ -29,4 +30,5 @@ export const each: {
test: true,
},
};

/* c8 ignore stop */
10 changes: 10 additions & 0 deletions src/configs/files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* c8 ignore start */

import { FileResults } from '../@types/list-files.js';

export const fileResults: FileResults = {
success: [],
fail: [],
};

/* c8 ignore stop */
2 changes: 2 additions & 0 deletions src/configs/indentation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* c8 ignore start */

export const indentation = {
test: ' ',
stdio: ' ',
};

/* c8 ignore stop */
1 change: 1 addition & 0 deletions src/modules/each.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* c8 ignore next */
import { Control, each } from '../configs/each.js';

/* c8 ignore start */
Expand Down
5 changes: 3 additions & 2 deletions src/modules/poku.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* c8 ignore start */

/**
* Both CLI, API, noExit, sequential and parallel runs are strictly tested, but these tests use deep child process for it
*/

/* c8 ignore start */
import { EOL } from 'node:os';
import { Code } from '../@types/code.js';
import { Configs } from '../@types/poku.js';
Expand All @@ -12,7 +13,7 @@ import { exit } from './exit.js';
import { format } from '../helpers/format.js';
import { isQuiet } from '../helpers/logs.js';
import { hr } from '../helpers/hr.js';
import { fileResults } from '../services/run-test-file.js';
import { fileResults } from '../configs/files.js';
import { indentation } from '../configs/indentation.js';

export async function poku(
Expand Down
3 changes: 3 additions & 0 deletions src/modules/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* c8 ignore next */
import { each } from '../configs/each.js';

export async function test(cb: () => Promise<unknown>): Promise<void>;
Expand All @@ -7,6 +8,7 @@ export async function test(
): Promise<void> {
if (typeof each.before.cb === 'function' && each.before.test) {
const beforeResult = each.before.cb();
/* c8 ignore next */
if (beforeResult instanceof Promise) await beforeResult;
}

Expand All @@ -16,6 +18,7 @@ export async function test(

if (typeof each.after.cb === 'function' && each.after.test) {
const afterResult = each.after.cb();
/* c8 ignore next */
if (afterResult instanceof Promise) await afterResult;
}
}
15 changes: 1 addition & 14 deletions src/services/run-test-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,7 @@ import { Configs } from '../@types/poku.js';
import { isDebug, isQuiet } from '../helpers/logs.js';
import { removeConsecutiveRepeats } from '../helpers/remove-repeats.js';
import { beforeEach, afterEach } from './each.js';

/* c8 ignore start */
export type FileResults = {
success: string[];
fail: string[];
};
/* c8 ignore stop */

/* c8 ignore start */
export const fileResults: FileResults = {
success: [],
fail: [],
};
/* c8 ignore stop */
import { fileResults } from '../configs/files.js';

export const runTestFile = (
filePath: string,
Expand Down

0 comments on commit cd83dfb

Please sign in to comment.