Skip to content

Commit

Permalink
Drop unnecessary VSTS_OVERWRITE_TEMP and fix failing tests. See #7598
Browse files Browse the repository at this point in the history
  • Loading branch information
willsmythe committed Jan 10, 2019
1 parent f6d0300 commit ea7935f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
4 changes: 1 addition & 3 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
- job: Windows
pool:
vmImage: vs2017-win2016
variables:
VSTS_OVERWRITE_TEMP: true
steps:
- script: |
git config --global core.autocrlf false
Expand All @@ -25,7 +23,7 @@ jobs:
pool:
vmImage: macos-10.13
steps:
- script: brew install mercurial
- script: HOMEBREW_NO_AUTO_UPDATE=1 brew install mercurial
displayName: 'Install Mercurial'
- template: .azure-pipelines-steps.yml

Expand Down
8 changes: 5 additions & 3 deletions e2e/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ export const createEmptyPackage = (
};

export const extractSummary = (stdout: string) => {
const match = stdout.replace(/(?:\\[rn])+/g, '\n').match(
/Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm,
);
const match = stdout
.replace(/(?:\\[rn])+/g, '\n')
.match(
/Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm,
);
if (!match) {
throw new Error(
`
Expand Down
3 changes: 2 additions & 1 deletion e2e/__tests__/hasteMapSize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import os from 'os';
import path from 'path';
import HasteMap from 'jest-haste-map';
import {cleanup, writeFiles} from '../Utils';
import {sync as realpath} from 'realpath-native';

const DIR = path.resolve(os.tmpdir(), 'haste_map_size');
const DIR = path.resolve(realpath(os.tmpdir()), 'haste_map_size');

beforeEach(() => {
cleanup(DIR);
Expand Down
9 changes: 7 additions & 2 deletions packages/jest-cli/src/SearchSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import testPathPatternToRegExp from './testPathPatternToRegexp';
import {escapePathForRegex} from 'jest-regex-util';
import {replaceRootDirInPath} from 'jest-config';
import {buildSnapshotResolver} from 'jest-snapshot';
import {sync as realpath} from 'realpath-native';

type SearchResult = {|
noSCM?: boolean,
Expand Down Expand Up @@ -182,11 +183,12 @@ export default class SearchSource {
}

findTestsByPaths(paths: Array<Path>): SearchResult {
const cwd = realpath(process.cwd());
return {
tests: toTests(
this._context,
paths
.map(p => path.resolve(process.cwd(), p))
.map(p => path.resolve(cwd, p))
.filter(this.isTestFilePath.bind(this)),
),
};
Expand All @@ -197,7 +199,10 @@ export default class SearchSource {
collectCoverage: boolean,
): SearchResult {
if (Array.isArray(paths) && paths.length) {
const resolvedPaths = paths.map(p => path.resolve(process.cwd(), p));
const cwd = realpath(process.cwd());
const resolvedPaths = paths.map(p =>
path.resolve(cwd, p),
);
return this.findRelatedTests(new Set(resolvedPaths), collectCoverage);
}
return {tests: []};
Expand Down
9 changes: 7 additions & 2 deletions packages/jest-config/src/getCacheDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
import path from 'path';
import os from 'os';

import {sync as realpath} from 'realpath-native';

const getCacheDirectory = () => {
const {getuid} = process;
if (getuid == null) {
return path.join(os.tmpdir(), 'jest');
return path.join(realpath(os.tmpdir()), 'jest');
}
// On some platforms tmpdir() is `/tmp`, causing conflicts between different
// users and permission issues. Adding an additional subdivision by UID can
// help.
return path.join(os.tmpdir(), 'jest_' + getuid.call(process).toString(36));
return path.join(
realpath(os.tmpdir()),
'jest_' + getuid.call(process).toString(36),
);
};

export default getCacheDirectory;

0 comments on commit ea7935f

Please sign in to comment.