-
Notifications
You must be signed in to change notification settings - Fork 92
sandbox: Make updated resource path configurable #154
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,9 +10,9 @@ func TestSandbox(t *testing.T) { | |
| var sandbox Sandbox | ||
| var err error | ||
| if runtime.GOOS == "windows" { | ||
| sandbox, err = Create(t.Context(), ConfigurationLlamaCpp, nil, "go", "version") | ||
| sandbox, err = Create(t.Context(), ConfigurationLlamaCpp, nil, "/some/path/bin", "go", "version") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Test does not verify the effect of configurable resource paths. Please add assertions to confirm that the sandbox configuration uses the provided path and its derived lib path as intended. Suggested implementation: if err != nil {
t.Fatal("unable to create sandboxed process:", err)
}
// Assert that the sandbox uses the provided bin path
if sandbox.BinPath != "/some/path/bin" {
t.Errorf("expected BinPath to be '/some/path/bin', got '%s'", sandbox.BinPath)
}
// Assert that the sandbox uses the derived lib path
expectedLibPath := "/some/path/bin/lib"
if sandbox.LibPath != expectedLibPath {
t.Errorf("expected LibPath to be '%s', got '%s'", expectedLibPath, sandbox.LibPath)
}If the |
||
| } else { | ||
| sandbox, err = Create(t.Context(), ConfigurationLlamaCpp, nil, "date") | ||
| sandbox, err = Create(t.Context(), ConfigurationLlamaCpp, nil, "/some/path/bin", "date") | ||
| } | ||
| if err != nil { | ||
| t.Fatal("unable to create sandboxed process:", err) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ func (s *sandbox) Close() error { | |
| // configuration, for which a pre-defined value should be used. The modifier | ||
| // function allows for an optional callback (which may be nil) to configure the | ||
| // command before it is started. | ||
| func Create(ctx context.Context, configuration string, modifier func(*exec.Cmd), name string, arg ...string) (Sandbox, error) { | ||
| func Create(ctx context.Context, configuration string, modifier func(*exec.Cmd), updatedBinPath, name string, arg ...string) (Sandbox, error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: updatedBinPath parameter is unused in this implementation. If updatedBinPath is included only for interface consistency, please document this or refactor to prevent confusion. Suggested implementation: /*
Create initializes a new Sandbox instance.
configuration: Pre-defined configuration value.
modifier: Optional callback to configure the command before it is started (may be nil).
updatedBinPath: Included for interface consistency with other platforms; currently unused in this implementation.
name: Name of the command to execute.
arg: Arguments to pass to the command.
*/
func Create(ctx context.Context, configuration string, modifier func(*exec.Cmd), updatedBinPath, name string, arg ...string) (Sandbox, error) {func Create(ctx context.Context, configuration string, modifier func(*exec.Cmd), updatedBinPath, name string, arg ...string) (Sandbox, error) {
// updatedBinPath is intentionally unused in this implementation.
// Parse the configuration and configure limits.
limits := []winjob.Limit{winjob.WithKillOnJobClose()}
tokens := limitTokenMatcher.FindAllString(configuration, -1) |
||
| // Parse the configuration and configure limits. | ||
| limits := []winjob.Limit{winjob.WithKillOnJobClose()} | ||
| tokens := limitTokenMatcher.FindAllString(configuration, -1) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: updatedBinPath parameter is unused in this implementation.
If updatedBinPath is included for cross-platform consistency, please document this in the code. Otherwise, consider removing it to avoid confusion.