Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/language-profilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ looks for `rc-profiler-typescript`, then `runtimeconditions-typescript-profiler`
`rc-profiler-java`, or `runtimeconditions-python-profiler`, on `PATH`;
`RC_TYPESCRIPT_PROFILER`, `RC_JAVA_PROFILER`, or `RC_PYTHON_PROFILER` can name an absolute
path instead. It runs the add-on only if `--version --json` lists the core profile schema
`rc` targets (0.4.0). The add-on's output and exit status pass through.
`rc` targets (0.4.0). The add-on's output and exit status pass through. When `rc`
invokes an add-on, it sets `RC_COMMAND_PREFIX` in its environment (for example
`rc profile typescript`), so the add-on's usage text and diagnostics can suggest
commands the user can copy directly.

The Java launcher chooses the JDK, not `rc`: `RC_JAVA_HOME`, then `JAVA_HOME`, then the
runtime bundled in its system package, then `java` on `PATH`. It needs JDK 17 or newer and
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ func newLanguageCommand(language plugins.Language, deps Dependencies) *cobra.Com
return fmt.Errorf("the %s profiler %s at %s supports core profile schema %s, but this rc targets %s; install a matching version with: %s",
language.Display, info.Version, found.Path, strings.Join(info.CoreSchemas, ", "), coreSchemaVersion, language.InstallHint)
}
env := append(os.Environ(), "RC_COMMAND_PREFIX="+cmd.CommandPath())
code, err := deps.Runner.Run(ctx, process.Spec{
Path: found.Path, Args: args,
Path: found.Path, Args: args, Env: env,
Stdin: cmd.InOrStdin(), Stdout: cmd.OutOrStdout(), Stderr: cmd.ErrOrStderr(),
})
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions internal/cli/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func TestAddOnReceivesItsArgumentsUnchangedAndItsOutputPassesThrough(t *testing.
if len(runner.calls) != 1 || runner.calls[0].Path != "/usr/bin/rc-profiler-typescript" || !slices.Equal(runner.calls[0].Args, args) {
t.Fatalf("calls %+v", runner.calls)
}
if !slices.Contains(runner.calls[0].Env, "RC_COMMAND_PREFIX=rc profile typescript") {
t.Fatalf("expected RC_COMMAND_PREFIX in env, got: %v", runner.calls[0].Env)
}
}

func TestAddOnHelpAndVersionFlagsReachTheAddOn(t *testing.T) {
Expand Down Expand Up @@ -240,6 +243,9 @@ func TestJavaAddOnReceivesItsArgumentsUnchangedAndItsOutputPassesThrough(t *test
if len(runner.calls) != 1 || runner.calls[0].Path != "/usr/bin/rc-profiler-java" || !slices.Equal(runner.calls[0].Args, args) {
t.Fatalf("calls: %+v", runner.calls)
}
if !slices.Contains(runner.calls[0].Env, "RC_COMMAND_PREFIX=rc profile java") {
t.Fatalf("expected RC_COMMAND_PREFIX in env, got: %v", runner.calls[0].Env)
}
}

func TestJavaAddOnThatIsNotInstalledSaysHowToGetIt(t *testing.T) {
Expand Down Expand Up @@ -272,6 +278,9 @@ func TestPythonAddOnReceivesItsArgumentsUnchangedAndItsOutputPassesThrough(t *te
if len(runner.calls) != 1 || runner.calls[0].Path != "/usr/bin/runtimeconditions-python-profiler" || !slices.Equal(runner.calls[0].Args, args) {
t.Fatalf("calls: %+v", runner.calls)
}
if !slices.Contains(runner.calls[0].Env, "RC_COMMAND_PREFIX=rc profile python") {
t.Fatalf("expected RC_COMMAND_PREFIX in env, got: %v", runner.calls[0].Env)
}
}

func TestPythonAddOnThatIsNotInstalledSaysHowToGetIt(t *testing.T) {
Expand Down
Loading