mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
Fix damlc test with relative --project-root (#6541)
Returning the original relative path from withProjectRoot makes no sense since we change the directory in there so this PR fixes this to return the canonicalized project root. fixes #6245 changelog_begin - [DAML Compiler] damlc test --project-root now works with relative paths as well. changelog_end
This commit is contained in:
parent
0c80c984b6
commit
470d4f28a5
@ -194,6 +194,23 @@ testsForDamlcTest damlc = testGroup "damlc test" $
|
||||
exitCode @?= ExitSuccess
|
||||
assertBool ("Succeeding scenario in " <> stdout) ("Main.daml:test: ok" `isInfixOf` stdout)
|
||||
stderr @?= ""
|
||||
, testCase "damlc test --project-root relative" $ withTempDir $ \projDir -> do
|
||||
createDirectoryIfMissing True (projDir </> "relative")
|
||||
writeFileUTF8 (projDir </> "relative" </> "Main.daml") $ unlines
|
||||
[ "daml 1.2"
|
||||
, "module Main where"
|
||||
, "test = scenario do"
|
||||
, " assert True"
|
||||
]
|
||||
writeFileUTF8 (projDir </> "relative" </> "daml.yaml") $ unlines
|
||||
[ "sdk-version: " <> sdkVersion
|
||||
, "name: relative"
|
||||
, "version: 0.0.1"
|
||||
, "source: ."
|
||||
, "dependencies: [daml-prim, daml-stdlib]"
|
||||
]
|
||||
withCurrentDirectory projDir $
|
||||
callProcessSilent damlc ["test", "--project-root=relative"]
|
||||
] <>
|
||||
[ testCase ("damlc test " <> unwords (args "") <> " in project") $ withTempDir $ \projDir -> do
|
||||
createDirectoryIfMissing True (projDir </> "a")
|
||||
|
@ -173,10 +173,10 @@ withProjectRoot mbProjectDir (ProjectCheck cmdName check) act = do
|
||||
when check $ do
|
||||
hPutStrLn stderr (cmdName <> ": Not in project.")
|
||||
exitFailure
|
||||
act mbProjectPath pure
|
||||
act Nothing pure
|
||||
Just projectPath -> do
|
||||
projectPath <- canonicalizePath projectPath
|
||||
withCurrentDirectory projectPath $ act mbProjectPath $ \f -> do
|
||||
withCurrentDirectory projectPath $ act (Just projectPath) $ \f -> do
|
||||
absF <- canonicalizePath (previousCwd </> f)
|
||||
pure (projectPath `makeRelative` absF)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user