Fix integration tests for asdf-managed yarn#549
Merged
sorenlouv merged 2 commits intosorenlouv:mainfrom Nov 7, 2025
Merged
Conversation
ebf983c to
02fa2d0
Compare
Owner
|
When running the test yarn run v1.22.22
$ jest postinstall.integration.test
/bin/sh: asdf: command not found
/bin/sh: asdf: command not found
PASS src/scripts/postinstall.integration.test.ts (13.481 s)
postinstall (integration)
✓ creates ~/.backport/config.json (3 ms)
✓ does not overwrite existing config file (5534 ms)
✓ creates config with the expected template content (1 ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 13.829 s, estimated 24 s |
Contributor
Author
@sorenlouv Done changed the approach |
The postinstall integration test was failing with exit code 126 when yarn is managed by asdf. This occurs because the test overrides the HOME environment variable, which breaks the asdf shim's ability to locate its configuration and execute. The issue is specific to development environments using asdf to manage tool versions. In these environments, 'yarn' is typically a shell shim at ~/.asdf/shims/yarn that requires the original HOME to function. Solution: - Detect if yarn is managed by asdf using 'asdf which yarn' - Use the actual yarn binary path instead of the shim - Use 'shell: /bin/bash' to ensure proper HOME variable handling - Falls back to 'yarn' from PATH if asdf is not available This fix ensures the test works in both asdf and non-asdf environments.
Refactor yarn command resolution into shared helper that uses 'asdf which yarn' to get the actual binary path instead of the shim. This suppresses the '/bin/sh: asdf: command not found' error when HOME is overridden in tests. - Extract getYarnCommand() helper to shared integration-test-helpers.ts - Use 'which asdf' + realpath to find actual asdf binary - Use 'asdf which yarn' to resolve actual yarn binary path - Apply helper to all yarn commands in both integration test files
526e017 to
f5ef903
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes integration tests that fail when yarn is managed by asdf, suppressing "/bin/sh: asdf: command not found" errors when
HOMEis overridden.Problem
Integration tests override
HOMEto test config file creation in isolated directories. When yarn is managed by asdf, theyarncommand resolves to a shell shim at~/.asdf/shims/yarnthat executesasdf exec yarn. WhenHOMEis overridden, the shim can't findasdfin PATH and fails with "/bin/sh: asdf: command not found".Solution
Extract yarn command resolution into a shared helper that bypasses the asdf shim by:
asdfbinary usingwhich asdf+realpathasdf which yarnto get the actual yarn binary pathChanges
getYarnCommand()helper insrc/test/integration-test-helpers.tspostinstall.integration.test.tsandbinary.integration.test.tsto use helperwhich asdfdetection instead of hardcoded pathsBenefits