mill.testkit

package mill.testkit

Members list

Type members

Classlikes

object BashTokenizer

Attributes

Source
BashTokenizer.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object ExampleParser

Attributes

Source
ExampleParser.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object ExampleTester

A variant of IntegrationTester, ExampleTester works the same way except the commands used to test the project come from a /** Usage ... */ comment inside the project's build.mill file. This is intended to make the build.mill file usable as documentation, such that a reader can skim the build.mill and see both the build configuration and the commands they themselves can enter at the command line to exercise it.

A variant of IntegrationTester, ExampleTester works the same way except the commands used to test the project come from a /** Usage ... */ comment inside the project's build.mill file. This is intended to make the build.mill file usable as documentation, such that a reader can skim the build.mill and see both the build configuration and the commands they themselves can enter at the command line to exercise it.

Implements a bash-like test DSL for educational purposes, parsed out from a Example Usage comment in the example's build.mill file. Someone should be able to read the Example Usage comment and know roughly how to execute the example themselves.

Each empty-line-separated block consists of one command (prefixed with >) and zero or more output lines we expect to get from the command (either stdout or stderr):

  1. If there are no expected output lines, we do not perform any assertions on the output of the command

  2. Output lines can be prefixed by error: to indicate we expect that command to fail.

  3. ... can be used to indicate wildcards, which match anything. These can be used alone as the entire line, or in the middle of another line

  4. Every line of stdout/stderr output by the command must match at least one line of the expected output, and every line of expected output must match at least one line of stdout/stderr. We ignore ordering of output lines.

For teaching purposes, the output lines do not show the entire output of every command, which can be verbose and confusing. They instead contain sub-strings of the command output, enough to convey the important points to a learner. This is not as strict as asserting the entire command output, but should be enough to catch most likely failure modes

Because our CI needs to run on Windows, we cannot rely on just executing commands in the bash shell, and instead we implement a janky little interpreter that reads the command lines and does things in-JVM in response to each one.

Attributes

Companion
class
Source
ExampleTester.scala
Supertypes
class Object
trait Matchable
class Any
Self type
class ExampleTester(val daemonMode: Boolean, val workspaceSourcePath: Path, millExecutable: Path, bashExecutable: String, val baseWorkspacePath: Path, val propagateJavaHome: Boolean, val cleanupProcessIdFile: Boolean) extends IntegrationTesterBase

Attributes

Companion
object
Source
ExampleTester.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Source
IntegrationTestSuite.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class IntegrationTester(val daemonMode: Boolean, val workspaceSourcePath: Path, val millExecutable: Path, val debugLog: Boolean, val baseWorkspacePath: Path, val propagateJavaHome: Boolean, val cleanupProcessIdFile: Boolean) extends Impl

Helper meant for executing Mill integration tests, which runs Mill in a subprocess against a folder with a build.mill and project files. Provides APIs such as eval to run Mill commands and out to inspect the results on disk. You can use modifyFile or any of the OS-Lib os.* APIs on the workspacePath to modify project files in the course of the test.

Helper meant for executing Mill integration tests, which runs Mill in a subprocess against a folder with a build.mill and project files. Provides APIs such as eval to run Mill commands and out to inspect the results on disk. You can use modifyFile or any of the OS-Lib os.* APIs on the workspacePath to modify project files in the course of the test.

Value parameters

daemonMode

Whether to run Mill in client-server mode. If false, Mill is run with --no-server

millExecutable

What Mill executable to use.

workspaceSourcePath

The folder in which the build.mill and project files being tested comes from. These are copied into a temporary folder and are not modified during tests

Attributes

Companion
object
Source
IntegrationTester.scala
Supertypes
trait Impl
trait AutoCloseable
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Source
IntegrationTester.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Source
IntegrationTesterBase.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
abstract class TestRootModule(baseModuleSourcePath: Path)(using millModuleEnclosing0: Enclosing, millModuleLine0: Line, millModuleFile0: File) extends RootModule0

A wrapper of RootModule0 meant for easy instantiation in test suites.

A wrapper of RootModule0 meant for easy instantiation in test suites.

Attributes

Source
TestBaseModule.scala
Supertypes
class RootModule0
trait Module
trait ModuleApi
trait Wrapper
class BaseClass
trait Cacher
trait Cacher
class Object
trait Matchable
class Any
Show all
object UnitTester

Attributes

Companion
class
Source
UnitTester.scala
Supertypes
class Object
trait Matchable
class Any
Self type
UnitTester.type
class UnitTester(module: TestRootModule, sourceRoot: Option[Path], resetSourcePath: Boolean, failFast: Boolean, threads: Option[Int], outStream: PrintStream, errStream: PrintStream, inStream: InputStream, debugEnabled: Boolean, env: Map[String, String], offline: Boolean)(using fullName: FullName) extends AutoCloseable

Value parameters

failFast

failFast mode enabled

module

The module under test

threads

explicitly used nr. of parallel threads

Attributes

Companion
object
Source
UnitTester.scala
Supertypes
trait AutoCloseable
class Object
trait Matchable
class Any
object UtestExampleTestSuite extends TestSuite

Attributes

Source
UtestExampleTestSuite.scala
Supertypes
class TestSuite
trait TestSuitePlatformSpecific
trait TestSuiteVersionSpecific
trait Executor
class Object
trait Matchable
class Any
Show all
Self type
abstract class UtestIntegrationTestSuite extends TestSuite, IntegrationTestSuite

Attributes

Source
UtestIntegrationTestSuite.scala
Supertypes
class TestSuite
trait TestSuitePlatformSpecific
trait TestSuiteVersionSpecific
trait Executor
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def asTestValue[A](a: Text[A])(using typeName: TPrint[A]): TestValue

Attributes

Source
helpers.scala
def asTestValue[A](name: String, a: A)(using typeName: TPrint[A]): TestValue

Attributes

Source
helpers.scala
def withTestClues[A](clues: TestValue*)(f: => A): A

Adds the provided clues to the thrown utest.AssertionError.

Adds the provided clues to the thrown utest.AssertionError.

Attributes

Source
helpers.scala