mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
version test added; log error and result during version parsing updated
This commit is contained in:
@@ -27,7 +27,8 @@ import java.util.regex.Pattern;
|
||||
public class HgVersionCommand {
|
||||
|
||||
private static final Logger LOGGER = Logger.getInstance(HgVersionCommand.class);
|
||||
private static final Pattern HG_VERSION_PATTERN = Pattern.compile(".+\\(\\s*version\\s+([0-9]+\\.[0-9]*)\\+?([0-9]*)[0-9\\.]*\\s*\\)\\s*");
|
||||
private static final Pattern HG_VERSION_PATTERN =
|
||||
Pattern.compile(".+\\(\\s*version\\s+([0-9]+\\.[0-9]*)\\+?([0-9]*)[0-9\\.]*\\s*\\)\\s*");
|
||||
|
||||
public Double getVersion(String executable, boolean isRunViaBash) {
|
||||
String hgExecutable = executable == null ? null : executable.trim();
|
||||
@@ -56,6 +57,10 @@ public class HgVersionCommand {
|
||||
if (matcher.matches()) {
|
||||
return Double.valueOf(matcher.group(1).concat(matcher.group(2)));
|
||||
}
|
||||
return null;
|
||||
if (versionResult.getOutputLines().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
LOGGER.error("Couldn't identify hg version: " + versionResult.getOutputLines());
|
||||
return new Double(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package hg4idea.test.version;
|
||||
|
||||
import hg4idea.test.HgPlatformTest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.zmlx.hg4idea.HgVcs;
|
||||
import org.zmlx.hg4idea.command.HgVersionCommand;
|
||||
|
||||
/**
|
||||
* @author Nadya Zabrodina
|
||||
*/
|
||||
public class HgVersionTest extends HgPlatformTest {
|
||||
|
||||
@NotNull private HgVcs myVcs;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
HgVcs vcs = HgVcs.getInstance(myProject);
|
||||
assertNotNull(vcs);
|
||||
myVcs = vcs;
|
||||
}
|
||||
|
||||
public void testVersionCommandForCurrentHgVersion() {
|
||||
Double version =
|
||||
new HgVersionCommand().getVersion(myVcs.getGlobalSettings().getHgExecutable(), myVcs.getGlobalSettings().isRunViaBash());
|
||||
assertNotNull(version);
|
||||
assertTrue(version > 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user