[test] Make test discovery robust with retries

Previously, if `fx test --list` failed, the test discovery user
interaction would silently fail, leaving the user with an empty list of
tests without any notification or way to recover.

This change introduces a `TestcaseDiscoveryQueue` to manage test case
discovery, bringing the following benefits:
 - Error Handling and Retries: When a test discovery fails, an error
   notification is displayed to the user with options to "Retry",
   "Show Logs", or "Dismiss".
 - JSON parsing: Errors from parsing the output of `fx test --list` are
   now explicitly surfaced to users.
 - Batching: Multiple discovery requests are batched together, limiting
   the amount of notification spam should multiple TestItem discoveries
   fail.

The following test improvements are also included:
 - Test coverage of `TestcaseDiscoveryQueue`, and implicit coverage of
   `discoverTestCases()`.
 - `setupMockFfx()` is now generalized to `setupMockedCommand()`,
   allowing `fx` to be expressively mocked in the same way.

Fixed: 436612350, 436866233
Change-Id: I8deac64788aad994ef762b7e034ce706446e80a4
Reviewed-on: https://fuchsia-review.googlesource.com/c/vscode-plugins/+/1351884
Reviewed-by: Amy Hu <amyhu@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
4 files changed
tree: 3a37d5bce5cf069f583bb44d5f7094672788833f
  1. .ci/
  2. .kokoro/
  3. .vscode/
  4. docs/
  5. resources/
  6. src/
  7. syntax/
  8. testdata/
  9. .eslintrc.json
  10. .gitignore
  11. .nvmrc
  12. .vscodeignore
  13. AUTHORS
  14. build-helpers.mjs
  15. build.mjs
  16. BUILDING.md
  17. CHANGELOG.md
  18. CONTRIBUTING.md
  19. LICENSE
  20. OWNERS
  21. package-lock.json
  22. package.json
  23. PATENTS
  24. README.md
  25. THIRD_PARTY_NOTICES.txt
  26. TROUBLESHOOTING_ZXDB.md
  27. tsconfig.json
  28. web-test-runner.config.mjs
README.md

Fuchsia VS Code Extension

The Fuchsia VS Code Extension streamlines Fuchsia development by integrating essential tools and workflows within the editor.

Visit the fuchsia.dev reference for a detailed walkthrough of this extension's features, Using the Fuchsia extension for VS Code.

Setup

Ensure you have a Fuchsia source checkout. You may need to configure the path to your ffx tool:

  1. Go to Settings > Extensions > Fuchsia
  2. Set the Fuchsia: Ffx Path to the absolute path of your ffx executable.

If not set, the extension will search for ffx in ./tools/ffx and ./.jiri_root/bin/ffx.

Features

All features are accessible via the VS Code command palette Ctrl+Shift+P or Cmd+Shift+P. Type “Fuchsia” to see a list of available commands.

Command palette

Configure and run builds

  • fx set: Interactively select product, board, compilation mode, and packages.
  • fx build: Run builds, monitor progress and output in VS Code.
  • fx serve: Start and stop the package server.
  • fx ota: Trigger an over-the-air update.

Target management

  • Target discovery: List and switch between connected Fuchsia targets.
  • Target interaction: Reboot, power off, or capture a snapshot of a connected device.
  • Emulator control: Start and stop the Fuchsia emulator (ffx emu).
  • Log viewer: Stream logs to dedicated output channel.

Debug & test

  • Test explorer: Run and debug tests within the VS Code UI.
  • Component explorer: View and manage component list.
  • ZXDB debugger: Attach the zxdb debugger to running processes or components.

Language support

  • Syntax highlighting: For FIDL and Component Manifest (CML) files.
  • Build output links: Makes file paths in build logs clickable to jump directly to the source code.
  • Problem matcher: Parses build output to show C++ and Rust errors in the “Problems” panel.

Tips

Keybinds for fx build

There are two options to set a keybinds for fx build.

Default build task

  1. Open the command palette.
  2. Select Terminal > Configure Default Build Task...
  3. Select Fuchsia Extension: fx build
  4. The command can be run with Cmd+Shift+b or Ctrl+Shift+b.

Custom key

  1. Open Preferences: Open Keyboard Shortcuts
  2. Search for Fuchsia: fx build
  3. Double click keybinding cell and set desired keybind.

Recommended extensions

Contributing

Issues/feedback

  • Please report issues/feedback here.

Legal Notice

Use of the Fuchsia core developer tools is subject to the Google Terms of Service. The Google Privacy Policy describes how data is handled in your use of this service.