build_test library

Classes

FakeWatcher
A fake DirectoryWatcher.
GlobbingBuilder
A simple builder which globs files in a package and outputs a file that lists each matching file in alphabetical order into another file, one per line.
PackageAssetReader
Resolves using a PackageConfig before reading from the file system.
ReaderWriterTesting
Access to TestReaderWriter state for testing.
TestBuilder
A test Builder.
TestBuilderResult
TestReaderWriter
In-memory implementation of AssetReader and AssetWriter.

Constants

useAssetReader → const String
Marker constant that may be used in combination with resolveSources.

Properties

assetNotFoundException → TypeMatcher<AssetNotFoundException>
Matches instance of AssetNotFoundException.
final
invalidInputException → TypeMatcher<InvalidInputException>
Matches instance of InvalidInputException.
final
invalidOutputException → TypeMatcher<InvalidOutputException>
Matches instance of InvalidOutputException.
final
packageNotFoundException → TypeMatcher<PackageNotFoundException>
Matches instance of PackageNotFoundException.
final

Functions

addAssets(Map<AssetId, dynamic> assets, TestReaderWriter writer) → void
anyLogOf(dynamic messageOrMatcher) → Matcher
Matches LogRecord of any level whose message is messageOrMatcher.
appendExtension(String postFix, {String from = '', int numCopies = 1}) Map<String, List<String>>
A Builder.buildExtensions which operats on assets ending in from and creates outputs with postFix appended as the extension.
checkOutputs(Map<String, Object>? outputs, Iterable<AssetId> actualAssets, TestReaderWriter writer, {AssetId mapAssetIds(AssetId id) = _passThrough}) → void
Validates that actualAssets matches the expected outputs.
copyFrom(AssetId assetId) BuildBehavior
A build behavior which reads assetId and copies it's content into every output.
decodedMatches(dynamic expected, {Encoding? encoding}) → TypeMatcher<List<int>>
Decodes the value using encoding and matches it against expected.
infoLogOf(dynamic messageOrMatcher) → Matcher
Matches LogRecord of Level.INFO where message is messageOrMatcher.
makeAssetId([String? assetIdString]) → AssetId
recordLogs(dynamic run(), {String name = ''}) Stream<LogRecord>
Executes run with a new Logger, returning the resulting log records.
replaceExtension(String from, String to) Map<String, List<String>>
resolveAsset<T>(AssetId inputId, FutureOr<T> action(Resolver resolver), {PackageConfig? packageConfig, Set<AssetId>? nonInputsToReadFromFilesystem, bool? readAllSourcesFromFilesystem, Future<void>? tearDown, Resolvers? resolvers}) Future<T>
A convenience for using resolveSources with a single inputId from disk.
resolveSource<T>(String inputSource, FutureOr<T> action(Resolver resolver), {AssetId? inputId, PackageConfig? packageConfig, Set<AssetId>? nonInputsToReadFromFilesystem, bool? readAllSourcesFromFilesystem, Resolvers? resolvers}) Future<T>
A convenience method for using resolveSources with a single source file.
resolveSources<T>(Map<String, String> inputs, FutureOr<T> action(Resolver resolver), {PackageConfig? packageConfig, Set<AssetId>? nonInputsToReadFromFilesystem, bool? readAllSourcesFromFilesystem, String? resolverFor, String? rootPackage, FutureOr<void> assetReaderChecks(TestReaderWriter)?, Future<void>? tearDown, Resolvers? resolvers}) Future<T>
Resolves and runs action using a created resolver for inputs.
severeLogOf(dynamic messageOrMatcher) → Matcher
Matches LogRecord of Level.SEVERE where message is messageOrMatcher.
testBuilder(Builder builder, Map<String, Object> sourceAssets, {Set<String>? generateFor, bool isInput(String assetId)?, String? rootPackage, Map<String, Object>? outputs, void onLog(LogRecord log)?, void reportUnusedAssetsForInput(AssetId, Iterable<AssetId>)?, PackageConfig? packageConfig, Resolvers? resolvers, TestReaderWriter? readerWriter, bool verbose = false, bool enableLowResourceMode = false, bool flattenOutput = false}) Future<TestBuilderResult>
Runs builder in a test environment.
testBuilderFactories(Iterable<BuilderFactory> builderFactories, Map<String, Object> sourceAssets, {Iterable<PostProcessBuilderFactory> postProcessBuilderFactories = const [], Set<String>? generateFor, bool isInput(String assetId)?, String? rootPackage, Map<String, Object>? outputs, void onLog(LogRecord log)?, void reportUnusedAssetsForInput(AssetId, Iterable<AssetId>)?, PackageConfig? packageConfig, Resolvers? resolvers, Set<BuilderFactory> optionalBuilderFactories = const {}, Set<BuilderFactory> visibleOutputBuilderFactories = const {}, Map<BuilderFactory, List<String>> appliesBuilders = const {}, bool testingBuilderConfig = true, TestReaderWriter? readerWriter, bool verbose = false, bool enableLowResourceMode = false, bool flattenOutput = false}) Future<TestBuilderResult>
Runs builders from builderFactories and postProcessBuilderFactories in a test environment.
testBuilders(Iterable<Builder> builders, Map<String, Object> sourceAssets, {Iterable<PostProcessBuilder> postProcessBuilders = const [], Set<String>? generateFor, bool isInput(String assetId)?, String? rootPackage, Map<String, Object>? outputs, void onLog(LogRecord log)?, void reportUnusedAssetsForInput(AssetId, Iterable<AssetId>)?, PackageConfig? packageConfig, Resolvers? resolvers, Set<Builder> optionalBuilders = const {}, Set<Builder> visibleOutputBuilders = const {}, Map<Builder, List<String>> appliesBuilders = const {}, bool testingBuilderConfig = true, TestReaderWriter? readerWriter, bool verbose = false, bool enableLowResourceMode = false, bool flattenOutput = false}) Future<TestBuilderResult>
Runs builders and postProcessBuilders in a test environment.
warningLogOf(dynamic messageOrMatcher) → Matcher
Matches LogRecord of Level.WARNING where message is messageOrMatcher.
writeCanRead(AssetId assetId) BuildBehavior
A build behavior which writes either 'true' or 'false' depending on whether assetId can be read.

Typedefs

BuildBehavior = FutureOr Function(BuildStep buildStep, Map<String, List<String>> buildExtensions)
Overridable behavior for a Builder.build method.