@@ -6,7 +6,6 @@ import java.io.{ByteArrayOutputStream, File}
6
6
import java .nio .charset .Charset
7
7
8
8
import scala .cli .integration .util .DockerServer
9
- import scala .concurrent .duration .DurationInt
10
9
import scala .io .Codec
11
10
import scala .jdk .CollectionConverters .*
12
11
import scala .util .Properties
@@ -1506,87 +1505,6 @@ abstract class RunTestDefinitions
1506
1505
}
1507
1506
}
1508
1507
1509
- test(" watch with interactive, with multiple main classes" ) {
1510
- val fileName = " watch.scala"
1511
- TestInputs (
1512
- os.rel / fileName ->
1513
- """ object Run1 extends App {println("Run1 launched")}
1514
- |object Run2 extends App {println("Run2 launched")}
1515
- |""" .stripMargin
1516
- ).fromRoot { root =>
1517
- val confDir = root / " config"
1518
- val confFile = confDir / " test-config.json"
1519
-
1520
- os.write(confFile, " {}" , createFolders = true )
1521
-
1522
- if (! Properties .isWin)
1523
- os.perms.set(confDir, " rwx------" )
1524
-
1525
- val configEnv = Map (" SCALA_CLI_CONFIG" -> confFile.toString)
1526
-
1527
- TestUtil .withProcessWatching(
1528
- proc = os.proc(TestUtil .cli, " run" , " --watch" , " --interactive" , fileName)
1529
- .spawn(
1530
- cwd = root,
1531
- mergeErrIntoOut = true ,
1532
- stdout = os.Pipe ,
1533
- stdin = os.Pipe ,
1534
- env = Map (" SCALA_CLI_INTERACTIVE" -> " true" ) ++ configEnv
1535
- ),
1536
- timeout = 60 .seconds
1537
- ) { (proc, timeout, ec) =>
1538
- def lineReaderIter : Iterator [String ] = Iterator .continually {
1539
- val line = TestUtil .readLine(proc.stdout, ec, timeout)
1540
- println(s " Line read: $line" )
1541
- line
1542
- }
1543
-
1544
- def checkLinesForError (lines : Seq [String ]): Unit = munit.Assertions .assert(
1545
- ! lines.exists { line =>
1546
- TestUtil .removeAnsiColors(line).contains(" [error]" )
1547
- },
1548
- clues(lines.toSeq)
1549
- )
1550
-
1551
- def answerInteractivePrompt (id : Int ): Unit = {
1552
- val interactivePromptLines = lineReaderIter
1553
- .takeWhile(! _.startsWith(" [1]" /* probably [1] Run2 or [1] No*/ ))
1554
- .toList
1555
- expect(interactivePromptLines.nonEmpty)
1556
- checkLinesForError(interactivePromptLines)
1557
- proc.stdin.write(s " $id\n " )
1558
- proc.stdin.flush()
1559
- }
1560
-
1561
- def analyzeRunOutput (restart : Boolean ): Unit = {
1562
- val runResultLines = lineReaderIter
1563
- .takeWhile(! _.contains(" press Enter to re-run" ))
1564
- .toList
1565
- expect(runResultLines.nonEmpty)
1566
- checkLinesForError(runResultLines)
1567
- if (restart)
1568
- proc.stdin.write(" \n " )
1569
- proc.stdin.flush()
1570
- }
1571
-
1572
- // You have run the current scala-cli command with the --interactive mode turned on.
1573
- // Would you like to leave it on permanently?
1574
- answerInteractivePrompt(0 )
1575
-
1576
- // Found several main classes. Which would you like to run?
1577
- answerInteractivePrompt(0 )
1578
- expect(TestUtil .readLine(proc.stdout, ec, timeout) == " Run1 launched" )
1579
-
1580
- analyzeRunOutput( /* restart */ true )
1581
-
1582
- answerInteractivePrompt(1 )
1583
- expect(TestUtil .readLine(proc.stdout, ec, timeout) == " Run2 launched" )
1584
-
1585
- analyzeRunOutput( /* restart */ false )
1586
- }
1587
- }
1588
- }
1589
-
1590
1508
test(" decoded classNames in interactive ask" ) {
1591
1509
val fileName = " watch.scala"
1592
1510
@@ -2341,28 +2259,4 @@ abstract class RunTestDefinitions
2341
2259
}
2342
2260
}
2343
2261
}
2344
-
2345
- test(" simple --watch .scala source" ) {
2346
- val expectedMessage1 = " Hello"
2347
- val inputPath = os.rel / " smth.scala"
2348
- TestInputs (inputPath -> s """ object Smth extends App { println(" $expectedMessage1") } """ )
2349
- .fromRoot { root =>
2350
- TestUtil .withProcessWatching(
2351
- os.proc(TestUtil .cli, " run" , " ." , " --watch" , extraOptions)
2352
- .spawn(cwd = root, stderr = os.Pipe )
2353
- ) { (proc, timeout, ec) =>
2354
- val output1 = TestUtil .readLine(proc.stdout, ec, timeout)
2355
- expect(output1 == expectedMessage1)
2356
- val expectedMessage2 = " World"
2357
- while (! TestUtil .readLine(proc.stderr, ec, timeout).contains(" re-run" ))
2358
- Thread .sleep(100L )
2359
- os.write.over(
2360
- root / inputPath,
2361
- s """ object Smth extends App { println(" $expectedMessage2") } """ .stripMargin
2362
- )
2363
- val output2 = TestUtil .readLine(proc.stdout, ec, timeout)
2364
- expect(output2 == expectedMessage2)
2365
- }
2366
- }
2367
- }
2368
2262
}
0 commit comments