use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.
the class KarmaTestProxyFilterProvider method getFilter.
@Nullable
@Override
public Filter getFilter(@NotNull String nodeType, @NotNull String nodeName, @Nullable String nodeArguments) {
KarmaConfig config = myKarmaServer.getKarmaConfig();
String baseDir = config != null ? config.getBasePath() : null;
if ("browser".equals(nodeType)) {
AbstractFileHyperlinkFilter browserFilter = BrowserStacktraceFilters.createFilter(nodeName, myProject, baseDir);
if (browserFilter != null) {
return new KarmaSourceMapStacktraceFilter(myProject, baseDir, browserFilter);
}
}
if ("browserError".equals(nodeType)) {
return getBrowserErrorFilter();
}
return null;
}
use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.
the class KarmaServerState method canSetBrowsersReady.
private boolean canSetBrowsersReady() {
List<String> expectedBrowsers = myOverriddenBrowsers;
if (expectedBrowsers == null) {
KarmaConfig config = myConfig;
if (config == null) {
return true;
}
expectedBrowsers = config.getBrowsers();
}
Set<String> expectedBrowserSet = ContainerUtil.newHashSet(expectedBrowsers);
expectedBrowserSet.removeAll(myFailedToStartBrowsers);
int autoCapturedBrowserCount = getAutoCapturedBrowserCount();
return autoCapturedBrowserCount > 0 && expectedBrowserSet.size() <= autoCapturedBrowserCount;
}
use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.
the class KarmaDebugProgramRunner method getDebuggableFileFinder.
private static DebuggableFileFinder getDebuggableFileFinder(@NotNull KarmaServer karmaServer) {
BiMap<String, VirtualFile> mappings = HashBiMap.create();
KarmaConfig karmaConfig = karmaServer.getKarmaConfig();
if (karmaConfig != null) {
VirtualFile basePath = LocalFileSystem.getInstance().findFileByPath(karmaConfig.getBasePath());
if (basePath != null && basePath.isValid()) {
if (karmaConfig.isWebpack()) {
mappings.put("webpack:///" + basePath.getPath(), basePath);
VirtualFile nodeModulesDir = basePath.findChild(NodeModuleUtil.NODE_MODULES);
if (nodeModulesDir != null && nodeModulesDir.isValid() && nodeModulesDir.isDirectory()) {
mappings.put(karmaServer.formatUrlWithoutUrlRoot("/base/" + NodeModuleUtil.NODE_MODULES), nodeModulesDir);
}
} else {
mappings.put(karmaServer.formatUrlWithoutUrlRoot("/base"), basePath);
}
}
}
if (SystemInfo.isWindows) {
VirtualFile[] roots = ManagingFS.getInstance().getLocalRoots();
for (VirtualFile root : roots) {
String key = karmaServer.formatUrlWithoutUrlRoot("/absolute" + root.getName());
if (mappings.containsKey(key)) {
LOG.warn("Duplicate mapping for Karma debug: " + key);
} else {
mappings.put(key, root);
}
}
} else {
VirtualFile[] roots = ManagingFS.getInstance().getLocalRoots();
if (roots.length == 1) {
mappings.put(karmaServer.formatUrlWithoutUrlRoot("/absolute"), roots[0]);
}
}
return new RemoteDebuggingFileFinder(mappings, null);
}
use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.
the class KarmaExecutionSession method createCommandLine.
@NotNull
private GeneralCommandLine createCommandLine(@NotNull NodeJsLocalInterpreter interpreter, int serverPort, @Nullable KarmaConfig config, @NotNull File clientAppFile) throws ExecutionException {
GeneralCommandLine commandLine = new GeneralCommandLine();
File configFile = new File(myRunSettings.getConfigPath());
// looks like it should work with any working directory
commandLine.setWorkDirectory(configFile.getParentFile());
commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
commandLine.setExePath(interpreter.getInterpreterSystemDependentPath());
//NodeCommandLineUtil.addNodeOptionsForDebugging(commandLine, Collections.emptyList(), 5858, false, interpreter, true);
commandLine.addParameter(clientAppFile.getAbsolutePath());
commandLine.addParameter("--karmaPackageDir=" + myKarmaServer.getServerSettings().getKarmaPackage().getSystemDependentPath());
commandLine.addParameter("--serverPort=" + serverPort);
if (config != null) {
commandLine.addParameter("--urlRoot=" + config.getUrlRoot());
}
if (isDebug()) {
commandLine.addParameter("--debug=true");
}
if (myRunSettings.getScopeKind() == KarmaScopeKind.TEST_FILE) {
List<String> topNames = findTopLevelSuiteNames(myProject, myRunSettings.getTestFileSystemIndependentPath());
if (topNames.size() > 1) {
throw new ExecutionException("Cannot run test file with several top level suites");
}
topNames = ContainerUtil.map(topNames, s -> s + " ");
commandLine.addParameter("--testName=" + StringUtil.join(topNames, "|"));
} else if (myRunSettings.getScopeKind() == KarmaScopeKind.SUITE || myRunSettings.getScopeKind() == KarmaScopeKind.TEST) {
commandLine.addParameter("--testName=" + StringUtil.join(myRunSettings.getTestNames(), " "));
}
return commandLine;
}
use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.
the class KarmaCoverageRunner method loadCoverageData.
@Override
public ProjectData loadCoverageData(@NotNull File sessionDataFile, @Nullable CoverageSuite baseCoverageSuite) {
KarmaConfig karmaConfig = null;
if (myKarmaServer != null) {
karmaConfig = myKarmaServer.getKarmaConfig();
}
String basePath = null;
if (karmaConfig != null) {
basePath = karmaConfig.getBasePath();
}
if (basePath != null) {
File basePathDir = new File(basePath);
if (basePathDir.isAbsolute() && basePathDir.isDirectory()) {
try {
return readProjectData(sessionDataFile, basePathDir);
} catch (Exception e) {
LOG.warn("Can't read coverage data", e);
}
}
}
return null;
}
Aggregations