Repository navigation
feat(host): capture HostEnvironment once at entry points #3763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+2,172
−854
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
77dde28
feat(host): capture HostEnvironment once at entry points
thymikee f4d4970
fix(host): resolve relative state dirs against the captured working d…
thymikee 2ebb886
fix(host): give platform code the command host instead of process reads
thymikee 5effcd7
fix(host): answer review of the host environment foundation
thymikee ae204b4
fix(host): keep the test host setup out of mutation scope and finish …
thymikee fb9e4e6
fix(host): bind the test command host per suite, not globally
thymikee 30bbef5
chore(deps): declare test-kit in the HarmonyOS and Linux platform pac…
thymikee d522d25
fix(host): bind the test command host in the stale-provider admission…
thymikee 756cf4e
fix(host): resolve every client read from the client's host
thymikee 63b984b
fix(host): resolve the daemon policy path against the host working di…
thymikee f4616b9
style: format the daemon policy reuse test
thymikee 2a6416d
Merge remote-tracking branch 'origin/main' into refactor/host-environ…
thymikee 7c68072
test: merge the duplicate test-kit import in the handler chain routin…
thymikee 3c622c3
fix(host): start a launched daemon in the launching host's working di…
thymikee ab5ee6e
test: keep the registration-owner test under its size ratchet
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import path from 'node:path'; | ||
| import { expect, test } from 'vitest'; | ||
| import { resolveDaemonPaths } from './daemon-resolution.ts'; | ||
|
|
||
| test('a relative state dir resolves against the working directory it is given', () => { | ||
| const paths = resolveDaemonPaths('state/here', { cwd: '/workspace/project' }); | ||
|
|
||
| expect(paths.baseDir).toBe(path.resolve('/workspace/project', 'state/here')); | ||
| }); | ||
|
|
||
| test('a relative state dir without a working directory is refused with a typed reason', () => { | ||
| expect(() => resolveDaemonPaths('state/here')).toThrow( | ||
| expect.objectContaining({ | ||
| code: 'INVALID_ARGS', | ||
| details: expect.objectContaining({ reason: 'relative_state_dir_without_cwd' }), | ||
| }), | ||
| ); | ||
| }); | ||
|
|
||
| test('an absolute state dir needs no working directory', () => { | ||
| expect(resolveDaemonPaths('/var/agent-device/state').baseDir).toBe('/var/agent-device/state'); | ||
| }); |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,29 @@ | ||
| import path from 'node:path'; | ||
| import { expect, test, vi } from 'vitest'; | ||
| import { deviceClaimFilePath } from '@agent-device/test-kit'; | ||
| import { resolveDeviceClaimPath } from './device-claim-paths.ts'; | ||
| import { resolveDeviceClaimPath, resolveDeviceClaimRoot } from './device-claim-paths.ts'; | ||
|
|
||
| const DEVICE_KEYS = ['local:android:none:emulator-5554', 'local:ios:ios:ABCD-1234']; | ||
|
|
||
| test('the claim file path test-kit restates matches the production resolver', () => { | ||
| vi.stubEnv('AGENT_DEVICE_CLAIMS_DIR', ''); | ||
| for (const key of DEVICE_KEYS) { | ||
| expect(deviceClaimFilePath(key)).toBe(resolveDeviceClaimPath(key)); | ||
| expect(deviceClaimFilePath(key)).toBe(resolveDeviceClaimPath(key, process.env)); | ||
| } | ||
| }); | ||
|
|
||
| test('the restated path follows the claims directory override like the resolver', () => { | ||
| vi.stubEnv('AGENT_DEVICE_CLAIMS_DIR', path.join('relative', 'claims')); | ||
| vi.stubEnv('AGENT_DEVICE_CLAIMS_DIR', path.join(path.sep, 'tmp', 'agent-device-claims-override')); | ||
|
thymikee marked this conversation as resolved.
|
||
| for (const key of DEVICE_KEYS) { | ||
| expect(deviceClaimFilePath(key)).toBe(resolveDeviceClaimPath(key)); | ||
| expect(deviceClaimFilePath(key)).toBe(resolveDeviceClaimPath(key, process.env)); | ||
| expect(path.isAbsolute(deviceClaimFilePath(key))).toBe(true); | ||
| } | ||
| }); | ||
|
|
||
| test('a relative claims dir is refused instead of following the working directory', () => { | ||
| expect(() => resolveDeviceClaimRoot({ AGENT_DEVICE_CLAIMS_DIR: 'claims' })).toThrow( | ||
| expect.objectContaining({ | ||
| details: expect.objectContaining({ reason: 'relative_claims_dir' }), | ||
| }), | ||
| ); | ||
| }); | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.