[test][discovery] Speed up testcase discovery.

This change refactors testcase discovery for faster multi-stage loading.

The previous testcase discovery process would block on a full
`fx test --list <test>` command. This is a pretty heavyweight command,
leading to a sluggish experience when expanding test items in the UI.

This change refactors the discovery logic to be asynchronous and
multi-staged, providing results significantly quicker to the user.

The new discovery process now populates testcases in three tiers:
1.  **Cache:** Instantly loads testcases from the workspace state cached
    during the previous successful discovery.
2.  **No-Build:** Runs `fx test --list --no-build` to quickly enumerate
    across tests that are already built.
3.  **With-Build:** Runs the full `fx test --list` to retrieve the most
    accurate and updated list of test cases.

The UI is updated as each stage completes, starting with the
fastest (cache) and ending with the most accurate (with-build).
The results from the final stage are cached for the next session.

This implementation also refactors the `TestcaseDiscoveryQueue` to
handle concurrent discovery requests concurrently instead of processing
them serially, and adds additional functionality to DataStreamProcess +
JsonStreamProcess for improved debugging.

Fixed: 447204022
Change-Id: Ibeab4fbfe0ea9e028c286688b6bb005c46643307
Reviewed-on: https://fuchsia-review.googlesource.com/c/vscode-plugins/+/1409174
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Amy Hu <amyhu@google.com>
4 files changed
tree: 62c29cfa61d1e204246953e142c3da85b8d17a47
  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.