File tree 2 files changed +50
-3
lines changed
cli/src/main/scala/scala/cli/commands/util
integration/src/test/scala/scala/cli/integration
2 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ trait BuildCommandHelpers { self: ScalaCommand[_] =>
24
24
sharedOptions.compilationOutput.filter(_.nonEmpty)
25
25
.orElse(sharedOptions.scalac.scalacOption.getScalacOption(" -d" ))
26
26
.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
+ }
30
36
}
31
37
}
Original file line number Diff line number Diff line change @@ -268,6 +268,47 @@ trait RunScalacCompatTestDefinitions { _: RunTestDefinitions =>
268
268
expect(runRes.out.trim() == expectedOutput)
269
269
}
270
270
}
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
+ }
271
312
272
313
test(" run main class from a jar even when no explicit inputs are passed" ) {
273
314
val expectedOutput = " Hello"
You can’t perform that action at this time.
0 commit comments