Skip to content

Commit

Permalink
Set workspace dir to os.tmp for virtual sources
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Jan 11, 2023
1 parent a809da5 commit 242d096
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/build/src/main/scala/scala/build/input/Inputs.scala
Expand Up @@ -157,6 +157,11 @@ object Inputs {
)
(f.path / os.up, true, WorkspaceOrigin.SourcePaths)
}
}.orElse {
validElems.collectFirst {
case _: Virtual =>
(os.temp.dir(), true, WorkspaceOrigin.VirtualForced)
}
}.getOrElse((os.pwd, true, WorkspaceOrigin.Forced))
}

Expand Down
Expand Up @@ -9,5 +9,6 @@ object WorkspaceOrigin {

case object ResourcePaths extends WorkspaceOrigin

case object HomeDir extends WorkspaceOrigin
case object HomeDir extends WorkspaceOrigin
case object VirtualForced extends WorkspaceOrigin
}
Expand Up @@ -202,4 +202,14 @@ trait RunPipedSourcesTestDefinitions { _: RunTestDefinitions =>
expect(output == expectedOutput)
}
}

test("running script snipped should not create workspace dir in cwd") {
emptyInputs.fromRoot { root =>
os.proc(TestUtil.cli, "-e", """println("Hello")""", extraOptions)
.call(cwd = root)
.out.trim()
expect(!os.exists(root / Constants.workspaceDirName))
}
}

}

0 comments on commit 242d096

Please sign in to comment.