Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: skip mercurial tests when no hg installed #9840

Merged
merged 8 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {ExecaReturnValue, sync as spawnSync} from 'execa';
import makeDir = require('make-dir');
import rimraf = require('rimraf');
import dedent = require('dedent');
import which = require('which');

interface RunResult extends ExecaReturnValue {
status: number;
Expand Down Expand Up @@ -260,3 +261,7 @@ export const normalizeIcons = (str: string) => {
.replace(new RegExp('\u00D7', 'g'), '\u2715')
.replace(new RegExp('\u221A', 'g'), '\u2713');
};

// Certain environments (like CITGM and GH Actions) do not come with mercurial installed
export const hgIsInstalled = which.sync('hg', {nothrow: true}) !== null;
export const testIfHg = hgIsInstalled ? test : test.skip;
SimenB marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 1 addition & 6 deletions e2e/__tests__/jestChangedFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {findRepos, getChangedFilesForRoots} from 'jest-changed-files';
import {skipSuiteOnWindows} from '@jest/test-utils';
import which = require('which');
import {cleanup, run, writeFiles} from '../Utils';
import {cleanup, hgIsInstalled, run, testIfHg, writeFiles} from '../Utils';
import runJest from '../runJest';

skipSuiteOnWindows();
Expand All @@ -24,10 +23,6 @@ const HG = 'hg --config ui.username=jest_test';
beforeEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));

// Certain environments (like CITGM and GH Actions) do not come with mercurial installed
const hgIsInstalled = which.sync('hg', {nothrow: true}) !== null;
const testIfHg = hgIsInstalled ? test : test.skip;

if (!hgIsInstalled) {
console.warn('Mercurial (hg) is not installed - skipping some tests');
}
Expand Down
8 changes: 6 additions & 2 deletions e2e/__tests__/onlyChanged.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {tmpdir} from 'os';
import * as path from 'path';
import runJest from '../runJest';
import {cleanup, run, writeFiles} from '../Utils';
import {cleanup, hgIsInstalled, run, testIfHg, writeFiles} from '../Utils';

const DIR = path.resolve(tmpdir(), 'jest_only_changed');
const GIT = 'git -c user.name=jest_test -c user.email=jest_test@test.com';
Expand All @@ -17,6 +17,10 @@ const HG = 'hg --config ui.username=jest_test';
beforeEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));

if (!hgIsInstalled) {
console.warn('Mercurial (hg) is not installed - skipping some tests');
}

test('run for "onlyChanged" and "changedSince"', () => {
writeFiles(DIR, {
'.watchmanconfig': '',
Expand Down Expand Up @@ -252,7 +256,7 @@ test('onlyChanged in config is overwritten by --all or testPathPattern', () => {
expect(stderr).toMatch(/PASS __tests__(\/|\\)file3.test.js/);
});

test('gets changed files for hg', async () => {
testIfHg('gets changed files for hg', async () => {
if (process.env.CI) {
// Circle and Travis have very old version of hg (v2, and current
// version is v4.2) and its API changed since then and not compatible
Expand Down