Skip to content

Commit e0256ad

Browse files
committed
Partest --no-exec skips runs
Runnable tests are compiled, but not run; they are marked skipped.
1 parent 760627e commit e0256ad

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

project/PartestUtil.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object PartestUtil {
3434
def partestParser(globalBase: File, testBase: File): Parser[String] = {
3535
val knownUnaryOptions = List(
3636
"--pos", "--neg", "--run", "--jvm", "--res", "--ant", "--scalap", "--specialized",
37-
"--instrumented", "--presentation", "--failed", "--update-check",
37+
"--instrumented", "--presentation", "--failed", "--update-check", "--no-exec",
3838
"--show-diff", "--show-log", "--verbose", "--terse", "--debug", "--version", "--help")
3939
val srcPathOption = "--srcpath"
4040
val grepOption = "--grep"

src/partest/scala/tools/partest/nest/AbstractRunner.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ abstract class AbstractRunner {
161161
}
162162
val expectedFailureMessage = if (expectedFailures == 0) "" else s" (expecting $expectedFailures to fail)"
163163
echo(s"Selected $totalTests tests drawn from $testContributors$expectedFailureMessage\n")
164+
if (config.optNoExec) echoMixed("Under --no-exec, tests will be compiled but not run! Runnable tests will be marked skipped!")
164165

165166
val (_, millis) = timed {
166167
for ((kind, paths) <- grouped) {

src/partest/scala/tools/partest/nest/ConsoleRunner.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ConsoleRunner(val config: RunnerSpec.Config) extends AbstractRunner {
1212
fileManager = new FileManager(ClassPath split PathResolver.Environment.javaUserClassPath map (Path(_))), // the script sets up our classpath for us via ant
1313
updateCheck = config.optUpdateCheck,
1414
failed = config.optFailed,
15+
noexec = config.optNoExec,
1516
nestUI = nestUI)
1617
}
1718

src/partest/scala/tools/partest/nest/Runner.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import scala.tools.nsc.reporters.ConsoleReporter
2424
import scala.tools.nsc.util.stackTraceString
2525
import scala.util.{Failure, Success, Try}
2626
import ClassPath.join
27-
import TestState.{Crash, Fail, Pass, Uninitialized, Updated}
27+
import TestState.{Crash, Fail, Pass, Skip, Uninitialized, Updated}
2828
import FileManager.{compareContents, joinPaths, withTempFile}
2929
import scala.reflect.internal.util.ScalaClassLoader.URLClassLoader
3030
import scala.util.control.ControlThrowable
@@ -107,6 +107,7 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner, val nestUI: NestU
107107

108108
def genPass() = Pass(testFile)
109109
def genFail(reason: String) = Fail(testFile, reason, _transcript.fail.toArray)
110+
def genSkip(reason: String) = Skip(testFile, reason)
110111
def genTimeout() = Fail(testFile, "timed out", _transcript.fail.toArray)
111112
def genCrash(caught: Throwable) = Crash(testFile, caught, _transcript.fail.toArray)
112113
def genUpdated() = Updated(testFile)
@@ -216,7 +217,6 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner, val nestUI: NestU
216217
}
217218
}
218219

219-
220220
/** Runs command redirecting standard out and
221221
* error out to output file.
222222
*/
@@ -688,11 +688,12 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner, val nestUI: NestU
688688
}
689689

690690
private def runRunTest(): Unit = {
691-
val argsFile = testFile changeExtension "javaopts"
691+
val argsFile = testFile changeExtension "javaopts"
692692
val javaopts = readOptionsFile(argsFile)
693693
val execInProcess = PartestDefaults.execInProcess && javaopts.isEmpty && !Set("specialized", "instrumented").contains(testFile.getParentFile.getName)
694694
def exec() = if (execInProcess) execTestInProcess(outDir, logFile) else execTest(outDir, logFile)
695-
runTestCommon(exec() && diffIsOk)
695+
def noexec() = suiteRunner.noexec && { setLastState(genSkip("no-exec: tests compiled but not run")) ; true }
696+
runTestCommon(noexec() || exec() && diffIsOk)
696697
}
697698

698699
private def decompileClass(clazz: Class[_], isPackageObject: Boolean): String = {
@@ -761,6 +762,7 @@ class SuiteRunner(
761762
val fileManager: FileManager,
762763
val updateCheck: Boolean,
763764
val failed: Boolean,
765+
val noexec: Boolean,
764766
val nestUI: NestUI,
765767
val javaCmdPath: String = PartestDefaults.javaCmd,
766768
val javacCmdPath: String = PartestDefaults.javacCmd,

src/partest/scala/tools/partest/nest/RunnerSpec.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ trait RunnerSpec extends Spec with Meta.StdOpts with Interpolation {
2828
val optPack = "pack" / "pick compiler/reflect/library in build/pack, and run all tests" --?
2929
val optGrep = "grep" / "run all tests whose source file contains the expression given to grep" --|
3030
val optUpdateCheck = "update-check" / "instead of failing tests with output change, update checkfile (use with care!)" --?
31+
val optNoExec = "no-exec" / "instead of running tests, stop after dry-run compilation" --?
3132
val optBuildPath = "buildpath" / "set (relative) path to build jars (ex.: --buildpath build/pack)" --|
3233
val optClassPath = "classpath" / "set (absolute) path to build classes" --|
3334
val optSourcePath = "srcpath" / "set (relative) path to test source files (ex.: --srcpath pending)" --|

src/partest/scala/tools/partest/sbt/SBTRunner.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class SBTRunner(val config: RunnerSpec.Config,
6060
testSourcePath = testSrcPath,
6161
new FileManager(testClassLoader = testClassLoader),
6262
updateCheck = config.optUpdateCheck,
63-
failed = config.optFailed,
63+
failed = config.optFailed,
64+
noexec = config.optNoExec,
6465
nestUI = nestUI,
6566
javaCmdPath = Option(javaCmd).map(_.getAbsolutePath) getOrElse PartestDefaults.javaCmd,
6667
javacCmdPath = Option(javacCmd).map(_.getAbsolutePath) getOrElse PartestDefaults.javacCmd,

0 commit comments

Comments
 (0)