Skip to content

Commit

Permalink
test: remove flaky-integration-test related tooling
Browse files Browse the repository at this point in the history
- Tests have been stable for months now
  • Loading branch information
AriPerkkio committed Sep 19, 2021
1 parent db32068 commit 1dc90d8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 67 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/check-flaky-integration-tests.yml

This file was deleted.

3 changes: 1 addition & 2 deletions test/integration/jest.setup.integration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { addFailureLogger, clearRepositoryCache } from '../utils';
import { clearRepositoryCache } from '../utils';

jest.setTimeout(15000);
addFailureLogger();

beforeEach(async () => {
clearRepositoryCache();
Expand Down
3 changes: 1 addition & 2 deletions test/smoke/jest.setup.smoke.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { addFailureLogger, clearRepositoryCache } from '../utils';
import { clearRepositoryCache } from '../utils';

jest.setTimeout(300000);
addFailureLogger();

beforeEach(async () => {
clearRepositoryCache();
Expand Down
38 changes: 0 additions & 38 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fs from 'fs';
import { spawn } from 'node-pty';
import stripAnsi from 'strip-ansi';
import { Jasmine } from 'jest-jasmine2/build/index.d';
import { Reporter } from 'jest-jasmine2/build/types.d';

import {
CACHE_LOCATION,
Expand All @@ -14,7 +12,6 @@ import { removeDirectorySync } from '@file-client/file-utils';
import { Config, ConfigToValidate } from '@config/types';

declare const console: { log: jest.Mock; error: (...args: any) => void };
declare const jasmine: Jasmine;

export const INTEGRATION_REPO_OWNER = 'AriPerkkio';
export const INTEGRATION_REPO_NAME =
Expand All @@ -27,7 +24,6 @@ const ON_COMPLETE_PATTERN = /("onComplete": )"([\s|\S]*)"/;
const RULES_UNDER_TESTING_PATTERN = /("rulesUnderTesting": )"([\s|\S]*)",/;
const ESLINTRC_PATTERN = /("eslintrc": )"([\s|\S]*)",/;
const ESCAPED_NEWLINE_PATTERN = /\\n/g;
const DEBUG_LOG = '/tmp/test.debug.log';

let idCounter = 0;

Expand Down Expand Up @@ -77,12 +73,6 @@ export async function runProductionBuild(
const { name, cleanup } = createConfiguration(options, baseConfigPath);

return new Promise((resolve, reject) => {
if (fs.existsSync(DEBUG_LOG)) fs.unlinkSync(DEBUG_LOG);

const debugStream = fs.createWriteStream(DEBUG_LOG, {
encoding: 'utf8',
});

const ptyProcess = spawn('node', ['dist', '--config', name], {
cwd: process.cwd(),
encoding: 'utf8',
Expand All @@ -100,12 +90,10 @@ export async function runProductionBuild(
});
const output: string[] = [];
ptyProcess.onData(data => {
debugStream.write(stripAnsi(data));
output.push(data);
});

ptyProcess.onExit(({ exitCode }) => {
debugStream.end();
cleanup();

const parsedOutput = parsePtyOutput(output);
Expand Down Expand Up @@ -210,32 +198,6 @@ export function getComparisonResults(
);
}

/**
* Logs output of node-pty when a test fails.
* Used to debug flaky integration/smoke tests.
*/
export function addFailureLogger(): void {
const specDone: Reporter['specDone'] = async result => {
if (result.status === 'failed') {
if (!fs.existsSync(DEBUG_LOG)) {
return console.error('Debug log missing');
}

const logContent = fs.readFileSync(DEBUG_LOG, 'utf8');
console.log(
[
`Debug log content of "${result.description}"`,
'*********',
logContent,
'*********',
].join('\n')
);
}
};

jasmine.getEnv().addReporter({ specDone });
}

/**
* Get last call arguments of given mocked callback
* - Returns array incase of multiple call arguments
Expand Down

0 comments on commit 1dc90d8

Please sign in to comment.