-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build macros, run them, serve a (test) service, host.
- Loading branch information
1 parent
00a097a
commit 17e4220
Showing
29 changed files
with
1,185 additions
and
103 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,8 @@ stages: | |
- format: | ||
sdk: | ||
- dev | ||
- unit_test: | ||
- test: --test-randomize-ordering-seed=random | ||
os: | ||
- linux | ||
- windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ dependencies: | |
|
||
dev_dependencies: | ||
dart_flutter_team_lints: ^3.0.0 | ||
test: ^1.25.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
import 'dart:isolate'; | ||
|
||
import 'package:_macro_builder/macro_builder.dart'; | ||
import 'package:dart_model/dart_model.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group(MacroBuilder, () { | ||
test('bootstrap matches golden', () async { | ||
final script = MacroBuilder.createBootstrap([ | ||
QualifiedName('package:_test_macros/declare_x_macro.dart#DeclareX'), | ||
QualifiedName('package:_test_macros/declare_y_macro.dart#DeclareY'), | ||
QualifiedName( | ||
'package:_more_macros/other_macro.dart#OtherMacroImplementation') | ||
]); | ||
|
||
expect(script, ''' | ||
import 'package:_test_macros/declare_x_macro.dart' as m0; | ||
import 'package:_test_macros/declare_y_macro.dart' as m1; | ||
import 'package:_more_macros/other_macro.dart' as m2; | ||
import 'dart:convert'; | ||
import 'package:_macro_client/macro_client.dart'; | ||
import 'package:macro_service/macro_service.dart'; | ||
void main(List<String> arguments) { | ||
MacroClient.run( | ||
endpoint: HostEndpoint.fromJson(json.decode(arguments[0])), | ||
macros: [m0.DeclareX(), m1.DeclareY(), m2.OtherMacroImplementation()]); | ||
} | ||
'''); | ||
}); | ||
|
||
test('builds macros', () async { | ||
final builder = MacroBuilder(); | ||
|
||
final bundle = | ||
await builder.build(File.fromUri(Isolate.packageConfigSync!), [ | ||
QualifiedName( | ||
'package:_test_macros/declare_x_macro.dart#DeclareXImplementation') | ||
]); | ||
|
||
expect(File(bundle.executablePath).existsSync(), true); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,8 @@ stages: | |
- format: | ||
sdk: | ||
- dev | ||
- unit_test: | ||
- test: --test-randomize-ordering-seed=random | ||
os: | ||
- linux | ||
- windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
import 'package:_macro_client/macro_client.dart'; | ||
import 'package:_test_macros/declare_x_macro.dart'; | ||
import 'package:macro_service/macro_service.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group(MacroClient, () { | ||
test('connects to service', () async { | ||
final serverSocket = await ServerSocket.bind('localhost', 0); | ||
|
||
unawaited(MacroClient.run( | ||
endpoint: HostEndpoint(port: serverSocket.port), | ||
macros: [DeclareXImplementation()])); | ||
|
||
expect( | ||
serverSocket.first.timeout(const Duration(seconds: 10)), completes); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.