From 07e8a65d5794b6838a22fcca945090c6a6ca2fc8 Mon Sep 17 00:00:00 2001 From: Will Smythe Date: Thu, 10 Jan 2019 08:09:53 -0500 Subject: [PATCH] Drop unnecessary VSTS_OVERWRITE_TEMP and fix failing tests. See #7598 --- .azure-pipelines.yml | 4 +--- e2e/Utils.js | 8 +++++--- packages/jest-cli/src/SearchSource.js | 10 ++++++++-- packages/jest-config/src/getCacheDirectory.js | 9 +++++++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 5b560a96707b..f87035abb706 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -12,8 +12,6 @@ jobs: - job: Windows pool: vmImage: vs2017-win2016 - variables: - VSTS_OVERWRITE_TEMP: true steps: - script: | git config --global core.autocrlf false @@ -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 diff --git a/e2e/Utils.js b/e2e/Utils.js index 47dca4e0360b..5588bb9d235e 100644 --- a/e2e/Utils.js +++ b/e2e/Utils.js @@ -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( ` diff --git a/packages/jest-cli/src/SearchSource.js b/packages/jest-cli/src/SearchSource.js index 27862d6a7dac..a3aa0323e4ec 100644 --- a/packages/jest-cli/src/SearchSource.js +++ b/packages/jest-cli/src/SearchSource.js @@ -20,6 +20,8 @@ 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, stats?: {[key: string]: number}, @@ -182,11 +184,12 @@ export default class SearchSource { } findTestsByPaths(paths: Array): 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)), ), }; @@ -197,7 +200,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: []}; diff --git a/packages/jest-config/src/getCacheDirectory.js b/packages/jest-config/src/getCacheDirectory.js index d3771d41967c..bf9d6c4ce786 100644 --- a/packages/jest-config/src/getCacheDirectory.js +++ b/packages/jest-config/src/getCacheDirectory.js @@ -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;