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

Camelcade / Perl5-IDEA / #525521537

19 May 2025 08:07AM UTC coverage: 82.163% (-0.04%) from 82.204%
#525521537

push

github

hurricup
Got rid of exposed private members and inner classes

8 of 10 new or added lines in 5 files covered. (80.0%)

75 existing lines in 11 files now uncovered.

30862 of 37562 relevant lines covered (82.16%)

0.82 hits per line

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

60.38
/plugin/core/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.ProcessAdapter;
24
import com.intellij.execution.process.ProcessEvent;
25
import com.intellij.execution.process.ProcessHandler;
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.PerlPackageUtil;
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 = PerlRunUtil.findLibraryScriptWithNotification(perlSdk, getProject(), PROVE, PerlPackageUtil.TEST_HARNESS_MODULE);
1✔
69
    if (proveScript == null) {
1✔
UNCOV
70
      throw new ExecutionException(PerlBundle.message("perl.run.error.prove.missing", perlSdk.getName()));
×
71
    }
72
    return proveScript.getPath();
1✔
73
  }
74

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

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

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

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

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

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

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