build_test 0.9.2
build_test: ^0.9.2 copied to clipboard
Utilities for writing unit tests of Builders.
0.9.2 #
- Add
inputExtensionargument toCopyBuilder. When used the builder with throw if any assets are provided that don't match the input extension.
0.9.1 #
- Allow
build_barbackversion0.5.x. The breaking behavior change should not impact test uses that don't already have a version constraint on that package.
0.9.0 #
- Added the
TestBootstrapBuilderunder thebuilder.dartlibrary. This can be used to bootstrap tests similar to thetest/pub_serveTransformer.- Known Issue: Custom html files are not supported.
- Breaking: All
AssetReader#findAssetsimplementations now return aStream<AssetId>to match the latestbuildpackage. - Breaking: The
DatedValue,DatedString, andDatedBytesapis are now gone, since timestamps are no longer used by package:build. Instead theInMemoryAssetReaderand other apis take aMap<AssetId, dynamic>, and will automatically convert anyStringvalues intoList<int>values. - Breaking: The
outputsmap oftestBuilderworks a little bit differently due to the removal ofDatedValueandDatedString.- If a value provided is a
String, then the asset is by default decoded using UTF8, and matched against the string. - If the value is a
matcher, it will match againt the actual bytes of the asset (inList<int>form). - A new matcher was added,
decodedMatches, which can be combined with other matchers to match against the string contents. For example, to match a string containing a substring, you would dodecodedMatches(contains('some substring')).
- If a value provided is a
0.8.0 #
InMemoryAssetReader,MultiAssetReader,StubAssetReaderandPackageAssetReadernow implement theMultiPackageAssetReaderinterface.testBuildernow supportsBuilders that callfindAssetsin non-root packages.- Added a
GlobbingBuilderwhich globs files in a package. - Added the
RecordingAssetReaderinterface, which adds theIterable<AssetId> get assetsReadgetter. InMemoryAssetReadernow implementsRecordingAssetReader.- Breaking: The
MultiAssetReadernow requires all its wrapped readers to implement theMultiPackageAssetReaderinterface.- This should not affect most users, since all readers provided by this package now implement that interface.
0.7.1 #
-
Add
mapAssetIdsargument tocheckOutputsfor cases where the logical asset location recorded by the builder does not match the written location. -
Add
recordLogs, a top-level function that invokesscopeLogand captures the resultingStream<LogRecord>for testing. Can be used with the providedanyLogOf,infoLogOf,warningLogOf,severeLogOfmatchers in order to test a build process:
test('should log "uh oh!"', () async {
final logs = recordLogs(() => runBuilder());
expect(logs, emitsInOrder([
anyLogOf('uh oh!'),
]);
});
- Add the constructors
forPackagesandforPackageRoottoPackageAssetReader- these are convenience constructors for pointing to a small set of packages (fake or real) for testing purposes. For example:
test('should resolve multiple libraries', () async {
reader = new PackageAssetReader.forPackages({
'example_a': '_libs/example_a',
'example_b': '_libs/example_b',
});
expect(await reader.canRead(fileFromExampleLibA), isTrue);
expect(await reader.canRead(fileFromExampleLibB), isTrue);
expect(await reader.canRead(fileFromExampleLibC), isFalse);
});
0.7.0+1 #
- Switch to a typedef from function type syntax for compatibility with older SDKs.
0.7.0 #
- Breaking:
resolveSourceandresolveAssetnow take anactionto perform with the Resolver instance.
0.6.4+1 #
- Allow
package:build_barbackv0.4.x
0.6.4 #
- Allow
package:buildv0.10.x AssetReaderimplementations always returnFuturefromcanRead
0.6.3 #
- Added
resolveAsset, which is similar toresolveSourcebut specifies a real asset that lives on the file system. For example, to resolve the main library ofpackage:collection:
var pkgCollection = new AssetId('collection', 'lib/collection.dart');
var resolver = await resolveAsset(pkgCollection);
// ...
- Supports
package:build_barback >=0.2.0 <0.4.0.
0.6.2 #
- Internal version bump.
0.6.1 #
- Declare an output extension in
_ResolveSourceBuilderso it is not skipped
0.6.0 #
- Support build 0.9.0
- Rename
hasInputtocanReadinAssetReaderimplementations - Replace
declareOutputswithbuildExtensionsinBuilderimplementations
- Rename
- Breaking
CopyBuilderno longer has anoutputPackagefield since outputs can only ever be in the same package as inputs.
0.5.2 #
- Add
MultiAssetReaderto the public API.
0.5.1 #
- Add
PackageAssetReader, a standalone asset reader that uses aPackageResolverto map anAssetIdto a location on disk. - Add
resolveSource, a top-level function that can resolve arbitrary Dart source code. This can be useful in testing your own code that uses aResolverto do type checks.
0.5.0 #
- Add
findAssetsimplementations to StubAssetReader an InMemoryAssetReader - BREAKING: InMemoryAssetReader constructor uses named optional parameters
0.4.1 #
- Make
scopeLogvisible so tests can be run with an availablelogwithout going through runBuilder.
0.4.0+1 #
- Bug Fix: Correctly identify missing outputs in testBuilder
0.4.0 #
Updates to work with build version 0.7.0.
New Features #
- The
testBuildermethod now acceptsList<int>values for bothsourceAssetsandoutputs. - The
checkOutputsmethod is now public.
Breaking Changes #
- The
testBuildermethod now requires aRecordingAssetWriterinstead of just anAssetWriterfor thewriterparameter. - If a
Matcheris provided as a value inoutputs, then it will match against the same value that was written. For example if your builder useswriteAsStringthen it will match against that string. If you usewriteAsBytesthen it will match against those bytes. It will not automatically convert to/from bytes and strings. - Deleted the
makeAssetandmakeAssetsmethods. There is no moreAssetclass so these don't really have any value any more. - The signature of
addAssetshas changed tovoid addAssets(Map<AssetId, dynamic> assets, InMemoryAssetWriter writer). Values of the map may be eitherStringorList<int>. InMemoryAssetReader#assetsandInMemoryAssetWriter#assetshave changed to a type ofMap<AssetId, DatedValue>from a type ofMap<AssetId, DatedString>.DatedValuehas both astringValueandbytesValuegetter.InMemoryAssetReaderandInMemoryAssetWriterhave been updated to implement the newAssetReaderandAssetWriterinterfaces (see thebuildpackage CHANGELOG for more details).InMemoryAssetReader#cacheAssethas been changed to two separate methods,void cacheStringAsset(AssetId id, String contents)andvoid cacheBytesAsset(AssetId id, List<int> bytes).- The
equalsAssetmatcher has been removed, since there is no moreAssetclass.
0.3.1 #
- Additional capabilities in testBuilder:
- Filter sourceAssets to inputs with
isInput - Get log records
- Ignore output expectations when
outputsis null - Use a custom
writer
- Filter sourceAssets to inputs with
0.3.0 #
- BREAKING removed testPhases utility. Tests should be using testBuilder
- Drop dependency on build_runner package
0.2.1 #
- Support the package split into build/build_runner/build_barback
- Expose additional test utilities that used to be internal to build
0.2.0 #
- Upgrade build package to 0.4.0
- Delete now unnecessary
GenericBuilderTransformerand useBuilderTransformerin the tests.
0.1.2 #
- Add
logLevelandonLognamed args totestPhases. These can be used to test your log messages, seetest/utils_test.dartfor an example.
0.1.1 #
- Allow String or Matcher for expected output values in
testPhases.
0.1.0 #
- Initial version, exposes many basic utilities for testing
Builders using in memory data structures. Most notably, thetestPhasesmethod.