• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Camelcade / Perl5-IDEA / #525521581

06 Jun 2025 08:26AM UTC coverage: 82.33% (-0.02%) from 82.354%
#525521581

push

github

hurricup
Moved debugger properties to the respective bundle

18 of 26 new or added lines in 8 files covered. (69.23%)

158 existing lines in 31 files now uncovered.

30858 of 37481 relevant lines covered (82.33%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.35
/plugin/profiler/src/main/java/com/perl5/lang/perl/profiler/run/PerlProfilerProgramRunner.java
1
/*
2
 * Copyright 2015-2025 Alexandr Evstigneev
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.perl5.lang.perl.profiler.run;
18

19
import com.intellij.execution.ExecutionException;
20
import com.intellij.execution.configurations.RunProfile;
21
import com.intellij.execution.configurations.RunProfileState;
22
import com.intellij.execution.runners.ExecutionEnvironment;
23
import com.intellij.execution.ui.RunContentDescriptor;
24
import com.intellij.openapi.application.PathManager;
25
import com.intellij.openapi.diagnostic.Logger;
26
import com.intellij.openapi.util.io.FileUtil;
27
import com.intellij.profiler.DefaultProfilerExecutorGroup;
28
import com.intellij.profiler.ProfilerToolWindowManager;
29
import com.perl5.lang.perl.idea.run.GenericPerlProgramRunner;
30
import com.perl5.lang.perl.idea.run.GenericPerlRunConfiguration;
31
import com.perl5.lang.perl.idea.run.PerlRunProfileState;
32
import com.perl5.lang.perl.profiler.PerlProfilerBundle;
33
import com.perl5.lang.perl.profiler.configuration.PerlProfilerConfigurationState;
34
import com.perl5.lang.perl.util.PerlPackageUtil;
35
import org.jetbrains.annotations.NotNull;
36
import org.jetbrains.annotations.Nullable;
37
import org.jetbrains.concurrency.AsyncPromise;
38

39
import java.io.IOException;
40
import java.util.Set;
41

42
@SuppressWarnings("UnstableApiUsage")
43
public class PerlProfilerProgramRunner extends GenericPerlProgramRunner {
1✔
44
  private static final Logger LOG = Logger.getInstance(PerlProfilerProgramRunner.class);
1✔
45

46
  @Override
47
  public @NotNull String getRunnerId() {
48
    return "Perl Profiler";
1✔
49
  }
50

51
  @Override
52
  public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
53
    if (!(profile instanceof GenericPerlRunConfiguration)) {
1✔
UNCOV
54
      return false;
×
55
    }
56
    var executorSettings = getExecutorSettings(executorId);
1✔
57
    return executorSettings != null && executorSettings.canRun(profile);
1✔
58
  }
59

60
  private static @Nullable DefaultProfilerExecutorGroup.ProfilerExecutorSettings getExecutorSettings(@NotNull String executorId) {
61
    var executorGroup = DefaultProfilerExecutorGroup.Companion.getInstance();
1✔
62
    if (executorGroup == null) {
1✔
UNCOV
63
      return null;
×
64
    }
65
    return executorGroup.getRegisteredSettings(executorId);
1✔
66
  }
67

68
  @Override
69
  protected @Nullable PerlRunProfileState createState(@NotNull ExecutionEnvironment executionEnvironment)
70
    throws ExecutionException {
71

72
    var executorSettings = getExecutorSettings(executionEnvironment.getExecutor().getId());
1✔
73
    if (executorSettings == null) {
1✔
74
      var message = PerlProfilerBundle.message("dialog.message.unable.to.find.executor.settings");
×
75
      LOG.error(message);
×
UNCOV
76
      throw new ExecutionException(message);
×
77
    }
78
    var runProfile = executionEnvironment.getRunProfile();
1✔
79
    if (!executorSettings.canRun(runProfile)) {
1✔
80
      var message = PerlProfilerBundle.message("dialog.message.unable.to.run.with", runProfile, executorSettings);
×
81
      LOG.error(message);
×
UNCOV
82
      throw new ExecutionException(message);
×
83
    }
84
    var perlProfilerConfigurationState = executorSettings.getState();
1✔
85
    if (!(perlProfilerConfigurationState instanceof PerlProfilerConfigurationState profilerConfigurationState)) {
1✔
86
      LOG.error("PerlProfilerConfigurationState expected, got: " + perlProfilerConfigurationState);
×
UNCOV
87
      throw new ExecutionException(
×
UNCOV
88
        PerlProfilerBundle.message("dialog.message.wrong.profiler.configuration.state", perlProfilerConfigurationState));
×
89
    }
90

91
    return new PerlProfilerRunProfileState(executionEnvironment, profilerConfigurationState);
1✔
92
  }
93

94
  @Override
95
  protected Set<String> getRequiredModules(@NotNull ExecutionEnvironment environment) {
96
    var modules = super.getRequiredModules(environment);
1✔
97
    modules.add(PerlPackageUtil.PROFILER_MODULE);
1✔
98
    return modules;
1✔
99
  }
100

101
  @Override
102
  protected void doExecute(@NotNull RunProfileState state,
103
                           @NotNull ExecutionEnvironment environment,
104
                           @NotNull AsyncPromise<? super RunContentDescriptor> result) throws ExecutionException {
105
    if (!(state instanceof PerlProfilerRunProfileState profilerRunProfileState)) {
1✔
UNCOV
106
      LOG.error("PerlProfilerRunProfileState expected, got " + state);
×
UNCOV
107
      throw new ExecutionException(PerlProfilerBundle.message("dialog.message.incorrect.run.configuration.state.see.logs.for.details"));
×
108
    }
109
    var profileResultsPath = profilerRunProfileState.getProfilingResultsPath();
1✔
110
    LOG.info("Profiling results saved in: " + profileResultsPath);
1✔
111
    if (FileUtil.isAncestor(PathManager.getSystemPath(), profileResultsPath.toString(), true)) {
1✔
112
      try {
113
        // fxime we probably should fix permissions here
114
        FileUtil.delete(profileResultsPath);
1✔
115
      }
UNCOV
116
      catch (IOException e) {
×
UNCOV
117
        throw new ExecutionException(PerlProfilerBundle.message("dialog.message.error.removing.old.profiling.data.at", profileResultsPath),
×
118
                                     e);
119
      }
1✔
120
    }
121
    else {
UNCOV
122
      LOG.error("Wrong profiler results directory: " + profileResultsPath);
×
123
    }
124
    //noinspection ResultOfMethodCallIgnored
125
    profileResultsPath.toFile().mkdirs();
1✔
126

127
    result.then(descriptor -> {
1✔
128
      if (descriptor instanceof RunContentDescriptor runContentDescriptor) {
1✔
129
        var profilerProcess = new PerlProfilerProcess(environment, runContentDescriptor, profilerRunProfileState);
1✔
130
        ProfilerToolWindowManager.getInstance(environment.getProject()).addProfilerProcessTab(profilerProcess, false);
1✔
131
      }
132
      return descriptor;
1✔
133
    });
134
    createAndSetContentDescriptor(environment, state.execute(environment.getExecutor(), this), result);
1✔
135
  }
1✔
136
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc