File tree Expand file tree Collapse file tree
cli/src/main/scala/scala/cli/commands/util
integration/src/test/scala/scala/cli/integration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ trait BuildCommandHelpers { self: ScalaCommand[_] =>
2424 sharedOptions.compilationOutput.filter(_.nonEmpty)
2525 .orElse(sharedOptions.scalac.scalacOption.getScalacOption(" -d" ))
2626 .filter(_.nonEmpty)
27- .map(os.Path (_, Os .pwd)).foreach(output =>
28- os.copy.over(successfulBuild.output, output, createFolders = true )
29- )
27+ .map(os.Path (_, Os .pwd)).foreach { output =>
28+ os.copy(
29+ successfulBuild.output,
30+ output,
31+ createFolders = true ,
32+ mergeFolders = true ,
33+ replaceExisting = true
34+ )
35+ }
3036 }
3137}
Original file line number Diff line number Diff line change @@ -268,6 +268,47 @@ trait RunScalacCompatTestDefinitions { _: RunTestDefinitions =>
268268 expect(runRes.out.trim() == expectedOutput)
269269 }
270270 }
271+ test(" dont clear output dir" ) {
272+ val expectedOutput = " Hello"
273+ val `lib.scala` = os.rel / " lib.scala"
274+ val `utils.scala` = os.rel / " utils.scala"
275+ TestInputs (
276+ `lib.scala` -> s """ object lib { def foo = " $expectedOutput" } """ ,
277+ `utils.scala` -> s """ object utils { def bar = lib.foo } """
278+ ).fromRoot { (root : os.Path ) =>
279+ val compilationOutputDir = os.rel / " compilationOutput"
280+ // first, precompile to an explicitly specified output directory with -d
281+ os.proc(
282+ TestUtil .cli,
283+ " compile" ,
284+ " -d" ,
285+ compilationOutputDir,
286+ `lib.scala`,
287+ extraOptions
288+ ).call(cwd = root)
289+
290+ val outputFiles = os.list(root / compilationOutputDir)
291+ expect(outputFiles.exists(_.endsWith(os.rel / " lib$.class" )))
292+ expect(outputFiles.exists(_.endsWith(os.rel / " lib.class" )))
293+
294+ os.proc(
295+ TestUtil .cli,
296+ " compile" ,
297+ " -d" ,
298+ compilationOutputDir,
299+ " -cp" ,
300+ compilationOutputDir,
301+ `utils.scala`,
302+ extraOptions
303+ ).call(cwd = root)
304+
305+ val outputFlies2 = os.list(root / compilationOutputDir)
306+ expect(outputFlies2.exists(_.endsWith(os.rel / " utils$.class" )))
307+ expect(outputFlies2.exists(_.endsWith(os.rel / " utils.class" )))
308+ expect(outputFlies2.exists(_.endsWith(os.rel / " lib$.class" )))
309+ expect(outputFlies2.exists(_.endsWith(os.rel / " lib.class" )))
310+ }
311+ }
271312
272313 test(" run main class from a jar even when no explicit inputs are passed" ) {
273314 val expectedOutput = " Hello"
You can’t perform that action at this time.
0 commit comments