Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoPatchTest.java @ 946:50968ab011d9
TW-34711 update libraries
author | Dmitry Neverov <dmitry.neverov@gmail.com> |
---|---|
date | Wed, 16 Mar 2016 14:20:46 +0100 |
parents | c3dc302af86a |
children | 7bf4d943d5bb |
line wrap: on
line source
/* * 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.vcs.CheckoutRules; import jetbrains.buildServer.vcs.VcsRoot; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.File; import static com.intellij.openapi.util.io.FileUtil.delete; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.buildPatch; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; @Test public class SubrepoPatchTest extends BaseMercurialPatchTestCase { private MercurialVcsSupport myVcs; private File myRemoteRepo1; private File myRemoteRepo2; private File myRemoteRepo3; private ServerPluginConfig myPluginConfig; private VcsRoot myRoot; @BeforeMethod public void setUp() throws Exception { super.setUp(); File remoteRepoParentDir = myTempFiles.createTempDir(); myRemoteRepo1 = new File(remoteRepoParentDir, "r1"); myRemoteRepo2 = new File(remoteRepoParentDir, "r2"); myRemoteRepo3 = new File(remoteRepoParentDir, "r3"); copyRepository(new File("mercurial-tests/testData/subrepos/r1"), myRemoteRepo1); copyRepository(new File("mercurial-tests/testData/subrepos/r2"), myRemoteRepo2); copyRepository(new File("mercurial-tests/testData/subrepos/r3"), myRemoteRepo3); myPluginConfig = new ServerPluginConfigBuilder() .cachesDir(myTempFiles.createTempDir()) .detectSubrepoChanges(true) .build(); myVcs = mercurialSupport().withConfig(myPluginConfig).build(); myRoot = vcsRoot().withUrl(myRemoteRepo1.getAbsolutePath()).withSubrepoChanges(true).build(); } @Override protected String getTestDataPath() { return "mercurial-tests/testData"; } public void clean_patch_should_use_subrepo_clones_on_the_server() throws Exception { //this makes plugin to clone r1 and its subrepos myVcs.getCollectChangesPolicy().collectChanges(myRoot, "e4eced2b7381", "d64d9799c143", CheckoutRules.DEFAULT); //delete remote subrepo to make sure patch is build from the clone on the server delete(myRemoteRepo3); setName("clean_patch_with_subrepositories"); checkPatchResult(buildPatch(myVcs, myRoot, null, "d350e7209906", CheckoutRules.DEFAULT).toByteArray()); } public void clean_patch_should_use_subrepo_clones_on_the_server_recursive_case() throws Exception { //this makes plugin to clone r1 and its subrepos myVcs.getCollectChangesPolicy().collectChanges(myRoot, "e4eced2b7381", "d64d9799c143", CheckoutRules.DEFAULT); //delete remote subrepos to make sure patch is build from the clone on the server delete(new File(myRemoteRepo2, ".hg")); //remove .hg but leave parent dir untouched, url resolution needs that delete(new File(myRemoteRepo3, ".hg")); setName("clean_patch_recursive_subrepos"); checkPatchResult(buildPatch(myVcs, myRoot, null, "d64d9799c143", CheckoutRules.DEFAULT).toByteArray()); } public void incremental_patch_subrepo_revision_changed() throws Exception { setName("inc_patch_subrepo_revision_changed"); checkPatchResult(buildPatch(myVcs, myRoot, "d350e7209906", "09c256b6163e", CheckoutRules.DEFAULT).toByteArray()); } public void incremental_patch_subrepo_added() throws Exception { setName("inc_patch_subrepo_added"); checkPatchResult(buildPatch(myVcs, myRoot, "4d7b3db8779f", "d350e7209906", CheckoutRules.DEFAULT).toByteArray()); } public void incremental_patch_subrepo_removed() throws Exception { setName("inc_patch_subrepo_removed"); checkPatchResult(buildPatch(myVcs, myRoot, "34017377d9c3", "4d7b3db8779f", CheckoutRules.DEFAULT).toByteArray()); } public void incremental_patch_subrepo_url_changed() throws Exception { setName("inc_patch_subrepo_url_changed"); checkPatchResult(buildPatch(myVcs, myRoot, "34017377d9c3", "d64d9799c143", CheckoutRules.DEFAULT).toByteArray()); } public void incremental_patch_with_checkout_rules() throws Exception { setName("inc_patch_subrepo_with_checkout_rules"); checkPatchResult(buildPatch(myVcs, myRoot, "d350e7209906", "09c256b6163e", new CheckoutRules("+:.=>subdir")).toByteArray()); } public void incremental_patch_with_excluding_checkout_rules() throws Exception { setName("inc_patch_subrepo_with_excluding_checkout_rules"); checkPatchResult(buildPatch(myVcs, myRoot, "d350e7209906", "09c256b6163e", new CheckoutRules("+:.=>subdir\n-:r2")).toByteArray()); } }