Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't clear compilation output dir #1660

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ trait BuildCommandHelpers { self: ScalaCommand[_] =>
sharedOptions.compilationOutput.filter(_.nonEmpty)
.orElse(sharedOptions.scalac.scalacOption.getScalacOption("-d"))
.filter(_.nonEmpty)
.map(os.Path(_, Os.pwd)).foreach(output =>
os.copy.over(successfulBuild.output, output, createFolders = true)
)
.map(os.Path(_, Os.pwd)).foreach { output =>
os.copy(
successfulBuild.output,
output,
createFolders = true,
mergeFolders = true,
replaceExisting = true
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,47 @@ trait RunScalacCompatTestDefinitions { _: RunTestDefinitions =>
expect(runRes.out.trim() == expectedOutput)
}
}
test("dont clear output dir") {
val expectedOutput = "Hello"
val `lib.scala` = os.rel / "lib.scala"
val `utils.scala` = os.rel / "utils.scala"
TestInputs(
`lib.scala` -> s"""object lib { def foo = "$expectedOutput" }""",
`utils.scala` -> s"""object utils { def bar = lib.foo }"""
).fromRoot { (root: os.Path) =>
val compilationOutputDir = os.rel / "compilationOutput"
// first, precompile to an explicitly specified output directory with -d
os.proc(
TestUtil.cli,
"compile",
"-d",
compilationOutputDir,
`lib.scala`,
extraOptions
).call(cwd = root)

val outputFiles = os.list(root / compilationOutputDir)
expect(outputFiles.exists(_.endsWith(os.rel / "lib$.class")))
expect(outputFiles.exists(_.endsWith(os.rel / "lib.class")))

os.proc(
TestUtil.cli,
"compile",
"-d",
compilationOutputDir,
"-cp",
compilationOutputDir,
`utils.scala`,
extraOptions
).call(cwd = root)

val outputFlies2 = os.list(root / compilationOutputDir)
expect(outputFlies2.exists(_.endsWith(os.rel / "utils$.class")))
expect(outputFlies2.exists(_.endsWith(os.rel / "utils.class")))
expect(outputFlies2.exists(_.endsWith(os.rel / "lib$.class")))
expect(outputFlies2.exists(_.endsWith(os.rel / "lib.class")))
}
}

test("run main class from a jar even when no explicit inputs are passed") {
val expectedOutput = "Hello"
Expand Down