-
Notifications
You must be signed in to change notification settings - Fork 6
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 service.
- Loading branch information
1 parent
afefe34
commit fec3f8d
Showing
16 changed files
with
608 additions
and
37 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
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( | ||
HostEndpoint.fromJson(json.decode(arguments[0])), | ||
[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
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 |
---|---|---|
|
@@ -14,3 +14,5 @@ dependencies: | |
|
||
dev_dependencies: | ||
dart_flutter_team_lints: ^3.0.0 | ||
dart_model: any | ||
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,33 @@ | ||
// 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:_macro_runner/macro_runner.dart'; | ||
import 'package:dart_model/dart_model.dart'; | ||
import 'package:macro_service/macro_service.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group(MacroRunner, () { | ||
test('runs macros', () async { | ||
final builder = MacroBuilder(); | ||
final bundle = | ||
await builder.build(File.fromUri(Isolate.packageConfigSync!), [ | ||
QualifiedName( | ||
'package:_test_macros/declare_x_macro.dart#DeclareXImplementation') | ||
]); | ||
|
||
final serverSocket = await ServerSocket.bind('localhost', 0); | ||
|
||
final runner = MacroRunner(); | ||
runner.run(bundle, HostEndpoint(port: serverSocket.port)); | ||
|
||
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
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,22 @@ | ||
// 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 'package:_macro_client/macro_client.dart'; | ||
import 'package:_macro_server/macro_server.dart'; | ||
import 'package:_test_macros/declare_x_macro.dart'; | ||
import 'package:macro_service/macro_service.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group(MacroServer, () { | ||
test('serves a macro service', () async { | ||
final service = TestMacroHostService(); | ||
final server = await MacroServer.serve(service: service); | ||
|
||
MacroClient().run(server.endpoint, [DeclareXImplementation()]); | ||
}); | ||
}); | ||
} | ||
|
||
class TestMacroHostService implements MacroHostService {} |
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