Version 0.03 (2018-02-28)
Add plugin to
resolvers += "Sonatype Releases" at "https://oss.sonatype.org/content/groups/public/" addSbtPlugin("com.github.pawelkrol" % "sbt-commtest" % "0.03")
build.sbt with settings to configure
lazy val root = (project in file(".")). settings( Defaults.coreDefaultSettings ++ Seq( mainProgram := "program.src", packagerOptions := "-m64 -t64 -x1", scalaVersion := "2.12.4", startAddress := 0x1000 ) )
sbt-commtest assumes the following set of conventions is respected:
Directory structure of a project reflects an example layout:
. ├── ... ├── src │ ├── main # Source code files │ └── test # CommTest unit tests └── ...
src/mainsubdirectory consists of source program files (recognised by a
.srcextension) as well as supplementary include files (identified with an
.incextension). Include files will not be compiled as standalone binaries that become subjects to test, and they will be ignored by a test engine. They are not even expected to compile successfully without a context of their parent program files. On the other hand, all source code files (
.src) are compiled and their result binaries may be included in unit tests.
src/testsubdirectory consists of Scala unit tests conforming to documented CommTest requirements. There is one exception to those requirements though. Due to the fact that
sbt-commtestplugin puts all result files in a
targetsubdirectory, you must refer them from
targetand not from your source code directory in unit tests configuration. For example, if your
src/mainsubdirectory contains a single source code file to test named
program.src, all your test classes will need to specify appropriate references to both output binary and label log files (see CommTest documentation for more details on defining your unit tests) that will be written into
targetsubdirectory during compilation process:
outputPrg = "target/program.prg" // rather than "program.prg" labelLog = "target/program.log" // rather than "program.log"
Please note that
src/main/program.src compiles to
target/program.prg, while label log is written to
target/program.log. Future versions of this plugin will improve this aspect of setting up your tests in a way that instead of specifying targets explicitly you will only need to indicate a source code file under test.
Start sbt in an interactive mode:
Compile the project:
Run the tests:
Define the main program file (as a relative path to a directory containing all of your source code files) and specify an initial start address in your
mainProgram := "program.src" startAddress := 0x1000
In an above example
target/program would be created by packaging
target/program.prg. Note that the main program file does not need to end with a
.src extension (you may not necessarily want to unit test it before packaging), it will be successfully compiled and packaged nonetheless.
Package the program:
mainProgram setting will also determine a file name of a target D64 disk image (e.g.
Execute the program within an emulator (optionally with an additional hardware simulated):
sbt> run sbt> run-ide64 sbt> run-plus60k
Delete files produced by the build:
CommTest is built on top of CPU 6502 Simulator, which defaults to a very extensive logging configuration. Running tests without applying any modifications to these settings will result in dumping a very detailed processing output to a
In order to avoid running out of available disk space quickly it is recommended to minimise the logging output or even turn off logging completely. This is accomplished by creating an appropriately configured
src/test/resources/logback-test.xml file. Should you lack an inspiration how to do it, see an example logback-test.xml.
COPYRIGHT AND LICENCE
Copyright (C) 2017, 2018 by Pawel Krol.
This library is free open source software; you can redistribute it and/or modify it under the same terms as Scala itself, either Scala version 2.12.4 or, at your option, any later version of Scala you may have available.