Skip to content

Conversation

matthewbastien
Copy link
Member

@matthewbastien matthewbastien commented Sep 22, 2025

Description

I've been super frustrated with random bugs popping up in test cases where dependencies were either not mocked or the test ended up mocking more than it should causing unexpected behavior. It's also really difficult to know exactly what you need to mock when a piece of code is using global functions from "utilities.ts", static methods from SwiftToolchain, etc.

As a first step towards removing non-essential global state, I've started creating several services that can be included as dependencies to various parts of the extension:

  • FileSystem: for anything using Node's fs module.
  • Environment: for anything related to Node process or os.
  • Shell: for anything related to Node child_process.
  • ToolchainService: methods that create or work with SwiftToolchain.
  • Swiftly: for working with Swiftly to use and install toolchains.

These changes allow us to just use mockObject() and make it obvious what dependencies something has.

Tasks

  • Required tests have been written
  • [ ] Documentation has been updated
  • [ ] Added an entry to CHANGELOG.md if applicable

@matthewbastien matthewbastien changed the title Refactoring and Swiftly fixes Refactor Swiftly into a new SwiftlyService Sep 22, 2025
@matthewbastien matthewbastien changed the title Refactor Swiftly into a new SwiftlyService Refactor global functions/state into services Sep 22, 2025
@matthewbastien matthewbastien added the full-test-run Perform a full test suite run. Apply this label before pushing up a PR or commit label Sep 22, 2025
@matthewbastien matthewbastien force-pushed the swiftly-fixes branch 2 times, most recently from d906db6 to ab1609a Compare September 23, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full-test-run Perform a full test suite run. Apply this label before pushing up a PR or commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant