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

Camelcade / Perl5-IDEA / #525521635

20 Jul 2025 03:45PM UTC coverage: 82.266% (-0.09%) from 82.355%
#525521635

push

github

hurricup
Build 252.23892.248

30936 of 37605 relevant lines covered (82.27%)

0.82 hits per line

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

61.11
/plugin/backend/src/main/java/com/perl5/lang/perl/idea/run/prove/PerlTestRunConfiguration.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.idea.run.prove;
18

19
import com.google.common.annotations.VisibleForTesting;
20
import com.intellij.execution.ExecutionException;
21
import com.intellij.execution.configurations.ConfigurationFactory;
22
import com.intellij.execution.configurations.RuntimeConfigurationException;
23
import com.intellij.execution.process.ProcessEvent;
24
import com.intellij.execution.process.ProcessHandler;
25
import com.intellij.execution.process.ProcessListener;
26
import com.intellij.openapi.diagnostic.Logger;
27
import com.intellij.openapi.project.Project;
28
import com.intellij.openapi.projectRoots.Sdk;
29
import com.intellij.openapi.util.Key;
30
import com.intellij.openapi.util.text.StringUtil;
31
import com.intellij.openapi.vfs.VirtualFile;
32
import com.perl5.PerlBundle;
33
import com.perl5.lang.perl.util.PerlPackageUtilCore;
34
import com.perl5.lang.perl.util.PerlRunUtil;
35
import org.jetbrains.annotations.NotNull;
36
import org.jetbrains.annotations.Nullable;
37

38
import java.util.*;
39
import java.util.regex.Matcher;
40
import java.util.regex.Pattern;
41

42
@VisibleForTesting
43
public class PerlTestRunConfiguration extends PerlAbstractTestRunConfiguration {
44
  private static final Logger LOG = Logger.getInstance(PerlTestRunConfiguration.class);
1✔
45
  private static final String PROVE = "prove";
46
  private static final String PROVE_FORMAT_ARGUMENT = "--formatter";
47
  private static final String PROVE_FRAMEWORK_NAME = "Prove";
48
  private static final Pattern MISSING_FILTER_PATTERN = Pattern.compile("Can't load module (\\S+) at .+?/prove line");
1✔
49
  private static final String PROVE_PLUGIN_NAMESPACE = "App::Prove::Plugin";
50
  private static final List<String> PROVE_DEFAULT_ARGUMENTS = Arrays.asList("--merge", "--recurse");
1✔
51
  private static final String PROVE_JOBS_SHORT_PREFIX = "-j";
52
  private static final String PROVE_JOBS_PARAMETER = "--jobs";
53

54
  public PerlTestRunConfiguration(@NotNull Project project,
55
                                  @NotNull ConfigurationFactory factory,
56
                                  @Nullable String name) {
57
    super(project, factory, name);
1✔
58
  }
1✔
59

60
  @Override
61
  protected @NotNull List<String> getDefaultTestRunnerArguments() {
62
    return PROVE_DEFAULT_ARGUMENTS;
1✔
63
  }
64

65
  @Override
66
  protected @NotNull String getTestRunnerLocalPath() throws ExecutionException {
67
    Sdk perlSdk = getEffectiveSdk();
1✔
68
    VirtualFile proveScript =
1✔
69
      PerlRunUtil.findLibraryScriptWithNotification(perlSdk, getProject(), PROVE, PerlPackageUtilCore.TEST_HARNESS_MODULE);
1✔
70
    if (proveScript == null) {
1✔
71
      throw new ExecutionException(PerlBundle.message("perl.run.error.prove.missing", perlSdk.getName()));
×
72
    }
73
    return proveScript.getPath();
1✔
74
  }
75

76
  @Override
77
  protected @NotNull List<String> getTestsArguments() {
78
    List<String> testScriptParametersList = getTestScriptParametersList();
1✔
79
    if (testScriptParametersList.isEmpty()) {
1✔
80
      return Collections.emptyList();
1✔
81
    }
82
    var result = new ArrayList<String>();
×
83
    result.add("::");
×
84
    result.addAll(testScriptParametersList);
×
85
    return result;
×
86
  }
87

88
  @Override
89
  protected @NotNull List<String> getScriptArguments() {
90
    List<String> userArguments = super.getScriptArguments();
1✔
91
    for (Iterator<String> iterator = userArguments.iterator(); iterator.hasNext(); ) {
1✔
92
      String userParameter = iterator.next();
×
93
      if (StringUtil.startsWith(userParameter, PROVE_JOBS_SHORT_PREFIX)) {
×
94
        iterator.remove();
×
95
      }
96
      else if (PROVE_FORMAT_ARGUMENT.equals(userParameter) || PROVE_JOBS_PARAMETER.equals(userParameter)) {
×
97
        iterator.remove();
×
98
        if (iterator.hasNext()) {
×
99
          iterator.next();
×
100
          iterator.remove();
×
101
        }
102
      }
103
    }
×
104
    return userArguments;
1✔
105
  }
106

107
  @Override
108
  protected @NotNull String getFrameworkName() {
109
    return PROVE_FRAMEWORK_NAME;
1✔
110
  }
111

112
  @Override
113
  protected @NotNull ProcessHandler doPatchProcessHandler(@NotNull ProcessHandler processHandler) {
114
    try {
115
      Sdk effectiveSdk = getEffectiveSdk();
1✔
116
      processHandler.addProcessListener(new ProcessListener() {
1✔
117
        @Override
118
        public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
119
          String inputText = event.getText();
1✔
120
          Matcher matcher = MISSING_FILTER_PATTERN.matcher(inputText);
1✔
121
          if (matcher.find()) {
1✔
122
            String libraryName = PROVE_PLUGIN_NAMESPACE + PerlPackageUtilCore.NAMESPACE_SEPARATOR + matcher.group(1);
×
123
            PerlRunUtil.showMissingLibraryNotification(getProject(), effectiveSdk, Collections.singletonList(libraryName));
×
124
          }
125
        }
1✔
126
      });
127
    }
128
    catch (ExecutionException e) {
×
129
      LOG.warn("Missing effective sdk for test configuration: " + getName());
×
130
    }
1✔
131
    return processHandler;
1✔
132
  }
133

134
  @Override
135
  protected void checkConfigurationScriptPath() throws RuntimeConfigurationException {
136
    if (StringUtil.isEmptyOrSpaces(getScriptPath())) {
1✔
137
      throw new RuntimeConfigurationException(PerlBundle.message("perl.run.error.no.test.set"));
×
138
    }
139
    if (computeTargetFiles().isEmpty()) {
1✔
140
      throw new RuntimeConfigurationException(PerlBundle.message("perl.run.error.no.tests.found"));
×
141
    }
142
  }
1✔
143

144
  @Override
145
  public void checkConfiguration() throws RuntimeConfigurationException {
146
    super.checkConfiguration();
1✔
147
    if (PerlRunUtil.findScript(getProject(), PROVE) == null) {
1✔
148
      throw new RuntimeConfigurationException(PerlBundle.message("perl.run.error.no.prove.found"));
×
149
    }
150
  }
1✔
151

152
  @Override
153
  protected @NotNull PerlTestRunConfigurationProducer getRunConfigurationProducer() {
154
    return PerlTestRunConfigurationProducer.getInstance();
1✔
155
  }
156
}
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