changeset 839:64fb4e1e23a2

do not run via CMD tests if HG is too legacy
author eugene.petrenko@jetbrains.com
date Tue, 03 Jun 2014 14:02:34 +0200
parents 7e461ea697f1
children e36e8d036ebd
files .idea/runConfigurations/tests_via_file.xml mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ViaCMDInterceptor.java mercurial-tests/src/testng-via-cmd.xml
diffstat 3 files changed, 103 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.idea/runConfigurations/tests_via_file.xml	Mon Jun 02 16:20:41 2014 +0200
+++ b/.idea/runConfigurations/tests_via_file.xml	Tue Jun 03 14:02:34 2014 +0200
@@ -4,7 +4,7 @@
     <module name="mercurial-tests" />
     <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
     <option name="ALTERNATIVE_JRE_PATH" value="" />
-    <option name="SUITE_NAME" value="$PROJECT_DIR$/mercurial-tests/src/testng.xml" />
+    <option name="SUITE_NAME" value="$PROJECT_DIR$/mercurial-tests/src/testng-via-cmd.xml" />
     <option name="PACKAGE_NAME" value="" />
     <option name="MAIN_CLASS_NAME" value="" />
     <option name="METHOD_NAME" value="" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ViaCMDInterceptor.java	Tue Jun 03 14:02:34 2014 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2000-2014 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 jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.VersionCommand;
+import org.testng.IMethodInstance;
+import org.testng.IMethodInterceptor;
+import org.testng.ITestContext;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Created 03.06.2014 13:22
+ *
+ * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
+ */
+public class ViaCMDInterceptor implements IMethodInterceptor {
+  public List<IMethodInstance> intercept(List<IMethodInstance> list, ITestContext iTestContext) {
+    if (!"true".equalsIgnoreCase(System.getProperty("teamcity.mercurial.use.commandline.via.file.wrapper"))) {
+      return list;
+    }
+
+    try {
+      final String path = Util.getHgPath();
+      final VersionCommand versionCommand = new VersionCommand(new TestCommandSettingsFactory().create(), path, new File(".."));
+      final HgVersion version = versionCommand.call();
+
+      if (!version.isEqualsOrGreaterThan(new HgVersion(2,5,0))) {
+        System.out.println("!!! Mercurial version is too old: " + version + "  @ " + path);
+        return Collections.emptyList();
+      }
+
+      return list;
+    } catch (Throwable t) {
+      System.out.println("Invalid mercurial: " + t.getMessage());
+      return Collections.emptyList();
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/testng-via-cmd.xml	Tue Jun 03 14:02:34 2014 +0200
@@ -0,0 +1,46 @@
+<!--
+  ~ Copyright 2000-2014 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.
+  -->
+
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="Mercurial Suite">
+  <listeners>
+    <listener class-name="jetbrains.buildServer.buildTriggers.vcs.mercurial.ViaCMDInterceptor"/>
+  </listeners>
+
+  <test name="Mercurial via commands file tests">
+    <classes>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CatCommandTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CloneCommandTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.LogCommandTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.StatusCommandTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.PushCommandTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.IdentifyCommandTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialVcsSupportTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.VersionCommandTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.DagFeaturesTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.UnrelatedResitoriesTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.ListFilesSupportTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.SubrepoChangesTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.SubrepoPatchTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MergeSupportTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.TagsTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.CommitsInfoBuilderSupportTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialModificationInfoBuilderTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialUrlSupportTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.PurgeTest"/>
+    </classes>
+  </test>
+</suite>