Skip to content

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Jan 28, 2026

πŸ“‘ Description

Support run string command directly: facades.Process().Run("ls -a") instead of facades.Process().Run("/bin/sh", "-c", "ls -a").

βœ… Checks

  • Added test cases for my code

}

func (r *Process) Run(name string, args ...string) contractsprocess.Result {
name, args = formatCommand(name, args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we make this explicit by adding a RunShell method. The auto-detection is ambiguous. For instance, on Windows, running a binary inside c:\Program Files\App.exe would fail because the code treats the space as a shell separator.

It also creates inconsistent behavior. For instance, facades.Process().Run("ls | grep foo", "-la") will fail. Because a second argument is present, the logic skips the shell detection and tries to find an executable literally named 'ls | grep foo'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered adding a new function like RunShell, but I'm thinking if it's necessary to add a single function to support running string commands. I just want to omit /bin/sh -c, it's a bit heavy to add such a function.

c:\Program Files\App.exe is a good case, space may be contained in the route.

facades.Process().Run("ls | grep foo", "-la") doesn't trigger the formatCommand, so it's not related to this PR.

We can optimize the condition to if len(args) == 0 && str.Of(name).Contains("&", "|"), except space. Then it's simpler to run such commands:

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you are concerned about the verbosity of manually writing /bin/sh -c but the default Run method should remain raw and strict to avoid 'magic' inside it.

Go's standard library actually warns against this implicit shell invocation:

Unlike the "system" library call from C and other languages, the os/exec package intentionally does not invoke the system shell and does not expand any glob patterns or handle other expansions, pipelines, or redirections typically done by shells. The package behaves more like C's "exec" family of functions. To expand glob patterns, either call the shell directly, taking care to escape any dangerous input, or use the path/filepath package's Glob function. To expand environment variables, use package os's ExpandEnv.

https://pkg.go.dev/os/exec

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, if we need to provide this functionality, let’s add an annotation for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Go has own standard, and our function is following that as default. I just want to provide an additional way to run string commands directly. It's very convenient in some situations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd /c "c:\Program Files\App.exe" is a valid command, so the space character can be added here.

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 56.14035% with 25 lines in your changes missing coverage. Please review.
βœ… Project coverage is 69.99%. Comparing base (a059e1b) to head (99a2fbc).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
testing/service_provider.go 0.00% 8 Missing ⚠️
testing/docker/docker.go 44.44% 5 Missing ⚠️
process/process.go 60.00% 2 Missing and 2 partials ⚠️
support/docker/utils.go 78.57% 2 Missing and 1 partial ⚠️
testing/application.go 0.00% 3 Missing ⚠️
testing/docker/image.go 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1361      +/-   ##
==========================================
- Coverage   70.64%   69.99%   -0.65%     
==========================================
  Files         286      284       -2     
  Lines       17664    17709      +45     
==========================================
- Hits        12479    12396      -83     
- Misses       4657     4777     +120     
- Partials      528      536       +8     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl marked this pull request as ready for review January 30, 2026 09:32
@hwbrzzl hwbrzzl requested a review from a team as a code owner January 30, 2026 09:32
@hwbrzzl
Copy link
Contributor Author

hwbrzzl commented Jan 30, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

βœ… Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Warning

Rate limit exceeded

@hwbrzzl has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 56 seconds before requesting another review.

βŒ› How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bowen/optimize-process-1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hwbrzzl hwbrzzl merged commit 7135899 into master Jan 30, 2026
16 of 18 checks passed
@hwbrzzl hwbrzzl deleted the bowen/optimize-process-1 branch January 30, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants