[testing] Add FileCheck API #4749
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an extension-method based FileCheck API. This builds off of @jackkoenig's original FileCheck trait inside ChiselSpec and repackages it for publishing.
This makes a number of deviations from the original version:
Taking (1) and (2) together, this is intended to not duplicate methods which are already availble via ChiselStage. Specifically, I am intending the API to be used like:
Things are done this way to try to make the APIs as orthogonal as possible without too many redundant ways to accomplish the same thing.
(3): is added for convenience of testing. On failure, this provides an output that approximates what you get from lit (LLVM's Integrated Tester). This additionally provides a rerun script that you can just copy-paste into a terminal to reproduce the failure.
For ease of reproduction, both the input and the check are written to files with predictable names in a temporary directory underneath what is provided by an implementation of the
HasTestingDirectory
type class. Having both the input and check file are necessary to do easy reruns.This is stacked on #4750.
Release Notes
Add
chisel3.testing.FileCheck
andchisel3.testing.scalatest.FileCheck
trait for writing FileCheck-based tests. This is useful for testing generators where you want to examine the output (FIRRTL or Verilog) as opposed to run a simulation. This is intended to complement ChiselSim.