Skip to main content

smf_pipeline 0.5.0 copy "smf_pipeline: ^0.5.0" to clipboard
smf_pipeline: ^0.5.0 copied to clipboard

The generation pipeline of the SMF CLI. Selects modules, validates their contributions against the roles they declare, and generates a Flutter app.

example/README.md

Test an SMF module with the contract harness #

The tests of a module package check the module with package:smf_pipeline/testing.dart. This test is for LoggingModule, the module of the example of smf_contracts, in a package smf_logging with smf_flutter_core, smf_pipeline and test as dev dependencies:

import 'package:smf_contracts/smf_contracts.dart';
import 'package:smf_flutter_core/smf_flutter_core.dart';
import 'package:smf_logging/smf_logging.dart';
import 'package:smf_pipeline/smf_pipeline.dart';
import 'package:smf_pipeline/testing.dart';
import 'package:test/test.dart';

void main() {
  final registry = ModuleRegistry(const [FlutterCoreModule(), LoggingModule()]);

  test('every app of the module follows the rules of its roles', () async {
    final results = await ContractHarness(registry).checkAll();
    for (final result in results) {
      expect(result.errors, isEmpty, reason: '${result.contractCase}');
    }
  });

  test('bootstrap() prints the log records first', () async {
    final result = await ContractHarness(registry).check(
      const ContractCase('logging', requested: [LoggingModule.id]),
    );
    // What the first phase of the start-up runs, whichever module provides
    // the app entry and renders it into bootstrap().
    final early = result.app!.socketOrders[AppEntryRole.bootstrapEarly]!;
    expect(
      [
        for (final collected in early.contributions)
          (collected.contribution as SocketContribution).fragment!.code,
      ],
      [contains('Logger.root.onRecord.listen')],
    );
  });

  test('the package follows the rules of a module package', () {
    expect(
      const ModulePackage(
        'smf_logging',
        testModules: {'smf_flutter_core'},
      ).problems(),
      isEmpty,
    );
  });
}
  • checkAll() renders in memory every app that matters for the modules of the registry, here the app with flutter_core alone and the app with logging, and checks each against the rules of the module model.
  • check() renders one app. result.app holds its files and, in socketOrders, what each socket got, in the order it was rendered; result.hook holds the data and the roles of the app, as the hooks of the roles got them. So a test checks what the module gives a role through the role, whichever module provides it, rather than in the files of that module.
  • ModulePackage checks what the package imports and depends on. flutter_core provides the app entry of the apps that the tests render, which is why it is a test module.

Test a module describes the harness and the cases it builds.

0
likes
0
points
979
downloads

Documentation

Documentation

Publisher

verified publishersaymyframe.com

Weekly Downloads

The generation pipeline of the SMF CLI. Selects modules, validates their contributions against the roles they declare, and generates a Flutter app.

Homepage
Repository (GitHub)
View/report issues

Topics

#flutter #cli #code-generation #modules

License

unknown (license)

Dependencies

analyzer, args, file, mason, meta, pub_semver, smf_contracts, yaml

More

Packages that depend on smf_pipeline