From 8dc5ece999d257bbf68c451bc34ed57fe16dfffa Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 18 Sep 2024 15:52:11 -0700 Subject: [PATCH 01/22] Adds vscode workspace with impeller test runner --- .gitignore | 1 - .vscode/extensions.json | 17 ---- engine.code-workspace | 197 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 18 deletions(-) delete mode 100644 .vscode/extensions.json create mode 100644 engine.code-workspace diff --git a/.gitignore b/.gitignore index 57696b6cdc409..9abe6831d2794 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,6 @@ xcuserdata .project .settings/ .vscode/ -!.vscode/extensions.json # packages file containing multi-root paths .packages.generated diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 314960ffa5d1b..0000000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "recommendations": [ - // Uses github-styled markdown preview, which supports more features than the default markdown preview. - "bierner.github-markdown-preview", - - // Flutter and Dart extensions. - "Dart-Code.dart-code", - - // Supports C/C++ in the engine. - // See https://github.com/flutter/engine/blob/main/docs/contributing/Setting-up-the-Engine-development-environment.md#vscode-with-cc-intellisense-cc - "llvm-vs-code-extensions.vscode-clangd", - - // Auto-formats C/C++ code. - // https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#cc - "xaver.clang-format", - ] -} diff --git a/engine.code-workspace b/engine.code-workspace new file mode 100644 index 0000000000000..026fde0433c74 --- /dev/null +++ b/engine.code-workspace @@ -0,0 +1,197 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "files.associations": { + "optional": "cpp", + "__bit_reference": "cpp", + "__bits": "cpp", + "__config": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__nullptr": "cpp", + "__split_buffer": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__tuple": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "exception": "cpp", + "forward_list": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "numeric": "cpp", + "ostream": "cpp", + "queue": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "set": "cpp", + "span": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "strstream": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "valarray": "cpp", + "variant": "cpp", + "vector": "cpp", + "algorithm": "cpp", + "filesystem": "cpp", + "memory_resource": "cpp", + "bit": "cpp", + "charconv": "cpp", + "format": "cpp", + "functional": "cpp", + "iterator": "cpp", + "utility": "cpp", + "__assert": "cpp", + "*.inc": "cpp", + "__verbose_abort": "cpp", + "*.def": "cpp", + "*.hpp11": "cpp", + "__functional_base": "cpp", + "shared_mutex": "cpp", + "coroutine": "cpp", + "hash_map": "cpp", + "hash_set": "cpp", + "thread": "cpp", + "propagate_const": "cpp", + "*.gen": "cpp", + "simd": "cpp", + "barrier": "cpp", + "cuchar": "cpp", + "latch": "cpp", + "numbers": "cpp", + "scoped_allocator": "cpp", + "semaphore": "cpp", + "typeindex": "cpp", + "__std_stream": "cpp", + "*.ipp": "cpp", + "csetjmp": "cpp", + "cfenv": "cpp" + }, + "C_Cpp.default.includePath": [ + "${default}", + "${workspaceFolder}/..", + "${workspaceFolder}", + ], + "dotnet.defaultSolution": "disable", + "dart.showTodos": false, + "testMate.cpp.test.advancedExecutables": [ + { + "pattern": "../out/host_debug_unopt_arm64/impeller_unittests", + "runTask": { + "before": [ + "impeller_unittests_arm64" + ] + }, + "gtest": { + "prependTestRunningArgs": [ + "--enable_playground" + ] + } + } + ], + }, + "tasks": { + "version": "2.0.0", + "tasks": [ + { + "label": "impeller_unittests_arm64", + "type": "shell", + "command": "./flutter/bin/et", + "args": [ + "build", + "-c", + "host_debug_unopt_arm64", + "//flutter/impeller:impeller_unittests" + ], + "options": { + "cwd": "${workspaceFolder}/.." + }, + "problemMatcher": [ + "$gcc" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "clear": true + }, + "group": { + "kind": "build", + } + } + ] + }, + "extensions": { + "recommendations": [ + // C++ TestMate + "matepek.vscode-catch2-test-adapter", + // Uses github-styled markdown preview, which supports more features than the default markdown preview. + "bierner.github-markdown-preview", + // Flutter and Dart extensions. + "Dart-Code.dart-code", + // Supports C/C++ in the engine. + // See https://github.com/flutter/engine/blob/main/docs/contributing/Setting-up-the-Engine-development-environment.md#vscode-with-cc-intellisense-cc + "llvm-vs-code-extensions.vscode-clangd", + // Auto-formats C/C++ code. + // https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#cc + "xaver.clang-format", + ] + } +} From a1ec843cccb8854318b54e859753bfe0da9aa224 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 18 Sep 2024 16:09:22 -0700 Subject: [PATCH 02/22] not sure why, but these have to be named like this which will interfere with linux --- engine.code-workspace | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine.code-workspace b/engine.code-workspace index 026fde0433c74..9298159472958 100644 --- a/engine.code-workspace +++ b/engine.code-workspace @@ -135,7 +135,7 @@ "pattern": "../out/host_debug_unopt_arm64/impeller_unittests", "runTask": { "before": [ - "impeller_unittests_arm64" + "impeller_unittests" ] }, "gtest": { @@ -150,7 +150,7 @@ "version": "2.0.0", "tasks": [ { - "label": "impeller_unittests_arm64", + "label": "impeller_unittests", "type": "shell", "command": "./flutter/bin/et", "args": [ @@ -194,4 +194,4 @@ "xaver.clang-format", ] } -} +} \ No newline at end of file From 86c084d4b9aac2a81bda2de9e01bcd49c1da5156 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 18 Sep 2024 16:16:16 -0700 Subject: [PATCH 03/22] added my launch entry too for debugging --- engine.code-workspace | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/engine.code-workspace b/engine.code-workspace index 9298159472958..6c92d331fa88b 100644 --- a/engine.code-workspace +++ b/engine.code-workspace @@ -135,7 +135,7 @@ "pattern": "../out/host_debug_unopt_arm64/impeller_unittests", "runTask": { "before": [ - "impeller_unittests" + "impeller_unittests_arm64" ] }, "gtest": { @@ -150,7 +150,7 @@ "version": "2.0.0", "tasks": [ { - "label": "impeller_unittests", + "label": "impeller_unittests_arm64", "type": "shell", "command": "./flutter/bin/et", "args": [ @@ -193,5 +193,33 @@ // https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#cc "xaver.clang-format", ] + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "impeller_unittests_arm64", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/../out/host_debug_unopt_arm64/impeller_unittests", + "args": [ + "--enable_playground", + ], + "stopAtEntry": false, + "cwd": "${workspaceFolder}/../out/host_debug_unopt_arm64", + "environment": [], + "externalConsole": false, + "MIMode": "lldb", + "setupCommands": [ + { + "description": "Enable pretty-printing for lldb", + "text": "settings set target.pretty-printing true", + "ignoreFailures": true + } + ], + "preLaunchTask": "impeller_unittests_arm64", + } + ], + "compounds": [] } } \ No newline at end of file From 1148586cb181338c9c7d368632780f4ddcae9d7e Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 18 Sep 2024 16:19:06 -0700 Subject: [PATCH 04/22] added test adapter --- engine.code-workspace | 1 + 1 file changed, 1 insertion(+) diff --git a/engine.code-workspace b/engine.code-workspace index 6c92d331fa88b..e7963affe7519 100644 --- a/engine.code-workspace +++ b/engine.code-workspace @@ -132,6 +132,7 @@ "dart.showTodos": false, "testMate.cpp.test.advancedExecutables": [ { + "name": "impeller_unittests_arm64", "pattern": "../out/host_debug_unopt_arm64/impeller_unittests", "runTask": { "before": [ From 7f07717aa44c781b975b3b8af80804acd76250af Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 18 Sep 2024 16:30:02 -0700 Subject: [PATCH 05/22] added source map for the debugger - works from launch ui, not from debug test ui =( --- engine.code-workspace | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engine.code-workspace b/engine.code-workspace index e7963affe7519..8946ff3a11d08 100644 --- a/engine.code-workspace +++ b/engine.code-workspace @@ -216,6 +216,11 @@ "description": "Enable pretty-printing for lldb", "text": "settings set target.pretty-printing true", "ignoreFailures": true + }, + { + "description": "Source map", + "text": "settings set target.source-map \"flutter/\" \"${workspaceFolder}\"", + "ignoreFailures": false } ], "preLaunchTask": "impeller_unittests_arm64", From 1a4a2a1d51cc503fff5d1b61fa8edab94b77d32c Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 18 Sep 2024 16:51:16 -0700 Subject: [PATCH 06/22] got source map working for the test menu --- engine.code-workspace | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/engine.code-workspace b/engine.code-workspace index 8946ff3a11d08..ae76943d85172 100644 --- a/engine.code-workspace +++ b/engine.code-workspace @@ -146,6 +146,33 @@ } } ], + "testMate.cpp.debug.configTemplate": { + "type": "cppvsdbg", + "linux": { + "type": "cppdbg", + "MIMode": "gdb" + }, + "darwin": { + "type": "cppdbg", + "MIMode": "lldb", + "setupCommands": [ + { + "description": "Source map", + "text": "settings set target.source-map \"flutter/\" \"${workspaceFolder}\"", + "ignoreFailures": false + } + ], + }, + "win32": { + "type": "cppvsdbg" + }, + "program": "${exec}", + "args": "${argsArray}", + "cwd": "${cwd}", + "env": "${envObj}", + "environment": "${envObjArray}", + "sourceFileMap": "${sourceFileMapObj}", + } }, "tasks": { "version": "2.0.0", From 8f0f017706c98bb1dcd4e09ce9c12d546a744712 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 09:44:56 -0700 Subject: [PATCH 07/22] license update --- ci/licenses_golden/excluded_files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index 549608f4d5a5e..56b935eea2ae8 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -18,7 +18,6 @@ ../../../flutter/.github ../../../flutter/.gitignore ../../../flutter/.style.yapf -../../../flutter/.vscode ../../../flutter/AUTHORS ../../../flutter/CODEOWNERS ../../../flutter/CONTRIBUTING.md @@ -50,6 +49,7 @@ ../../../flutter/display_list/utils/dl_accumulation_rect_unittests.cc ../../../flutter/display_list/utils/dl_matrix_clip_tracker_unittests.cc ../../../flutter/docs +../../../flutter/engine.code-workspace ../../../flutter/examples ../../../flutter/flow/README.md ../../../flutter/flow/diff_context_unittests.cc From aa24e2fd9df5b62575c971fcca72737109a5947b Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 20 Sep 2024 09:06:05 -0700 Subject: [PATCH 08/22] license exception --- tools/licenses/lib/paths.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/licenses/lib/paths.dart b/tools/licenses/lib/paths.dart index d2f2b93306c4f..35d17f3c676fd 100644 --- a/tools/licenses/lib/paths.dart +++ b/tools/licenses/lib/paths.dart @@ -25,6 +25,7 @@ final Set skippedPaths = { r'flutter/buildtools', // only used by build r'flutter/ci', r'flutter/docs', + r'flutter/engine.code-workspace', r'flutter/flutter_frontend_server', r'flutter/impeller/docs', r'flutter/lib/web_ui/build', // this is compiler-generated output From d4fcdeb90d6c05bcb1818db420b608692d116cf4 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 20 Sep 2024 09:30:16 -0700 Subject: [PATCH 09/22] tool signature --- ci/licenses_golden/tool_signature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/licenses_golden/tool_signature b/ci/licenses_golden/tool_signature index 22136f5b4a8a1..4cc7ffd679d25 100644 --- a/ci/licenses_golden/tool_signature +++ b/ci/licenses_golden/tool_signature @@ -1,2 +1,2 @@ -Signature: 53025d1261891c38c7bccb158862e09f +Signature: 8859e172e060ecb45aa665c3119d5d25 From 3c37b7c0a518c5ad1899da1b63d5bb5f824085fc Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 10:58:29 -0700 Subject: [PATCH 10/22] Added tool for updating the workspace --- tools/json_injector/README.md | 0 tools/json_injector/bin/main.dart | 5 ++ tools/json_injector/lib/json_injector.dart | 22 ++++++ tools/json_injector/pubspec.yaml | 5 ++ .../test/json_injector_test.dart | 79 +++++++++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 tools/json_injector/README.md create mode 100644 tools/json_injector/bin/main.dart create mode 100644 tools/json_injector/lib/json_injector.dart create mode 100644 tools/json_injector/pubspec.yaml create mode 100644 tools/json_injector/test/json_injector_test.dart diff --git a/tools/json_injector/README.md b/tools/json_injector/README.md new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tools/json_injector/bin/main.dart b/tools/json_injector/bin/main.dart new file mode 100644 index 0000000000000..93a23ee210a86 --- /dev/null +++ b/tools/json_injector/bin/main.dart @@ -0,0 +1,5 @@ +import 'package:json_injector/json_injector.dart'; + +void main() { + +} \ No newline at end of file diff --git a/tools/json_injector/lib/json_injector.dart b/tools/json_injector/lib/json_injector.dart new file mode 100644 index 0000000000000..60f9b351d411c --- /dev/null +++ b/tools/json_injector/lib/json_injector.dart @@ -0,0 +1,22 @@ +import 'dart:convert' show jsonDecode; + +Object? inject(Object? json, Object? injector) { + if (json is Map && injector is Map) { + final result = {}; + for (final key in json.keys) { + if (!injector.containsKey(key)) { + result[key] = json[key]; + } + } + for (final key in injector.keys) { + if (json.containsKey(key)) { + result[key] = inject(json[key], injector[key]); + } else { + result[key] = injector[key]; + } + } + return result; + } + + return json; +} diff --git a/tools/json_injector/pubspec.yaml b/tools/json_injector/pubspec.yaml new file mode 100644 index 0000000000000..b5c270ad23936 --- /dev/null +++ b/tools/json_injector/pubspec.yaml @@ -0,0 +1,5 @@ +name: json_injector +environment: + sdk: '^3.6.0-255.0.dev' +dependencies: + test: any diff --git a/tools/json_injector/test/json_injector_test.dart b/tools/json_injector/test/json_injector_test.dart new file mode 100644 index 0000000000000..f5d8e16d3ef19 --- /dev/null +++ b/tools/json_injector/test/json_injector_test.dart @@ -0,0 +1,79 @@ +import 'package:json_injector/json_injector.dart'; +import 'package:test/test.dart'; + +bool _deepEquals(Object? x, Object? y) { + if (x is Map && y is Map) { + if (x.length != y.length) { + return false; + } + + for (final key in x.keys) { + if (!_deepEquals(x[key], y[key])) { + return false; + } + } + return true; + } else if (x is List && y is List) { + if (x.length != y.length) { + return false; + } + + for (int i = 0; i < x.length; i++) { + if (_deepEquals(x[i], y[i])) { + return false; + } + } + return true; + } else { + return x == y; + } +} + +void main() { + test('noop', () { + const json = { + 'configurations': [], + }; + final result = inject(json, {}); + + expect(_deepEquals(json, result), isTrue); + }); + + test('simple inject', () { + const json = { + 'configurations': [], + }; + const injector = { + 'bar': [], + }; + + expect( + _deepEquals(inject(json, injector), { + 'configurations': [], + 'bar': [], + }), + isTrue); + }); + + test('simple recurse', () { + const json = { + 'configurations': { + 'foo': 1, + }, + }; + const injector = { + 'configurations': { + 'bar': 2, + }, + }; + + expect( + _deepEquals(inject(json, injector), { + 'configurations': { + 'foo': 1, + 'bar': 2, + }, + }), + isTrue); + }); +} From 0d5ae0b5218fc8a281d049c1c82aa673a5903e39 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 11:05:51 -0700 Subject: [PATCH 11/22] added matcher --- .../test/json_injector_test.dart | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tools/json_injector/test/json_injector_test.dart b/tools/json_injector/test/json_injector_test.dart index f5d8e16d3ef19..44919c2eb2534 100644 --- a/tools/json_injector/test/json_injector_test.dart +++ b/tools/json_injector/test/json_injector_test.dart @@ -1,7 +1,7 @@ import 'package:json_injector/json_injector.dart'; import 'package:test/test.dart'; -bool _deepEquals(Object? x, Object? y) { +bool _deepEquals(dynamic x, dynamic y) { if (x is Map && y is Map) { if (x.length != y.length) { return false; @@ -29,6 +29,24 @@ bool _deepEquals(Object? x, Object? y) { } } +class _DeepMatcher extends Matcher { + _DeepMatcher(this._target); + + final dynamic _target; + + @override + Description describe(Description description) { + description.add('equals $_target'); + return description; + } + + @override + bool matches(dynamic item, Map matchState) => + _deepEquals(item, _target); +} + +Matcher _isDeepEquals(dynamic x) => _DeepMatcher(x); + void main() { test('noop', () { const json = { @@ -36,7 +54,7 @@ void main() { }; final result = inject(json, {}); - expect(_deepEquals(json, result), isTrue); + expect(result, _isDeepEquals(json)); }); test('simple inject', () { @@ -48,11 +66,11 @@ void main() { }; expect( - _deepEquals(inject(json, injector), { + inject(json, injector), + _isDeepEquals({ 'configurations': [], 'bar': [], - }), - isTrue); + })); }); test('simple recurse', () { @@ -68,12 +86,12 @@ void main() { }; expect( - _deepEquals(inject(json, injector), { + inject(json, injector), + _isDeepEquals({ 'configurations': { 'foo': 1, 'bar': 2, }, - }), - isTrue); + })); }); } From 1eafab42fa5e5c99d219dbf813dd8cae8fa0ea03 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 11:32:09 -0700 Subject: [PATCH 12/22] added list --- tools/json_injector/lib/json_injector.dart | 11 +++++++++ .../test/json_injector_test.dart | 23 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/tools/json_injector/lib/json_injector.dart b/tools/json_injector/lib/json_injector.dart index 60f9b351d411c..c6e50079930f1 100644 --- a/tools/json_injector/lib/json_injector.dart +++ b/tools/json_injector/lib/json_injector.dart @@ -16,6 +16,17 @@ Object? inject(Object? json, Object? injector) { } } return result; + } if (json is List && injector is List) { + final Map jsonList = {}; + final Map injectorList = {}; + for (final item in json) { + jsonList['name'] = item; + } + for (final item in injector) { + injectorList['name'] = item; + } + final joined = inject(jsonList, injectorList) as Map?; + return joined?.values.toList(); } return json; diff --git a/tools/json_injector/test/json_injector_test.dart b/tools/json_injector/test/json_injector_test.dart index 44919c2eb2534..74e91775f0bf8 100644 --- a/tools/json_injector/test/json_injector_test.dart +++ b/tools/json_injector/test/json_injector_test.dart @@ -19,7 +19,7 @@ bool _deepEquals(dynamic x, dynamic y) { } for (int i = 0; i < x.length; i++) { - if (_deepEquals(x[i], y[i])) { + if (!_deepEquals(x[i], y[i])) { return false; } } @@ -94,4 +94,25 @@ void main() { }, })); }); + + test('simple list', () { + const json = { + 'configurations': [ + {'name': 'foo', 'x': 1}, + ], + }; + const injector = { + 'configurations': [ + {'name': 'foo', 'y': 1}, + ], + }; + + expect( + inject(json, injector), + _isDeepEquals({ + 'configurations': [ + {'name': 'foo', 'x': 1, 'y': 1}, + ], + })); + }); } From dc74f17df6243497bf531c678e5af859469cb449 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 11:35:21 -0700 Subject: [PATCH 13/22] pulled out namekey --- tools/json_injector/lib/json_injector.dart | 14 ++++++-------- tools/json_injector/test/json_injector_test.dart | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/json_injector/lib/json_injector.dart b/tools/json_injector/lib/json_injector.dart index c6e50079930f1..dc7bd6c3a7fe3 100644 --- a/tools/json_injector/lib/json_injector.dart +++ b/tools/json_injector/lib/json_injector.dart @@ -1,6 +1,4 @@ -import 'dart:convert' show jsonDecode; - -Object? inject(Object? json, Object? injector) { +Object? inject(Object? json, Object? injector, {String? nameKey}) { if (json is Map && injector is Map) { final result = {}; for (final key in json.keys) { @@ -10,22 +8,22 @@ Object? inject(Object? json, Object? injector) { } for (final key in injector.keys) { if (json.containsKey(key)) { - result[key] = inject(json[key], injector[key]); + result[key] = inject(json[key], injector[key], nameKey: nameKey); } else { result[key] = injector[key]; } } return result; - } if (json is List && injector is List) { + } if (json is List && injector is List && nameKey != null) { final Map jsonList = {}; final Map injectorList = {}; for (final item in json) { - jsonList['name'] = item; + jsonList[nameKey] = item; } for (final item in injector) { - injectorList['name'] = item; + injectorList[nameKey] = item; } - final joined = inject(jsonList, injectorList) as Map?; + final joined = inject(jsonList, injectorList, nameKey: nameKey) as Map?; return joined?.values.toList(); } diff --git a/tools/json_injector/test/json_injector_test.dart b/tools/json_injector/test/json_injector_test.dart index 74e91775f0bf8..25f60bb384005 100644 --- a/tools/json_injector/test/json_injector_test.dart +++ b/tools/json_injector/test/json_injector_test.dart @@ -108,7 +108,7 @@ void main() { }; expect( - inject(json, injector), + inject(json, injector, nameKey: 'name'), _isDeepEquals({ 'configurations': [ {'name': 'foo', 'x': 1, 'y': 1}, From 1e8a0b91a74aed518763ceaf7aa9bbe05391b8d6 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 13:35:31 -0700 Subject: [PATCH 14/22] added simple template example --- tools/json_injector/bin/main.dart | 6 +++- tools/json_injector/lib/json_injector.dart | 29 +++++++++++++++---- .../test/json_injector_test.dart | 28 ++++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/tools/json_injector/bin/main.dart b/tools/json_injector/bin/main.dart index 93a23ee210a86..7699c509c3a4e 100644 --- a/tools/json_injector/bin/main.dart +++ b/tools/json_injector/bin/main.dart @@ -1,5 +1,9 @@ +// Copyright 2013 The Flutter 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:json_injector/json_injector.dart'; void main() { - + } \ No newline at end of file diff --git a/tools/json_injector/lib/json_injector.dart b/tools/json_injector/lib/json_injector.dart index dc7bd6c3a7fe3..f37d90601a2d7 100644 --- a/tools/json_injector/lib/json_injector.dart +++ b/tools/json_injector/lib/json_injector.dart @@ -1,4 +1,13 @@ -Object? inject(Object? json, Object? injector, {String? nameKey}) { +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String _templateKey = 'json_injector:template'; + +Object? inject(Object? json, Object? injector, + {String? nameKey, Map>? templates}) { + Object? recurse(Object? x, Object? y) => + inject(x, y, nameKey: nameKey, templates: templates); if (json is Map && injector is Map) { final result = {}; for (final key in json.keys) { @@ -7,14 +16,24 @@ Object? inject(Object? json, Object? injector, {String? nameKey}) { } } for (final key in injector.keys) { - if (json.containsKey(key)) { - result[key] = inject(json[key], injector[key], nameKey: nameKey); + if (key == _templateKey) { + final String templateName = injector[key] as String; + final Map? template = templates?[templateName]; + if (template == null) { + throw StateError('unknown template: $templateName'); + } + for (final templateKey in template.keys) { + result[templateKey] = template[templateKey]; + } + } else if (json.containsKey(key)) { + result[key] = recurse(json[key], injector[key]); } else { result[key] = injector[key]; } } return result; - } if (json is List && injector is List && nameKey != null) { + } + if (json is List && injector is List && nameKey != null) { final Map jsonList = {}; final Map injectorList = {}; for (final item in json) { @@ -23,7 +42,7 @@ Object? inject(Object? json, Object? injector, {String? nameKey}) { for (final item in injector) { injectorList[nameKey] = item; } - final joined = inject(jsonList, injectorList, nameKey: nameKey) as Map?; + final joined = recurse(jsonList, injectorList) as Map?; return joined?.values.toList(); } diff --git a/tools/json_injector/test/json_injector_test.dart b/tools/json_injector/test/json_injector_test.dart index 25f60bb384005..e260d15dcb596 100644 --- a/tools/json_injector/test/json_injector_test.dart +++ b/tools/json_injector/test/json_injector_test.dart @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter 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:json_injector/json_injector.dart'; import 'package:test/test.dart'; @@ -115,4 +119,28 @@ void main() { ], })); }); + + test('simple template', () { + const json = { + 'configurations': [ + {'name': 'foo', 'x': 1}, + ], + }; + const injector = { + 'configurations': [ + {'name': 'foo', 'json_injector:template': 'super'}, + ], + }; + const templates = { + 'super': {'y': 2, 'z': 3} + }; + + expect( + inject(json, injector, nameKey: 'name', templates: templates), + _isDeepEquals({ + 'configurations': [ + {'name': 'foo', 'x': 1, 'y': 2, 'z': 3}, + ], + })); + }); } From c37888cdb805308a887654f195248cad2624d25c Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 13:53:25 -0700 Subject: [PATCH 15/22] implemented main --- tools/json_injector/bin/main.dart | 45 +++++++++++++++++++++++++++++-- tools/json_injector/pubspec.yaml | 1 + 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/tools/json_injector/bin/main.dart b/tools/json_injector/bin/main.dart index 7699c509c3a4e..33954c38b49b8 100644 --- a/tools/json_injector/bin/main.dart +++ b/tools/json_injector/bin/main.dart @@ -2,8 +2,49 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:convert' show jsonDecode, jsonEncode; +import 'dart:io'; + +import 'package:args/args.dart'; import 'package:json_injector/json_injector.dart'; -void main() { +void main(List arguments) { + final parser = ArgParser() + ..addOption('input', + abbr: 'i', help: 'Path to the input JSON file', mandatory: true) + ..addOption('injector', + abbr: 'j', help: 'Path to the injector JSON file', mandatory: true) + ..addOption('output', + abbr: 'o', help: 'Path to the output JSON file', mandatory: true) + ..addOption('templates', + abbr: 't', help: 'Path to the templates JSON file', mandatory: false) + ..addOption('name-key', + abbr: 'n', help: 'Name key for processing', mandatory: false); + + ArgResults argResults; + try { + argResults = parser.parse(arguments); + } catch (e) { + print('Error: $e\n'); + print('Usage:\n${parser.usage}'); + return; + } + + final String inputJson = File(argResults['input'] as String).readAsStringSync(); + final String injectorJson = File(argResults['injector'] as String).readAsStringSync(); + final String? nameKey = argResults['name-key'] as String?; + final String outputPath = argResults['output'] as String; + + Map>? templates; + final String? templatesPath = argResults['templates'] as String?; + if (templatesPath != null) { + final templateJson = File(templatesPath).readAsStringSync(); + templates = jsonDecode(templateJson) as Map>?; + } + + final dynamic input = jsonDecode(inputJson); + final dynamic injector = jsonDecode(injectorJson); -} \ No newline at end of file + final dynamic result = inject(input, injector, nameKey: nameKey, templates: templates); + File(outputPath).writeAsStringSync(jsonEncode(result)); +} diff --git a/tools/json_injector/pubspec.yaml b/tools/json_injector/pubspec.yaml index b5c270ad23936..1d8ccbebc32ab 100644 --- a/tools/json_injector/pubspec.yaml +++ b/tools/json_injector/pubspec.yaml @@ -3,3 +3,4 @@ environment: sdk: '^3.6.0-255.0.dev' dependencies: test: any + args: any From 68cc6ffb6b7ac8f97eb407b504dfe4779a8e7396 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 13:57:26 -0700 Subject: [PATCH 16/22] made error for missing mandatory options better --- tools/json_injector/bin/main.dart | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/json_injector/bin/main.dart b/tools/json_injector/bin/main.dart index 33954c38b49b8..524be77cdc753 100644 --- a/tools/json_injector/bin/main.dart +++ b/tools/json_injector/bin/main.dart @@ -21,20 +21,23 @@ void main(List arguments) { ..addOption('name-key', abbr: 'n', help: 'Name key for processing', mandatory: false); + late final String inputJson; + late final String injectorJson; + late final String outputPath; + ArgResults argResults; try { argResults = parser.parse(arguments); + inputJson = File(argResults['input'] as String).readAsStringSync(); + injectorJson = File(argResults['injector'] as String).readAsStringSync(); + outputPath = argResults['output'] as String; } catch (e) { print('Error: $e\n'); print('Usage:\n${parser.usage}'); return; } - final String inputJson = File(argResults['input'] as String).readAsStringSync(); - final String injectorJson = File(argResults['injector'] as String).readAsStringSync(); final String? nameKey = argResults['name-key'] as String?; - final String outputPath = argResults['output'] as String; - Map>? templates; final String? templatesPath = argResults['templates'] as String?; if (templatesPath != null) { @@ -45,6 +48,7 @@ void main(List arguments) { final dynamic input = jsonDecode(inputJson); final dynamic injector = jsonDecode(injectorJson); - final dynamic result = inject(input, injector, nameKey: nameKey, templates: templates); + final dynamic result = + inject(input, injector, nameKey: nameKey, templates: templates); File(outputPath).writeAsStringSync(jsonEncode(result)); } From 9a113bafcd8a6b75cf28f1daab14138b3f55c4a4 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 14:18:19 -0700 Subject: [PATCH 17/22] added injectos and cleaned up the workspace --- tools/json_injector/bin/main.dart | 23 +++++++++--- .../injectors/engine-templates.json | 1 + .../injectors/engine.code-workspace | 35 +++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 tools/json_injector/injectors/engine-templates.json create mode 100644 tools/json_injector/injectors/engine.code-workspace diff --git a/tools/json_injector/bin/main.dart b/tools/json_injector/bin/main.dart index 524be77cdc753..fcdd5f63bb9a1 100644 --- a/tools/json_injector/bin/main.dart +++ b/tools/json_injector/bin/main.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:convert' show jsonDecode, jsonEncode; +import 'dart:convert' show JsonEncoder, jsonDecode, jsonEncode; import 'dart:io'; import 'package:args/args.dart'; @@ -45,10 +45,25 @@ void main(List arguments) { templates = jsonDecode(templateJson) as Map>?; } - final dynamic input = jsonDecode(inputJson); - final dynamic injector = jsonDecode(injectorJson); + late final dynamic input; + try { + input = jsonDecode(inputJson); + } catch (ex) { + print('failed to parse: ${argResults['input']}'); + print('Error: $ex'); + return; + } + late final dynamic injector; + try { + injector = jsonDecode(injectorJson); + } catch (ex) { + print('failed to parse: ${argResults['injector']}'); + print('Error: $ex'); + return; + } final dynamic result = inject(input, injector, nameKey: nameKey, templates: templates); - File(outputPath).writeAsStringSync(jsonEncode(result)); + File(outputPath) + .writeAsStringSync(const JsonEncoder.withIndent(' ').convert(result)); } diff --git a/tools/json_injector/injectors/engine-templates.json b/tools/json_injector/injectors/engine-templates.json new file mode 100644 index 0000000000000..9e26dfeeb6e64 --- /dev/null +++ b/tools/json_injector/injectors/engine-templates.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tools/json_injector/injectors/engine.code-workspace b/tools/json_injector/injectors/engine.code-workspace new file mode 100644 index 0000000000000..d29525fac3080 --- /dev/null +++ b/tools/json_injector/injectors/engine.code-workspace @@ -0,0 +1,35 @@ +{ + "tasks": { + "version": "2.0.0", + "tasks": [ + { + "label": "display_list_unittests_arm64", + "type": "shell", + "command": "./flutter/bin/et", + "args": [ + "build", + "-c", + "host_debug_unopt_arm64", + "//flutter/display_list:display_list_unittests" + ], + "options": { + "cwd": "${workspaceFolder}/.." + }, + "problemMatcher": [ + "$gcc" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + } + } + ] + } +} \ No newline at end of file From d77a666b1a9e1e9c36b13c5d91935b89c3733754 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 14:40:29 -0700 Subject: [PATCH 18/22] fixed lists --- tools/json_injector/lib/json_injector.dart | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tools/json_injector/lib/json_injector.dart b/tools/json_injector/lib/json_injector.dart index f37d90601a2d7..c7eec321f6938 100644 --- a/tools/json_injector/lib/json_injector.dart +++ b/tools/json_injector/lib/json_injector.dart @@ -4,6 +4,15 @@ const String _templateKey = 'json_injector:template'; +bool _isListOf(List list) { + for (final item in list) { + if (item is! T) { + return false; + } + } + return list.isNotEmpty; +} + Object? inject(Object? json, Object? injector, {String? nameKey, Map>? templates}) { Object? recurse(Object? x, Object? y) => @@ -33,14 +42,21 @@ Object? inject(Object? json, Object? injector, } return result; } - if (json is List && injector is List && nameKey != null) { + if (json is List && + injector is List && + nameKey != null && + _isListOf>(json) && + _isListOf>(injector)) { final Map jsonList = {}; final Map injectorList = {}; + for (final item in json) { - jsonList[nameKey] = item; + final Map map = item as Map; + jsonList[map[nameKey] as String] = item; } for (final item in injector) { - injectorList[nameKey] = item; + final Map map = item as Map; + injectorList[map[nameKey] as String] = item; } final joined = recurse(jsonList, injectorList) as Map?; return joined?.values.toList(); From 6572c74fc6f2e09973452f50543ad412b32e75ab Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 15:02:54 -0700 Subject: [PATCH 19/22] got templates working correctly --- tools/json_injector/bin/main.dart | 4 +- .../injectors/engine-templates.json | 24 +++++++++++- .../injectors/engine.code-workspace | 25 ++----------- tools/json_injector/lib/json_injector.dart | 37 +++++++++++++++++-- .../test/json_injector_test.dart | 25 +++++++++++++ 5 files changed, 87 insertions(+), 28 deletions(-) diff --git a/tools/json_injector/bin/main.dart b/tools/json_injector/bin/main.dart index fcdd5f63bb9a1..8e151a55c1ce2 100644 --- a/tools/json_injector/bin/main.dart +++ b/tools/json_injector/bin/main.dart @@ -38,11 +38,11 @@ void main(List arguments) { } final String? nameKey = argResults['name-key'] as String?; - Map>? templates; + Map? templates; final String? templatesPath = argResults['templates'] as String?; if (templatesPath != null) { final templateJson = File(templatesPath).readAsStringSync(); - templates = jsonDecode(templateJson) as Map>?; + templates = jsonDecode(templateJson) as Map?; } late final dynamic input; diff --git a/tools/json_injector/injectors/engine-templates.json b/tools/json_injector/injectors/engine-templates.json index 9e26dfeeb6e64..581d3b1fed754 100644 --- a/tools/json_injector/injectors/engine-templates.json +++ b/tools/json_injector/injectors/engine-templates.json @@ -1 +1,23 @@ -{} \ No newline at end of file +{ + "et-task": { + "type": "shell", + "command": "./flutter/bin/et", + "options": { + "cwd": "${workspaceFolder}/.." + }, + "problemMatcher": [ + "$gcc" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + } + } +} \ No newline at end of file diff --git a/tools/json_injector/injectors/engine.code-workspace b/tools/json_injector/injectors/engine.code-workspace index d29525fac3080..e900e54eba868 100644 --- a/tools/json_injector/injectors/engine.code-workspace +++ b/tools/json_injector/injectors/engine.code-workspace @@ -1,35 +1,16 @@ { "tasks": { - "version": "2.0.0", "tasks": [ { "label": "display_list_unittests_arm64", - "type": "shell", - "command": "./flutter/bin/et", + "json_injector:template": "et-task", "args": [ "build", "-c", "host_debug_unopt_arm64", "//flutter/display_list:display_list_unittests" - ], - "options": { - "cwd": "${workspaceFolder}/.." - }, - "problemMatcher": [ - "$gcc" - ], - "presentation": { - "echo": true, - "reveal": "always", - "focus": false, - "panel": "shared", - "clear": true - }, - "group": { - "kind": "build", - "isDefault": true - } + ] } ] } -} \ No newline at end of file +} diff --git a/tools/json_injector/lib/json_injector.dart b/tools/json_injector/lib/json_injector.dart index c7eec321f6938..842a57a1e9623 100644 --- a/tools/json_injector/lib/json_injector.dart +++ b/tools/json_injector/lib/json_injector.dart @@ -13,8 +13,38 @@ bool _isListOf(List list) { return list.isNotEmpty; } +dynamic _applyTemplate(dynamic item, Map? templates) { + if (item is Map) { + if (item.containsKey(_templateKey)) { + final String templateName = item[_templateKey] as String; + final Map? template = + templates?[templateName] as Map?; + + if (template == null) { + throw StateError('unknown template: $templateName'); + } + + final Map result = {}; + for (final x in item.keys) { + if (x != _templateKey) { + result[x] = item[x]; + } + } + for (final x in template.keys) { + result[x] = template[x]; + } + return result; + } else { + return item; + } + } else if (item is List) { + } else { + return item; + } +} + Object? inject(Object? json, Object? injector, - {String? nameKey, Map>? templates}) { + {String? nameKey, Map? templates}) { Object? recurse(Object? x, Object? y) => inject(x, y, nameKey: nameKey, templates: templates); if (json is Map && injector is Map) { @@ -27,7 +57,8 @@ Object? inject(Object? json, Object? injector, for (final key in injector.keys) { if (key == _templateKey) { final String templateName = injector[key] as String; - final Map? template = templates?[templateName]; + final Map? template = + templates?[templateName] as Map?; if (template == null) { throw StateError('unknown template: $templateName'); } @@ -37,7 +68,7 @@ Object? inject(Object? json, Object? injector, } else if (json.containsKey(key)) { result[key] = recurse(json[key], injector[key]); } else { - result[key] = injector[key]; + result[key] = _applyTemplate(injector[key], templates); } } return result; diff --git a/tools/json_injector/test/json_injector_test.dart b/tools/json_injector/test/json_injector_test.dart index e260d15dcb596..2cc665ca7687c 100644 --- a/tools/json_injector/test/json_injector_test.dart +++ b/tools/json_injector/test/json_injector_test.dart @@ -143,4 +143,29 @@ void main() { ], })); }); + + test('new list item template', () { + const json = { + 'configurations': [ + {'name': 'foo', 'x': 1}, + ], + }; + const injector = { + 'configurations': [ + {'name': 'bar', 'json_injector:template': 'super'}, + ], + }; + const templates = { + 'super': {'y': 2, 'z': 3} + }; + + expect( + inject(json, injector, nameKey: 'name', templates: templates), + _isDeepEquals({ + 'configurations': [ + {'name': 'foo', 'x': 1}, + {'name': 'bar', 'y': 2, 'z': 3}, + ], + })); + }); } From fd26d14d6c93461affb05a4255c1c9cc2fcdec14 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 15:13:38 -0700 Subject: [PATCH 20/22] updated readme --- tools/json_injector/README.md | 25 +++++++++++++++++++ .../injectors/engine.code-workspace | 10 ++++++++ 2 files changed, 35 insertions(+) diff --git a/tools/json_injector/README.md b/tools/json_injector/README.md index e69de29bb2d1d..fe1391e3fbe45 100644 --- a/tools/json_injector/README.md +++ b/tools/json_injector/README.md @@ -0,0 +1,25 @@ +# json_injector + +## Description + +This is a tool to manipulate json files. It's main purpose is to reduce +redundancy in VSCode workspaces. + +It can inject missing keys from one json file into another, treat List\s as +Maps for the purpose of merging and apply templates. + +## Usage + +The following invocation will update //engine.code-workspace, injecting the json +data from `injectors/engine.code-workspace` and also applying the templates at +`./injectors/engine-templates.json`. List\s who have the key named +'label' will be treated as Maps whose key is "label". + +```shell +dart run bin/main.dart \ + --input ~/dev/engine/src/flutter/engine.code-workspace \ + --injector injectors/engine.code-workspace \ + --output ~/dev/engine/src/flutter/engine.code-workspace \ + --name-key label \ + --templates injectors/engine-templates.json +``` \ No newline at end of file diff --git a/tools/json_injector/injectors/engine.code-workspace b/tools/json_injector/injectors/engine.code-workspace index e900e54eba868..773071d924915 100644 --- a/tools/json_injector/injectors/engine.code-workspace +++ b/tools/json_injector/injectors/engine.code-workspace @@ -10,6 +10,16 @@ "host_debug_unopt_arm64", "//flutter/display_list:display_list_unittests" ] + }, + { + "label": "impeller_unittests_arm64", + "json_injector:template": "et-task", + "args": [ + "build", + "-c", + "host_debug_unopt_arm64", + "//flutter/impeller:impeller_unittests" + ] } ] } From 40e0f7f80d1e00677fe6ab734a295124824315f2 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 15:26:56 -0700 Subject: [PATCH 21/22] adds test that uses actual output from jsonDecode --- tools/json_injector/lib/json_injector.dart | 1 + .../test/json_injector_test.dart | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/json_injector/lib/json_injector.dart b/tools/json_injector/lib/json_injector.dart index 842a57a1e9623..cc8a6bf023fc2 100644 --- a/tools/json_injector/lib/json_injector.dart +++ b/tools/json_injector/lib/json_injector.dart @@ -38,6 +38,7 @@ dynamic _applyTemplate(dynamic item, Map? templates) { return item; } } else if (item is List) { + return item; } else { return item; } diff --git a/tools/json_injector/test/json_injector_test.dart b/tools/json_injector/test/json_injector_test.dart index 2cc665ca7687c..7846c4bb2988b 100644 --- a/tools/json_injector/test/json_injector_test.dart +++ b/tools/json_injector/test/json_injector_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:convert' show jsonDecode, jsonEncode; + import 'package:json_injector/json_injector.dart'; import 'package:test/test.dart'; @@ -144,6 +146,34 @@ void main() { })); }); + test('simple template - json', () { + dynamic json = { + 'configurations': [ + {'name': 'foo', 'x': 1}, + ], + }; + dynamic injector = { + 'configurations': [ + {'name': 'foo', 'json_injector:template': 'super'}, + ], + }; + Map templates = { + 'super': {'y': 2, 'z': 3} + }; + + json = jsonDecode(jsonEncode(json)); + injector = jsonDecode(jsonEncode(injector)); + templates = jsonDecode(jsonEncode(templates)) as Map; + + expect( + inject(json, injector, nameKey: 'name', templates: templates), + _isDeepEquals({ + 'configurations': [ + {'name': 'foo', 'x': 1, 'y': 2, 'z': 3}, + ], + })); + }); + test('new list item template', () { const json = { 'configurations': [ From 3a6109acbc38308dbab033f4f10fb139c89f5588 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 19 Sep 2024 16:11:39 -0700 Subject: [PATCH 22/22] pub_get_offline --- tools/pub_get_offline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pub_get_offline.py b/tools/pub_get_offline.py index 2bf6b8ace54a0..bc43990eeb5c8 100644 --- a/tools/pub_get_offline.py +++ b/tools/pub_get_offline.py @@ -46,7 +46,7 @@ os.path.join(ENGINE_DIR, 'tools', 'githooks'), os.path.join(ENGINE_DIR, 'tools', 'golden_tests_harvester'), os.path.join(ENGINE_DIR, 'tools', 'header_guard_check'), - os.path.join(ENGINE_DIR, 'tools', 'licenses'), + os.path.join(ENGINE_DIR, 'tools', 'json_injector'), os.path.join(ENGINE_DIR, 'tools', 'path_ops', 'dart'), os.path.join(ENGINE_DIR, 'tools', 'pkg', 'engine_build_configs'), os.path.join(ENGINE_DIR, 'tools', 'pkg', 'engine_repo_tools'),