Skip to content

Commit 86d0ac7

Browse files
simonmarfacebook-github-bot
authored andcommitted
Don't change working directory in the indexer (#558)
Summary: This reverts a change that was added as part of 77681e9 I'm sure there must have been a reason for it, but it breaks running tests in parallel. In general nothing should be changing the working directory, because it's process-wide. Pull Request resolved: #558 Reviewed By: phlalx Differential Revision: D78210500 Pulled By: pepeiborra fbshipit-source-id: f1bb25020dd28bba00ef78fa35574f265e3ad2fd
1 parent 2e1d0e5 commit 86d0ac7

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

  • glean/lang/clang/Glean/Indexer

glean/lang/clang/Glean/Indexer/Cpp.hs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import Glean.LocalOrRemote ( BackendKind(..),
5454
import Glean.Util.Service
5555
import qualified Glean.Interprocess.Worklist as Worklist
5656
import qualified Glean.Handler as GleanHandler
57-
import System.Posix (changeWorkingDirectory)
5857
import Data.Aeson (decode, Object, Value (String))
5958
import Data.Foldable (toList)
6059

@@ -230,11 +229,12 @@ indexerWith deriveToo = Indexer {
230229
forConcurrently_ [0 .. workers-1] $ \i -> bracket
231230
-- createProcess_ because we don't want the stdout/stderr handles
232231
-- to be closed
233-
( (if cdUp then pushd ".." else id) $
234-
createProcess_
232+
(createProcess_
235233
"Cpp.index"
236234
(proc clangIndex $ workerargs i)
237-
{std_out = stream, std_err = stream})
235+
{std_out = stream,
236+
std_err = stream,
237+
cwd = if cdUp then Just (takeDirectory currentDir) else Nothing})
238238
cleanupProcess
239239
$ \(_, _, _, ph) -> do
240240
ex <- waitForProcess ph
@@ -249,13 +249,6 @@ indexerWith deriveToo = Indexer {
249249
isPathPrefixOf :: FilePath -> FilePath -> Bool
250250
isPathPrefixOf prefix path = prefix == take (length prefix) path
251251

252-
pushd :: FilePath -> IO a -> IO a
253-
pushd dir f = do
254-
currentDir <- getCurrentDirectory
255-
changeWorkingDirectory dir
256-
res <- f
257-
changeWorkingDirectory currentDir
258-
pure res
259252

260253
writeToDB backend repo = mapM_ $ \dataFile -> do
261254
dat <- BS.readFile dataFile

0 commit comments

Comments
 (0)