Update Fuchsia recipe to use machine output of ffx product lookup

Change-Id: Ic6049cb6d5afd9327834fbf2109fb668be843c71
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/52523
Reviewed-by: Jiaming Li <lijiaming@google.com>
Reviewed-by: Godofredo Contreras <godofredoc@google.com>
Commit-Queue: Michael Brase <mbrase@google.com>
diff --git a/recipes/engine/femu_test.expected/arm64_emulator_arch.json b/recipes/engine/femu_test.expected/arm64_emulator_arch.json
index b2a9c53..52a94fb 100644
--- a/recipes/engine/femu_test.expected/arm64_emulator_arch.json
+++ b/recipes/engine/femu_test.expected/arm64_emulator_arch.json
@@ -1603,6 +1603,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.qemu-arm64",
@@ -1627,7 +1629,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.qemu-arm64 product bundle"
+    "name": "lookup terminal.qemu-arm64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.qemu-arm64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/femu_with_package_list.json b/recipes/engine/femu_test.expected/femu_with_package_list.json
index d665e2a..d501339 100644
--- a/recipes/engine/femu_test.expected/femu_with_package_list.json
+++ b/recipes/engine/femu_test.expected/femu_with_package_list.json
@@ -1616,6 +1616,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1640,7 +1642,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/invalid_emulator_arch.json b/recipes/engine/femu_test.expected/invalid_emulator_arch.json
index b334396..03c31e6 100644
--- a/recipes/engine/femu_test.expected/invalid_emulator_arch.json
+++ b/recipes/engine/femu_test.expected/invalid_emulator_arch.json
@@ -1596,6 +1596,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1620,7 +1622,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/multiple_non_root_fars.json b/recipes/engine/femu_test.expected/multiple_non_root_fars.json
index cc67475..cbe3c69 100644
--- a/recipes/engine/femu_test.expected/multiple_non_root_fars.json
+++ b/recipes/engine/femu_test.expected/multiple_non_root_fars.json
@@ -1606,6 +1606,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1630,7 +1632,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/no_zircon_file.json b/recipes/engine/femu_test.expected/no_zircon_file.json
index b334396..03c31e6 100644
--- a/recipes/engine/femu_test.expected/no_zircon_file.json
+++ b/recipes/engine/femu_test.expected/no_zircon_file.json
@@ -1596,6 +1596,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1620,7 +1622,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/run_on_test_specified_arch.json b/recipes/engine/femu_test.expected/run_on_test_specified_arch.json
index dfd55d2..df7bf51 100644
--- a/recipes/engine/femu_test.expected/run_on_test_specified_arch.json
+++ b/recipes/engine/femu_test.expected/run_on_test_specified_arch.json
@@ -1634,6 +1634,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1658,7 +1660,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/run_test_with_retry.json b/recipes/engine/femu_test.expected/run_test_with_retry.json
index 6b6080e..71a2ab5 100644
--- a/recipes/engine/femu_test.expected/run_test_with_retry.json
+++ b/recipes/engine/femu_test.expected/run_test_with_retry.json
@@ -1612,6 +1612,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1636,7 +1638,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/run_with_dart_aot_behavior.json b/recipes/engine/femu_test.expected/run_with_dart_aot_behavior.json
index 7c776bd..8275ace 100644
--- a/recipes/engine/femu_test.expected/run_with_dart_aot_behavior.json
+++ b/recipes/engine/femu_test.expected/run_with_dart_aot_behavior.json
@@ -1609,6 +1609,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1633,7 +1635,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/start_femu.json b/recipes/engine/femu_test.expected/start_femu.json
index 0eb15ea..5c8de50 100644
--- a/recipes/engine/femu_test.expected/start_femu.json
+++ b/recipes/engine/femu_test.expected/start_femu.json
@@ -1608,6 +1608,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1632,7 +1634,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/start_femu_with_cso.json b/recipes/engine/femu_test.expected/start_femu_with_cso.json
index e80aece..005aeda 100644
--- a/recipes/engine/femu_test.expected/start_femu_with_cso.json
+++ b/recipes/engine/femu_test.expected/start_femu_with_cso.json
@@ -1608,6 +1608,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1632,7 +1634,14 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
diff --git a/recipes/engine/femu_test.expected/start_femu_with_override_pbm.json b/recipes/engine/femu_test.expected/start_femu_with_override_pbm.json
index 94915b4..16aff2c 100644
--- a/recipes/engine/femu_test.expected/start_femu_with_override_pbm.json
+++ b/recipes/engine/femu_test.expected/start_femu_with_override_pbm.json
@@ -1587,6 +1587,8 @@
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
+      "--machine",
+      "json-pretty",
       "product",
       "lookup",
       "terminal.x64",
@@ -1611,14 +1613,21 @@
         "RECIPE_REPO[depot_tools]"
       ]
     },
-    "name": "lookup terminal.x64 product bundle"
+    "name": "lookup terminal.x64 product bundle",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"name\": \"terminal.x64\",@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"transfer_manifest_url\": \"gs://path/to/transfer_manifest.json\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
   },
   {
     "cmd": [
       "[CACHE]/builder/src/fuchsia/sdk/linux/tools/x64/ffx",
       "product",
       "download",
-      "",
+      "gs://path/to/transfer_manifest.json",
       "/tmp/local_pb",
       "--force"
     ],
diff --git a/recipes/engine/femu_test.py b/recipes/engine/femu_test.py
index 20e0224..68eaadb 100644
--- a/recipes/engine/femu_test.py
+++ b/recipes/engine/femu_test.py
@@ -380,11 +380,12 @@
   product_name = 'terminal.%s' % arch if arch == 'x64' else 'terminal.qemu-%s' % arch
   product_transfer_manifest = api.step(
       'lookup %s product bundle' % product_name, [
-          ffx, 'product', 'lookup', product_name, sdk_id, '--base-url',
+          ffx, '--machine', 'json-pretty', 'product', 'lookup',
+          product_name, sdk_id, '--base-url',
           'gs://%s/development/%s' % (gs_bucket, sdk_id)
       ],
-      stdout=api.raw_io.output_text()
-  ).stdout.strip()
+      stdout=api.json.output(),
+  ).stdout['transfer_manifest_url']
 
   local_pb = '/tmp/local_pb'
 
@@ -549,7 +550,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       *fail_step_with_retries(
           'run FEMU test on x64.run v2_test', 'launch x64 emulator'
@@ -607,7 +611,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       *ffx_repo_list_step_data_with_retries(
           'run FEMU test on x64.run v2_test', MAX_RETRIES
@@ -666,7 +673,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       *ffx_repo_list_step_data_with_retries(
           'run FEMU test on x64.run flutter-embedder-test', 2
@@ -723,7 +733,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       ffx_repo_list_step_data(
           'run FEMU test on x64.run v2_test.get repository information'
@@ -836,7 +849,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       ffx_repo_list_step_data(
           'run FEMU test on x64.run dart-jit-runner-integration-test.get repository information'
@@ -888,7 +904,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       ffx_repo_list_step_data(
           'run FEMU test on x64.run v2_test.get repository information'
@@ -955,7 +974,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       ffx_repo_list_step_data(
           'run FEMU test on x64.run run-on-both-arch.get repository information'
@@ -1006,7 +1028,10 @@
       ),
       api.step_data(
           'lookup terminal.qemu-arm64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.qemu-arm64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       ffx_repo_list_step_data(
           'run FEMU test on arm64.run v2_test.get repository information'
@@ -1064,7 +1089,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       *fail_step_with_retries(
           'run FEMU test on x64.run v2_test', 'launch x64 emulator'
@@ -1125,6 +1153,13 @@
           'read manifest',
           api.file.read_json({'id': '0.20200101.0.1'}),
       ),
+      api.step_data(
+          'lookup terminal.x64 product bundle',
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
+      ),
       *fail_step_with_retries(
           'run FEMU test on x64.run v2_test', 'launch x64 emulator'
       ),
@@ -1178,7 +1213,10 @@
       ),
       api.step_data(
           'lookup terminal.x64 product bundle',
-          stdout=api.raw_io.output_text('gs://path/to/transfer_manifest.json'),
+          stdout=api.json.output({
+              'name': 'terminal.x64',
+              'transfer_manifest_url': 'gs://path/to/transfer_manifest.json',
+          }),
       ),
       api.step_data(
           'run FEMU test on x64.run run-on-x64.launch x64 emulator', retcode=1