From 7b140315a3b54834e07bdf4a740debf95322cd32 Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 30 Jun 2021 08:51:21 -0600 Subject: [PATCH 1/3] fix-for-#12962 --- .../tools/scripting/BashScriptsTests.scala | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/compiler/test/dotty/tools/scripting/BashScriptsTests.scala b/compiler/test/dotty/tools/scripting/BashScriptsTests.scala index cadf86467ae7..ba324cf34768 100644 --- a/compiler/test/dotty/tools/scripting/BashScriptsTests.scala +++ b/compiler/test/dotty/tools/scripting/BashScriptsTests.scala @@ -41,39 +41,42 @@ class BashScriptsTests: /* verify `dist/bin/scalac` */ @Test def verifyScalacArgs = - val commandline = (Seq(scalacPath, "-script", showArgsScript) ++ testScriptArgs).mkString(" ") - if bashPath.toFile.exists then - var cmd = Array(bashExe, "-c", commandline) - val output = for { - line <- Process(cmd).lazyLines_! - } yield line - var fail = false - printf("\n") - for (line, expect) <- output zip expectedOutput do - printf("expected: %-17s| actual: %s\n", line, expect) - if line != expect then - fail = true - - if fail then - assert(output == expectedOutput) + if scalacPath.nonEmpty then + printf("scalacPath[%s]\n",scalacPath) + val commandline = (Seq(scalacPath, "-script", showArgsScript) ++ testScriptArgs).mkString(" ") + if bashPath.toFile.exists then + var cmd = Array(bashExe, "-c", commandline) + val output = for { + line <- Process(cmd).lazyLines_! + } yield line + var fail = false + printf("\n") + for (line, expect) <- output zip expectedOutput do + printf("expected: %-17s\nactual : %s\n", expect, line) + if line != expect then + fail = true + + if fail then + assert(output == expectedOutput) /* verify `dist/bin/scala` */ @Test def verifyScalaArgs = - val commandline = (Seq(scalaPath, showArgsScript) ++ testScriptArgs).mkString(" ") - if bashPath.toFile.exists then - var cmd = Array(bashExe, "-c", commandline) - val output = for { - line <- Process(cmd).lazyLines_! - } yield line - var fail = false - printf("\n") - for (line, expect) <- output zip expectedOutput do - printf("expected: %-17s| actual: %s\n", line, expect) - if line != expect then - fail = true - - if fail then - assert(output == expectedOutput) + if scalaPath.nonEmpty then + val commandline = (Seq(scalaPath, showArgsScript) ++ testScriptArgs).mkString(" ") + if bashPath.toFile.exists then + var cmd = Array(bashExe, "-c", commandline) + val output = for { + line <- Process(cmd).lazyLines_! + } yield line + var fail = false + printf("\n") + for (line, expect) <- output zip expectedOutput do + printf("expected: %-17s\nactual : %s\n", expect, line) + if line != expect then + fail = true + + if fail then + assert(output == expectedOutput) extension (str: String) def dropExtension = str.reverse.dropWhile(_ != '.').drop(1).reverse From e38932c17863e7dd0ed5dfcb76fa59d460a4e7ba Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 30 Jun 2021 10:09:03 -0600 Subject: [PATCH 2/3] fix for 12962, runtime conditions for BashScriptTests --- compiler/test-resources/scripting/showArgs.sc | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 compiler/test-resources/scripting/showArgs.sc diff --git a/compiler/test-resources/scripting/showArgs.sc b/compiler/test-resources/scripting/showArgs.sc old mode 100644 new mode 100755 From 078d1cb24771f89f3e8d04c7858d57b754ca503a Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 30 Jun 2021 15:24:12 -0600 Subject: [PATCH 3/3] embed relative paths to scalac and scala in BashScriptsTests.scala --- .../tools/scripting/BashScriptsTests.scala | 69 +++++++++---------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/compiler/test/dotty/tools/scripting/BashScriptsTests.scala b/compiler/test/dotty/tools/scripting/BashScriptsTests.scala index ba324cf34768..499111f02f26 100644 --- a/compiler/test/dotty/tools/scripting/BashScriptsTests.scala +++ b/compiler/test/dotty/tools/scripting/BashScriptsTests.scala @@ -36,47 +36,46 @@ class BashScriptsTests: val showArgsScript = testFiles.find(_.getName == "showArgs.sc").get.absPath - val scalacPath = which("scalac") - val scalaPath = which("scala") + val scalacPath = "dist/target/pack/bin/scalac" // which("scalac") + val scalaPath = "dist/target/pack/bin/scala" // which("scala") /* verify `dist/bin/scalac` */ @Test def verifyScalacArgs = - if scalacPath.nonEmpty then - printf("scalacPath[%s]\n",scalacPath) - val commandline = (Seq(scalacPath, "-script", showArgsScript) ++ testScriptArgs).mkString(" ") - if bashPath.toFile.exists then - var cmd = Array(bashExe, "-c", commandline) - val output = for { - line <- Process(cmd).lazyLines_! - } yield line - var fail = false - printf("\n") - for (line, expect) <- output zip expectedOutput do - printf("expected: %-17s\nactual : %s\n", expect, line) - if line != expect then - fail = true - - if fail then - assert(output == expectedOutput) + printf("scalacPath[%s]\n",scalacPath) + val commandline = (Seq(scalacPath, "-script", showArgsScript) ++ testScriptArgs).mkString(" ") + if bashPath.toFile.exists then + var cmd = Array(bashExe, "-c", commandline) + val output = for { + line <- Process(cmd).lazyLines_! + } yield line + var fail = false + printf("\n") + for (line, expect) <- output zip expectedOutput do + printf("expected: %-17s\nactual : %s\n", expect, line) + if line != expect then + fail = true + + if fail then + assert(output == expectedOutput) /* verify `dist/bin/scala` */ @Test def verifyScalaArgs = - if scalaPath.nonEmpty then - val commandline = (Seq(scalaPath, showArgsScript) ++ testScriptArgs).mkString(" ") - if bashPath.toFile.exists then - var cmd = Array(bashExe, "-c", commandline) - val output = for { - line <- Process(cmd).lazyLines_! - } yield line - var fail = false - printf("\n") - for (line, expect) <- output zip expectedOutput do - printf("expected: %-17s\nactual : %s\n", expect, line) - if line != expect then - fail = true - - if fail then - assert(output == expectedOutput) + val commandline = (Seq(scalaPath, showArgsScript) ++ testScriptArgs).mkString(" ") + if bashPath.toFile.exists then + var cmd = Array(bashExe, "-c", commandline) + val output = for { + line <- Process(cmd).lazyLines_! + } yield line + var fail = false + printf("\n") + var mismatches = List.empty[(String,String)] + for (line, expect) <- output zip expectedOutput do + printf("expected: %-17s\nactual : %s\n", expect, line) + if line != expect then + fail = true + + if fail then + assert(output == expectedOutput) extension (str: String) def dropExtension = str.reverse.dropWhile(_ != '.').drop(1).reverse