From e50ebfc6fa30d4015e77ed3792db4818f5933711 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 26 Feb 2019 19:25:35 -0800 Subject: [PATCH] remove personal repo and replace with trivial example for smoke test (#28386) --- .../codegen/lib/coffee_app.dart | 58 ------------------- dev/integration_tests/codegen/lib/main.dart | 10 +--- .../codegen/lib/message.spec | 1 + .../codegen/lib/src/coffee.dart | 41 ------------- dev/integration_tests/codegen/pubspec.yaml | 13 +---- .../codegen/test_driver/main_test.dart | 4 ++ .../simple_codegen/build.yaml | 8 +++ .../simple_codegen/lib/builders.dart | 18 ++++++ .../simple_codegen/pubspec.yaml | 37 ++++++++++++ 9 files changed, 73 insertions(+), 117 deletions(-) delete mode 100644 dev/integration_tests/codegen/lib/coffee_app.dart create mode 100644 dev/integration_tests/codegen/lib/message.spec delete mode 100644 dev/integration_tests/codegen/lib/src/coffee.dart create mode 100644 dev/integration_tests/simple_codegen/build.yaml create mode 100644 dev/integration_tests/simple_codegen/lib/builders.dart create mode 100644 dev/integration_tests/simple_codegen/pubspec.yaml diff --git a/dev/integration_tests/codegen/lib/coffee_app.dart b/dev/integration_tests/codegen/lib/coffee_app.dart deleted file mode 100644 index daa5b4225f..0000000000 --- a/dev/integration_tests/codegen/lib/coffee_app.dart +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:inject/inject.dart'; - -// This is a compile-time generated file and does not exist in source. -import 'coffee_app.inject.dart' as generated; // ignore: uri_does_not_exist -import 'src/coffee.dart'; - -@module -class PourOverCoffeeModule { - @provide - @brandName - String provideBrand() => 'Coffee by Flutter Inc.'; - - @provide - @modelName - String provideModel() => 'PourOverSupremeFiesta'; - - @provide - @asynchronous - Future provideHeater() async => Stove(); - - @provide - Pump providePump(Heater heater) => NoOpPump(); -} - -class NoOpPump extends Pump { - @override - void pump() { - print('nothing to pump...'); - } -} - -class Stove extends Heater { - @override - bool get isHot => _isHot; - bool _isHot = false; - - @override - void off() { - _isHot = true; - } - - @override - void on() { - _isHot = true; - } -} - -@Injector([PourOverCoffeeModule]) -abstract class CoffeeApp { - static final Future Function(PourOverCoffeeModule) create = generated.CoffeeApp$Injector.create; - - @provide - CoffeeMaker getCoffeeMaker(); -} diff --git a/dev/integration_tests/codegen/lib/main.dart b/dev/integration_tests/codegen/lib/main.dart index b136fba220..41f755f0f9 100644 --- a/dev/integration_tests/codegen/lib/main.dart +++ b/dev/integration_tests/codegen/lib/main.dart @@ -4,18 +4,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_driver/driver_extension.dart'; - -import 'coffee_app.dart'; -import 'src/coffee.dart'; +import 'message.dart' as generated; // ignore: uri_does_not_exist Future main() async { enableFlutterDriverExtension(); - coffeeApp = await CoffeeApp.create(PourOverCoffeeModule()); runApp(ExampleWidget()); } -CoffeeApp coffeeApp; - class ExampleWidget extends StatefulWidget { @override _ExampleWidgetState createState() => _ExampleWidgetState(); @@ -34,9 +29,8 @@ class _ExampleWidgetState extends State { RaisedButton( child: const Text('Press Button, Get Coffee'), onPressed: () async { - final CoffeeMaker coffeeMaker = coffeeApp.getCoffeeMaker(); setState(() { - _message = coffeeMaker.brew(); + _message = generated.message; }); }, ), diff --git a/dev/integration_tests/codegen/lib/message.spec b/dev/integration_tests/codegen/lib/message.spec new file mode 100644 index 0000000000..13c2e9ead0 --- /dev/null +++ b/dev/integration_tests/codegen/lib/message.spec @@ -0,0 +1 @@ +final String message = 'Thanks for using PourOverSupremeFiesta by Coffee by Flutter Inc.'; diff --git a/dev/integration_tests/codegen/lib/src/coffee.dart b/dev/integration_tests/codegen/lib/src/coffee.dart deleted file mode 100644 index 5b33d77ce0..0000000000 --- a/dev/integration_tests/codegen/lib/src/coffee.dart +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:inject/inject.dart'; - -const Qualifier brandName = Qualifier(#brandName); -const Qualifier modelName = Qualifier(#modelName); - -class CoffeeMaker { - @provide - CoffeeMaker(this._heater, this._pump, this._brand, this._model); - - final Heater _heater; - final Pump _pump; - - @modelName - final String _model; - - @brandName - final String _brand; - - String brew() { - _heater.on(); - _pump.pump(); - print(' [_]P coffee! [_]P'); - final String message = 'Thanks for using $_model by $_brand'; - _heater.off(); - return message; - } -} - -abstract class Heater { - void on(); - void off(); - bool get isHot; -} - -abstract class Pump { - void pump(); -} diff --git a/dev/integration_tests/codegen/pubspec.yaml b/dev/integration_tests/codegen/pubspec.yaml index 0b13485f96..3204d245c3 100644 --- a/dev/integration_tests/codegen/pubspec.yaml +++ b/dev/integration_tests/codegen/pubspec.yaml @@ -10,11 +10,6 @@ dependencies: sdk: flutter flutter_driver: sdk: flutter - # TODO(jonahwilliams): replace with pub version when everything is compatible - inject: - git: - url: https://github.com/jonahwilliams/inject.dart - path: package/inject async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -76,11 +71,9 @@ dev_dependencies: yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" builders: - # TODO(jonahwilliams): replace with pub version when everything is compatible - inject_generator: - git: - url: https://github.com/jonahwilliams/inject.dart - path: package/inject_generator + # Note: path is relative from generated directory + simple_codegen: + path: ../../../simple_codegen flutter: uses-material-design: true diff --git a/dev/integration_tests/codegen/test_driver/main_test.dart b/dev/integration_tests/codegen/test_driver/main_test.dart index 33824ab46a..df5bf2419c 100644 --- a/dev/integration_tests/codegen/test_driver/main_test.dart +++ b/dev/integration_tests/codegen/test_driver/main_test.dart @@ -12,6 +12,10 @@ void main() { driver = await FlutterDriver.connect(); }); + tearDownAll(() async { + await driver.close(); + }); + test('Can execute generated code', () async { const String button = 'Press Button, Get Coffee'; await driver.tap(find.text(button)); diff --git a/dev/integration_tests/simple_codegen/build.yaml b/dev/integration_tests/simple_codegen/build.yaml new file mode 100644 index 0000000000..b5a63635eb --- /dev/null +++ b/dev/integration_tests/simple_codegen/build.yaml @@ -0,0 +1,8 @@ +# Read about `build.yaml` at https://pub.dartlang.org/packages/build_config +builders: + simple: + import: "package:simple_codegen/builders.dart" + builder_factories: + - simpleBuilder + build_extensions: {'.spec':['.dart']} + auto_apply: all_packages diff --git a/dev/integration_tests/simple_codegen/lib/builders.dart b/dev/integration_tests/simple_codegen/lib/builders.dart new file mode 100644 index 0000000000..0f2199aee1 --- /dev/null +++ b/dev/integration_tests/simple_codegen/lib/builders.dart @@ -0,0 +1,18 @@ +import 'package:build/build.dart'; + +/// The builder factory used by the `build.yaml` script. +Builder simpleBuilder(BuilderOptions options) => SimpleBuilder(); + +/// A trivial builder which copies the contents of a `spec` file into a `dart` file. +class SimpleBuilder extends Builder { + @override + Map> get buildExtensions => const >{'.spec' : ['.dart']}; + + + @override + Future build(BuildStep buildStep) async { + final AssetId output = buildStep.inputId.changeExtension('.dart'); + final String contents = await buildStep.readAsString(buildStep.inputId); + buildStep.writeAsString(output, contents); + } +} diff --git a/dev/integration_tests/simple_codegen/pubspec.yaml b/dev/integration_tests/simple_codegen/pubspec.yaml new file mode 100644 index 0000000000..cc475ffc1f --- /dev/null +++ b/dev/integration_tests/simple_codegen/pubspec.yaml @@ -0,0 +1,37 @@ +name: simple_codegen +description: A package for testing codegen + +dependencies: + build: 1.1.1 + + analyzer: 0.35.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + html: 0.13.3+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + source_span: 1.5.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + +environment: + # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. + sdk: ">=2.0.0-dev.68.0 <3.0.0" + +# PUBSPEC CHECKSUM: 6ccf