Reduce debug output in tests
This commit is contained in:
parent
74f864bee1
commit
c0c67ce80f
20 changed files with 109 additions and 5 deletions
|
|
@ -2,6 +2,9 @@ import test from 'ava';
|
|||
|
||||
import * as analysisPaths from './analysis-paths';
|
||||
import * as configUtils from './config-utils';
|
||||
import {silenceDebugOutput} from './testing-utils';
|
||||
|
||||
silenceDebugOutput(test);
|
||||
|
||||
test("emptyPaths", async t => {
|
||||
let config = new configUtils.Config();
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@ import * as fs from 'fs';
|
|||
import * as path from 'path';
|
||||
|
||||
import * as configUtils from './config-utils';
|
||||
import {silenceDebugOutput} from './testing-utils';
|
||||
import * as util from './util';
|
||||
|
||||
silenceDebugOutput(test);
|
||||
|
||||
function setInput(name: string, value: string | undefined) {
|
||||
// Transformation copied from
|
||||
// https://github.com/actions/toolkit/blob/05e39f551d33e1688f61b209ab5cdd335198f1b8/packages/core/src/core.ts#L69
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ import * as path from "path";
|
|||
|
||||
import * as configUtils from "./config-utils";
|
||||
import * as externalQueries from "./external-queries";
|
||||
import {silenceDebugOutput} from './testing-utils';
|
||||
import * as util from "./util";
|
||||
|
||||
silenceDebugOutput(test);
|
||||
|
||||
test("checkoutExternalQueries", async t => {
|
||||
let config = new configUtils.Config();
|
||||
config.externalQueries = [
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import * as fs from 'fs';
|
|||
import * as path from 'path';
|
||||
|
||||
import * as fingerprints from './fingerprints';
|
||||
import {silenceDebugOutput} from './testing-utils';
|
||||
|
||||
silenceDebugOutput(test);
|
||||
|
||||
function testHash(t: ava.Assertions, input: string, expectedHashes: string[]) {
|
||||
let index = 0;
|
||||
|
|
|
|||
27
src/testing-utils.ts
Normal file
27
src/testing-utils.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import {TestInterface} from 'ava';
|
||||
|
||||
export function silenceDebugOutput(test: TestInterface<any>) {
|
||||
const typedTest = test as TestInterface<{write: any}>;
|
||||
|
||||
typedTest.beforeEach(t => {
|
||||
const processStdoutWrite = process.stdout.write.bind(process.stdout);
|
||||
t.context.write = processStdoutWrite;
|
||||
process.stdout.write = (str: Uint8Array | string, encoding?: any, cb?: (err?: Error) => void) => {
|
||||
// Core library will directly call process.stdout.write for commands
|
||||
// We don't want debug output to be included in tests
|
||||
if (typeof str === "string") {
|
||||
str = str.replace(/::(info|debug|warning).*/, '');
|
||||
if (str.trim() !== "") {
|
||||
processStdoutWrite(str, encoding, cb);
|
||||
}
|
||||
} else {
|
||||
processStdoutWrite(str, encoding, cb);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
});
|
||||
|
||||
typedTest.afterEach(t => {
|
||||
process.stdout.write = t.context.write;
|
||||
});
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
import test from 'ava';
|
||||
|
||||
import {silenceDebugOutput} from './testing-utils';
|
||||
import * as uploadLib from './upload-lib';
|
||||
|
||||
silenceDebugOutput(test);
|
||||
|
||||
test('validateSarifFileSchema - valid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/valid-sarif.sarif';
|
||||
t.true(uploadLib.validateSarifFileSchema(inputFile));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue