Skip to content

Commit

Permalink
Remove unnecessary subfolder wrappers for integration tests (#3458)
Browse files Browse the repository at this point in the history
Since #3347 made all test suites
run with `pwd` in the test's `.dest` folder by default, we are already
guaranteed that different concurrent test suites will not collide, so we
do not need the `out/blah/blah` segments to avoid conflicts
  • Loading branch information
lihaoyi authored Sep 5, 2024
1 parent a69e4cb commit 4caadfb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions testkit/src/mill/testkit/IntegrationTesterBase.scala
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
package mill.testkit
import mill.main.client.OutFiles.out

trait IntegrationTesterBase {
def workspaceSourcePath: os.Path
private val workspacePathBase = os.pwd / "out" / "integration-tester-workdir"
os.makeDir.all(workspacePathBase)

/**
* The working directory of the integration test suite, which is the root of the
* Mill build being tested. Contains the `build.mill` file, any application code, and
* the `out/` folder containing the build output
*
* Make sure it lives inside `os.pwd` because somehow the tests fail on windows
* if it lives in the global temp folder.
* Typically just `pwd`, which is a sandbox directory for test suites run using Mill.
*/
val workspacePath: os.Path = os.temp.dir(workspacePathBase, deleteOnExit = false)
val workspacePath: os.Path = os.pwd

/**
* Initializes the workspace in preparation for integration testing
*/
def initWorkspace(): Unit = {
println(s"Copying integration test sources from $workspaceSourcePath to $workspacePath")
os.remove.all(workspacePath)
os.makeDir.all(workspacePath / os.up)
// somehow os.copy does not properly preserve symlinks
// os.copy(scriptSourcePath, workspacePath)
os.call(("cp", "-R", workspaceSourcePath, workspacePath))
os.list(workspacePath).foreach(os.remove.all(_))
os.list(workspaceSourcePath).filter(_.last != out).foreach(os.copy.into(_, workspacePath))
os.remove.all(workspacePath / "out")
}
}

0 comments on commit 4caadfb

Please sign in to comment.