build_test 3.3.0-dev.3  build_test: ^3.3.0-dev.3 copied to clipboard
build_test: ^3.3.0-dev.3 copied to clipboard
Utilities for writing unit tests of Builders.
3.3.0-dev.3 #
- Read build configs using AssetReaderso they're easier to test: you can now pass inbuild.yamllike any other asset.
- Bug fix: don't crash when a builder logs during a testBuilderorresolveSourcecall outside a test.
- Remove unused deps: async,convert.
- Remove unused dev_deps: collection.
3.3.0-dev.2 #
- Files loaded from disk for resolveSourcesandtestBuildersthat are in the same package as explicitly-passed test inputs are now loaded if they match the default globs, such aslib/**, instead of ignored. This more closely matches version 2 behavior.
3.3.0-dev.1 #
- Use build3.0.0-dev.1.
- Use build_resolvers3.0.0-dev.1.
3.2.0 #
- Fixes when passing a readerWritertotestBuilders: don't count initial assets as outputs; do set up packages for initial assets; only apply builders to packages mentioned insourceAssets.
- Add readAllSourcesFromFilesystemparameter toresolveSources. Set it totrueto make the method behave as it did inbuild_test2.2.0.
- Fix to resolveSourceserror handling.
3.1.0 #
- Add inputsTrackedForandresolverEntrypointsTrackedFortoReaderWriterTesting, so tests can determine what each build step read and resolved.
- Add loadIsolateSourcestoReaderWriterTesting. It loads all real sources visible to the test into memory.
- testBuilderdefault- onLognow works outside of tests: it falls back to- printinstead of crashing.
- Update README.md.
3.0.0 #
Breaking changes:
- Breaking change: removed tearDownparameter toresolveSourcesfor keeping resolvers across multiple tests.
- Breaking change: tests must use new TestReaderWriterinstead ofInMemoryAssetReaderandInMemoryAssetWriter.
- Breaking change: testBuilderno longer accepts areaderand awriter. Instead it returns aTestBuilderResultwith theTestReaderWriterthat was used.
- Breaking change: resolveSourcesno longer automatically reads non-input files from the filesystem; specify explicitly which non-input files the test should read innonInputsToReadFromFilesystem.
- Breaking change: remove MultiAssetReader. Load the source into oneTestReaderWriterinstead.
- Breaking change: TestReaderWriter.assetsReaddoes not take into account details of the build, it's just what was actually read. UseTestReaderWriter.inputsTrackedfor what was recorded as an input. Note that resolver entrypoints are now tracked separately from inputs, seeTestReaderWriter.resolverEntrypointsTracked.
- Breaking change: Remove StubAssetReader. UseTestReaderWriterinstead.
Other user-visible changes:
- resolveSourcesand- testBuildernow do a full- build_runnerbuild, with configuration as much as possible based on the some parameters.
- Add testBuildersto run a test build with multiple builders.
- Add optionalBuilderstotestBuildersto have some builders be optional.
- Add visibleOutputBuilderstotestBuildersto have some builders write their output next to their inputs.
- Add testingBuilderConfigtotestBuildersto control builder config override.
- Add resolversparameter totestBuildandtestBuilders.
- Add readerWriterandenableLowResourceModeparameters totestBuildandtestBuilders.
- TestReaderWriterwrites and deletes are notified to- FakeWatcher.
- TestReaderWritertracks- assetsWritten.
- Support checks on reader state after a build action in resolveSources.
Versions:
- Bump the min SDK to 3.7.0.
- Use build_runner_core9.0.0.
Internal changes:
- Start using package:build/src/internal.dart.
- Refactor BuildCacheReadertoBuildCacheAssetPathProvider.
- Refactor FileBasedAssetReaderandFileBasedAssetWritertoReaderWriter.
2.2.3 #
- Bump the min sdk to 3.6.0.
- Allow analyzer version 7.x.
2.2.2 #
- Bump the min sdk to 3.0.0.
- Support the latest version of package:test_core.
2.2.1 #
- Avoid passing a nullable value to Future.value.
- Update to build_resolvers 2.4.0, which resolves some race conditions when using multiple resolvers instances.
2.2.0 #
- Forward logs from testBuildertoprintOnFailureby default.
2.1.7 #
- Allow the latest test_core (version 5.x).
2.1.6 #
- Fix bug in package config file loading.
- Raise the minimum SDK constraint to 2.18.
2.1.5 #
- Allow the latest analyzer.
2.1.4 #
- Update pub runreferences todart run.
- Drop package:pedantic dependency and replace it with package:lints.
2.1.3 #
- Use allowedOutputsinTestBuilderinstead of computing them again.
2.1.2 #
- Allow the latest package:test_core.
2.1.1 #
- Allow analyzer version 2.x.x.
2.1.0 #
- Migrate internal builders of this package to null safety
- Require build_config version 1.0.0.
2.0.0 #
- Migrate package:build_test/build_test.dartto null safety.
- Update to build 2.x.
- Update to build_resolvers 2.x.
1.3.7 #
- Update to analyzer 1.x.
- Update to glob 2.x.
1.3.6 #
- Allow the null safe pre-release version of html.
1.3.5 #
- Allow the null safe pre-release version of package_configandwatcher.
1.3.4 #
- Allow the null safe pre-release version of stream_transform.
1.3.3 #
- Return an empty stream instead of throwing from
PackageAssetReader.findAssetswhen passed a non-existing package name.
- Allow the null safe migration package versions for crypto,glob,logging, andpackage_config.
1.3.2 #
- Fix the test/index.htmlnot generating by default.
1.3.1 #
- 
Allow build version 1.6.x.
- 
Use $package$placeholder instead of$test$.
1.3.0 #
- Add support for running generated .browser_test.dartdirectly instead of expecting the test runner with the query stringdirectRun=true. It is no longer necessary to create a build config which generates for*_test.dartfiles inbuild_web_compilers, the default config generates for.browser_test.dartfiles which are used bydebug.html.
1.2.2 #
- Allow package:build versions through 1.5.x.
1.2.1 #
- Improve/fix testBuilderdocumentation.
- Update test bootstrap builder to copy language version comments from the test file if present.
1.2.0 #
- Add support for recognizing custom platforms in TestOn annotations during bootstrapping.
1.1.0 #
- Add support for enabling experiments via withEnabledExperimentszones from package:build, as well as forwarding thepackageConfigargument fromresolve*apis through to the defaultResolver.- Note: If passing your own Resolverthese things are still your responsibility.
 
- Note: If passing your own 
- Added the ability to pass a PackageConfigtotestBuilder, which is used to set the language version of each package.- The resolver created from testBuilderwill also now respect thewithEnabledExperimentszone.
 
- The resolver created from 
1.0.0 #
- Removed dependency on package:package_resolver, changed topackage:package_config.- All apis which used to take a PackageResolvernow take aPackageConfig.
 
- All apis which used to take a 
- Require SDK version 2.7.0.
0.10.12+1 #
- Allow the latest test_core package (0.3.x).
0.10.12 #
- Fix a bug with the resolve*apis where they would leak unhandled async errors to client code if the provided action callback threw an error.
0.10.11 #
- Add support for the new $package$placeholder.
Potentially Breaking Change #
- Only add the non-lib placeholders when a root package is specified
- Infer the root package when there is only one package in the sources
- This is being released as a non-breaking change because the only expected
use cases already would have been broken - findAssetscalls already required a root package.
 
0.10.10 #
- Allow reading of assets written from the same build step.
- This mirrors the latest behavior in build_runner_core.
 
- Require SDK version 2.6.0to enable extension methods.
0.10.9+1 #
- Fix the DebugTestBuilderon windows.
- Fix PackageAssetReaderon windows.
0.10.9 #
- Allow tracking of reported unused assets in testBuildercalls with thereportUnusedAssetsForInput(AssetId input, Iterable<AssetId> unused)callback.
0.10.8 #
- Allow a custom AssetReader to be passed to testBuilder. This will be used as a fallback for any sources that don't exist in thesourceAssetsmap.
0.10.7+3 #
- Handle the case where the root package in a PackageAssetReaderis a fake package.
0.10.7+2 #
- Avoid throwing for missing files from PackageAssetReader.canRead.
0.10.7+1 #
- Allow build_config0.4.x.
0.10.7 #
- Support the latest version of package:html.
- Only generate bootstrap scripts for supported platforms based on TestOnannotations.
0.10.6 #
- Allow build_resolvers version 1.0.0.
0.10.5 #
- Improve error messages for unresolvable URIs in the PackageAssetReader.
0.10.4 #
- Allow using PackageAssetReaderwhen the current working directory is not the root package directory as long as it uses a pub layout.
0.10.3+4 #
- Increased the upper bound for package:analyzerto<0.35.0.
0.10.3+3 #
- Increased the upper bound for package:analyzerto '<0.34.0'.
0.10.3+2 #
- Declare support for package:buildversion 1.0.0.
0.10.3+1 #
- Increased the upper bound for the sdk to <3.0.0.
0.10.3 #
- Require test version ^0.12.42 and use TypeMatcher.
- Improve performance of test methods which use a Resolverby keeping a cached instance ofAnalyzerResolvers.
0.10.2+4 #
- Allow the latest build_config.
0.10.2+3 #
- Remove package:build_barback dependency, and use public apis from package:test to directly do the bootstrapping instead of wrapping the transformer.
0.10.2+2 #
- Avoid looking for files from Uri.pathpaths.
0.10.2+1 #
- Add back an implementation of findAssetsinPackageAssetReader.
0.10.2 #
- Added a DebugIndexBuilder, which by default generates atest/index.htmlwith links to debug tests in yourtest/**_test.dartfolder, linking to the generated*_test.debug.htmlfiles. NOTE: This only works for web-based tests.
- Fix PackageAssetReaderwhen running with a package map pointing to a "packages" directory structure, as is generated bybuild_runner. Drop support for a brokenfindAssetsimplementation.
0.10.1+1 #
- Replace BarbackResolverswithAnalyzerResolversfrombuild_resolversby default.
0.10.1 #
- Allow overriding the Resolversused forresolve*utilities.
- Bug Fix: Don't call the actionmultiple times when there are multiple sources passed toresolve*.
0.10.0 #
- Added automatic generation of .debug.htmlfiles for all tests, which can be loaded in the browser to directly run tests and debug them without going through the package:test runner.
- Update to package:build version 0.12.0.
- Removed CopyBuilderin favor ofTestBuilderwhich takes closures to change behavior rather than adding configuration for every possible modification.
- Added support for the special placeholder {$lib/$test/$web}assets supported by thebuild_runnerandbazel_codegenimplementations ofpackage:build. For an example seetest/test_builder_test.dart. Note that this is technically a BREAKING CHANGE, as additional inputs will be matched for overzealous builders (likeTestBuilder).
- Added resolverForas an optional parameter toresolveSources. By default aResolveris returned for the first asset provided; to modify that the name of another asset may be provided. This is a BREAKING CHANGE, as previously the last asset was used.
0.9.4 #
- Added InMemoryAssetReader.shareAssetCacheconstructor. This is useful for the case where the reader should be kept up to date as assets are written through a writer.
- Added buildInputsstream toCopyBuilderwhich emits an event for eachBuildStep.inputIdat the top of thebuildmethod.
- CopyBuilderautomatically skips the placeholder files (any file ending in- $). This is technically breaking but should not affect any real users and is not being released as a breaking change.
- Changed TestBootstrapBuilderto only target_test.dartfiles.
0.9.3 #
- Added resolveSources, a way to resolve multiple libraries for testing, including any combination of fake files (in-memory, created in the test) and real ones (from on-disk packages):
test('multiple assets, some mock, some on disk', () async {
  final real = 'build_test|test/_files/example_lib.dart';
  final mock = 'build_test|test/_files/not_really_here.dart';
  final library = await resolveSources(
    {
      real: useAssetReader,
      mock: r'''
        // This is a fake library that we're mocking.
        library example;
        // This is a real on-disk library we are using.
        import 'example_lib.dart';
        class ExamplePrime extends Example {}
      ''',
    },
    (resolver) => resolver.findLibraryByName('example'),
  );
  final type = library.getType('ExamplePrime');
  expect(type, isNotNull);
  expect(type.supertype.name, 'Example');
});
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,- StubAssetReaderand- PackageAssetReadernow implement the- MultiPackageAssetReaderinterface.
- testBuildernow supports- Builders that call- findAssetsin non-root packages.
- Added a GlobbingBuilderwhich globs files in a package.
- Added the RecordingAssetReaderinterface, which adds theIterable<AssetId> get assetsReadgetter.
- InMemoryAssetReadernow implements- RecordingAssetReader.
- 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 return- Futurefrom- canRead
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#assetsand- InMemoryAssetWriter#assetshave changed to a type of- Map<AssetId, DatedValue>from a type of- Map<AssetId, DatedString>.- DatedValuehas both a- stringValueand- bytesValuegetter.
- InMemoryAssetReaderand- InMemoryAssetWriterhave been updated to implement the new- AssetReaderand- AssetWriterinterfaces (see the- buildpackage CHANGELOG for more details).
- InMemoryAssetReader#cacheAssethas been changed to two separate methods,- void cacheStringAsset(AssetId id, String contents)and- void 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.