Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 1 | // Copyright 2015 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | package com.google.devtools.build.lib.skyframe; |
| 15 | |
lberki | aea56b3 | 2017-05-30 12:35:33 +0200 | [diff] [blame] | 16 | import static com.google.common.truth.Truth.assertThat; |
Florian Weikert | 92b2236 | 2015-12-03 10:17:18 +0000 | [diff] [blame] | 17 | |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 18 | import com.google.common.collect.ImmutableList; |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableMap; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 20 | import com.google.common.collect.ImmutableSet; |
| 21 | import com.google.common.testing.EqualsTester; |
Kristina Chodorow | 5a2936f | 2016-04-22 17:02:19 +0000 | [diff] [blame] | 22 | import com.google.devtools.build.lib.analysis.BlazeDirectories; |
janakr | 3b63a4e | 2017-09-14 09:55:40 +0200 | [diff] [blame] | 23 | import com.google.devtools.build.lib.analysis.ServerDirectories; |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 24 | import com.google.devtools.build.lib.analysis.util.AnalysisMock; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 25 | import com.google.devtools.build.lib.cmdline.PackageIdentifier; |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 26 | import com.google.devtools.build.lib.cmdline.RepositoryName; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 27 | import com.google.devtools.build.lib.events.NullEventHandler; |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 28 | import com.google.devtools.build.lib.packages.PackageFactory; |
| 29 | import com.google.devtools.build.lib.packages.PackageFactory.EnvironmentExtension; |
| 30 | import com.google.devtools.build.lib.packages.RuleClassProvider; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 31 | import com.google.devtools.build.lib.pkgcache.PathPackageLocator; |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 32 | import com.google.devtools.build.lib.rules.repository.LocalRepositoryFunction; |
| 33 | import com.google.devtools.build.lib.rules.repository.LocalRepositoryRule; |
| 34 | import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction; |
| 35 | import com.google.devtools.build.lib.rules.repository.RepositoryFunction; |
| 36 | import com.google.devtools.build.lib.rules.repository.RepositoryLoaderFunction; |
Nathan Harmata | d4f7594 | 2016-10-18 08:55:17 +0000 | [diff] [blame] | 37 | import com.google.devtools.build.lib.skyframe.ExternalFilesHelper.ExternalFileAction; |
John Cater | 5e9ce94 | 2016-10-12 17:23:30 +0000 | [diff] [blame] | 38 | import com.google.devtools.build.lib.skyframe.PackageLookupFunction.CrossRepositoryLabelViolationStrategy; |
brandjon | dbff8b8 | 2017-10-23 19:02:31 +0200 | [diff] [blame] | 39 | import com.google.devtools.build.lib.syntax.SkylarkSemantics; |
Florian Weikert | cca703a | 2015-12-07 09:56:38 +0000 | [diff] [blame] | 40 | import com.google.devtools.build.lib.testutil.FoundationTestCase; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 41 | import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; |
Eric Fellheimer | e040fe9 | 2015-11-09 23:54:46 +0000 | [diff] [blame] | 42 | import com.google.devtools.build.lib.vfs.PathFragment; |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 43 | import com.google.devtools.build.lib.vfs.Root; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 44 | import com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator; |
| 45 | import com.google.devtools.build.skyframe.MemoizingEvaluator; |
| 46 | import com.google.devtools.build.skyframe.RecordingDifferencer; |
janakr | 1cde872 | 2017-10-10 03:22:21 +0200 | [diff] [blame] | 47 | import com.google.devtools.build.skyframe.SequencedRecordingDifferencer; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 48 | import com.google.devtools.build.skyframe.SequentialBuildDriver; |
| 49 | import com.google.devtools.build.skyframe.SkyFunction; |
| 50 | import com.google.devtools.build.skyframe.SkyFunctionName; |
| 51 | import com.google.devtools.build.skyframe.SkyKey; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 52 | import java.util.HashMap; |
| 53 | import java.util.Map; |
| 54 | import java.util.UUID; |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 55 | import java.util.concurrent.atomic.AtomicBoolean; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 56 | import java.util.concurrent.atomic.AtomicReference; |
John Cater | 5e9ce94 | 2016-10-12 17:23:30 +0000 | [diff] [blame] | 57 | import org.junit.Before; |
| 58 | import org.junit.Test; |
| 59 | import org.junit.runner.RunWith; |
| 60 | import org.junit.runners.JUnit4; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Tests for {@link ContainingPackageLookupFunction}. |
| 64 | */ |
Florian Weikert | 92b2236 | 2015-12-03 10:17:18 +0000 | [diff] [blame] | 65 | @RunWith(JUnit4.class) |
Florian Weikert | cca703a | 2015-12-07 09:56:38 +0000 | [diff] [blame] | 66 | public class ContainingPackageLookupFunctionTest extends FoundationTestCase { |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 67 | |
| 68 | private AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages; |
| 69 | private MemoizingEvaluator evaluator; |
| 70 | private SequentialBuildDriver driver; |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 71 | private RecordingDifferencer differencer; |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 72 | |
Florian Weikert | 92b2236 | 2015-12-03 10:17:18 +0000 | [diff] [blame] | 73 | @Before |
| 74 | public final void setUp() throws Exception { |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 75 | AnalysisMock analysisMock = AnalysisMock.get(); |
| 76 | |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 77 | AtomicReference<PathPackageLocator> pkgLocator = |
John Cater | e0d1d0e | 2017-11-28 20:47:41 -0800 | [diff] [blame] | 78 | new AtomicReference<>( |
| 79 | new PathPackageLocator( |
| 80 | outputBase, |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 81 | ImmutableList.of(Root.fromPath(rootDirectory)), |
John Cater | e0d1d0e | 2017-11-28 20:47:41 -0800 | [diff] [blame] | 82 | BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY)); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 83 | deletedPackages = new AtomicReference<>(ImmutableSet.<PackageIdentifier>of()); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 84 | BlazeDirectories directories = |
Nathan Harmata | d4f7594 | 2016-10-18 08:55:17 +0000 | [diff] [blame] | 85 | new BlazeDirectories( |
Klaus Aehlig | c2499c4 | 2018-02-27 05:47:21 -0800 | [diff] [blame] | 86 | new ServerDirectories(rootDirectory, outputBase, outputBase), |
janakr | 3b63a4e | 2017-09-14 09:55:40 +0200 | [diff] [blame] | 87 | rootDirectory, |
| 88 | analysisMock.getProductName()); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 89 | ExternalFilesHelper externalFilesHelper = |
nharmata | 3fb7d34 | 2018-02-23 11:37:51 -0800 | [diff] [blame] | 90 | ExternalFilesHelper.createForTesting( |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 91 | pkgLocator, |
| 92 | ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS, |
| 93 | directories); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 94 | |
| 95 | Map<SkyFunctionName, SkyFunction> skyFunctions = new HashMap<>(); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 96 | skyFunctions.put(SkyFunctions.CONTAINING_PACKAGE_LOOKUP, new ContainingPackageLookupFunction()); |
| 97 | |
John Cater | 5e9ce94 | 2016-10-12 17:23:30 +0000 | [diff] [blame] | 98 | skyFunctions.put( |
| 99 | SkyFunctions.PACKAGE_LOOKUP, |
John Cater | 0c0735a | 2016-11-11 01:52:02 +0000 | [diff] [blame] | 100 | new PackageLookupFunction( |
| 101 | deletedPackages, |
| 102 | CrossRepositoryLabelViolationStrategy.ERROR, |
John Cater | e0d1d0e | 2017-11-28 20:47:41 -0800 | [diff] [blame] | 103 | BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY)); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 104 | skyFunctions.put( |
| 105 | SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null)); |
Eric Fellheimer | 7ef96d7 | 2015-11-12 02:28:44 +0000 | [diff] [blame] | 106 | skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, |
nharmata | e4eb23f | 2017-12-05 09:27:45 -0800 | [diff] [blame] | 107 | new BlacklistedPackagePrefixesFunction( |
| 108 | /*hardcodedBlacklistedPackagePrefixes=*/ ImmutableSet.of(), |
| 109 | /*additionalBlacklistedPackagePrefixesFile=*/ PathFragment.EMPTY_FRAGMENT)); |
Ulf Adams | c73051c6 | 2016-03-23 09:18:13 +0000 | [diff] [blame] | 110 | skyFunctions.put(SkyFunctions.FILE_STATE, new FileStateFunction( |
| 111 | new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper)); |
Kristina Chodorow | f9fdc8d | 2015-12-08 12:49:31 +0000 | [diff] [blame] | 112 | skyFunctions.put(SkyFunctions.FILE, new FileFunction(pkgLocator)); |
John Cater | b4f461e | 2016-10-25 16:16:35 +0000 | [diff] [blame] | 113 | skyFunctions.put(SkyFunctions.DIRECTORY_LISTING, new DirectoryListingFunction()); |
| 114 | skyFunctions.put( |
| 115 | SkyFunctions.DIRECTORY_LISTING_STATE, |
| 116 | new DirectoryListingStateFunction(externalFilesHelper)); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 117 | RuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider(); |
| 118 | skyFunctions.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider)); |
| 119 | skyFunctions.put( |
| 120 | SkyFunctions.WORKSPACE_FILE, |
| 121 | new WorkspaceFileFunction( |
| 122 | ruleClassProvider, |
| 123 | analysisMock |
janakr | 52d05e8 | 2017-09-22 13:27:14 -0400 | [diff] [blame] | 124 | .getPackageFactoryBuilderForTesting(directories) |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 125 | .setEnvironmentExtensions( |
| 126 | ImmutableList.<EnvironmentExtension>of( |
| 127 | new PackageFactory.EmptyEnvironmentExtension())) |
nharmata | e57e9a3 | 2018-04-02 15:10:24 -0700 | [diff] [blame] | 128 | .build(ruleClassProvider), |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 129 | directories)); |
| 130 | skyFunctions.put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction()); |
John Cater | b4f461e | 2016-10-25 16:16:35 +0000 | [diff] [blame] | 131 | skyFunctions.put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction()); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 132 | skyFunctions.put( |
| 133 | SkyFunctions.FILE_SYMLINK_CYCLE_UNIQUENESS, new FileSymlinkCycleUniquenessFunction()); |
| 134 | ImmutableMap<String, RepositoryFunction> repositoryHandlers = |
| 135 | ImmutableMap.of( |
| 136 | LocalRepositoryRule.NAME, (RepositoryFunction) new LocalRepositoryFunction()); |
| 137 | skyFunctions.put( |
| 138 | SkyFunctions.REPOSITORY_DIRECTORY, |
janakr | ca6b46d | 2017-09-22 14:07:15 -0400 | [diff] [blame] | 139 | new RepositoryDelegatorFunction( |
| 140 | repositoryHandlers, null, new AtomicBoolean(true), ImmutableMap::of, directories)); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 141 | skyFunctions.put(SkyFunctions.REPOSITORY, new RepositoryLoaderFunction()); |
| 142 | |
janakr | 1cde872 | 2017-10-10 03:22:21 +0200 | [diff] [blame] | 143 | differencer = new SequencedRecordingDifferencer(); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 144 | evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer); |
| 145 | driver = new SequentialBuildDriver(evaluator); |
| 146 | PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID()); |
brandjon | dbff8b8 | 2017-10-23 19:02:31 +0200 | [diff] [blame] | 147 | PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get()); |
| 148 | PrecomputedValue.SKYLARK_SEMANTICS.set(differencer, SkylarkSemantics.DEFAULT_SEMANTICS); |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 149 | RepositoryDelegatorFunction.REPOSITORY_OVERRIDES.set( |
| 150 | differencer, ImmutableMap.<RepositoryName, PathFragment>of()); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | private ContainingPackageLookupValue lookupContainingPackage(String packageName) |
| 154 | throws InterruptedException { |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 155 | return lookupContainingPackage(PackageIdentifier.createInMainRepo(packageName)); |
| 156 | } |
| 157 | |
| 158 | private ContainingPackageLookupValue lookupContainingPackage(PackageIdentifier packageIdentifier) |
| 159 | throws InterruptedException { |
| 160 | SkyKey key = ContainingPackageLookupValue.key(packageIdentifier); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 161 | return driver |
| 162 | .<ContainingPackageLookupValue>evaluate( |
| 163 | ImmutableList.of(key), |
| 164 | false, |
| 165 | SkyframeExecutor.DEFAULT_THREAD_COUNT, |
| 166 | NullEventHandler.INSTANCE) |
| 167 | .get(key); |
| 168 | } |
| 169 | |
Florian Weikert | 92b2236 | 2015-12-03 10:17:18 +0000 | [diff] [blame] | 170 | @Test |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 171 | public void testNoContainingPackage() throws Exception { |
| 172 | ContainingPackageLookupValue value = lookupContainingPackage("a/b"); |
lberki | aea56b3 | 2017-05-30 12:35:33 +0200 | [diff] [blame] | 173 | assertThat(value.hasContainingPackage()).isFalse(); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Florian Weikert | 92b2236 | 2015-12-03 10:17:18 +0000 | [diff] [blame] | 176 | @Test |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 177 | public void testContainingPackageIsParent() throws Exception { |
| 178 | scratch.file("a/BUILD"); |
| 179 | ContainingPackageLookupValue value = lookupContainingPackage("a/b"); |
lberki | aea56b3 | 2017-05-30 12:35:33 +0200 | [diff] [blame] | 180 | assertThat(value.hasContainingPackage()).isTrue(); |
| 181 | assertThat(value.getContainingPackageName()).isEqualTo(PackageIdentifier.createInMainRepo("a")); |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 182 | assertThat(value.getContainingPackageRoot()).isEqualTo(Root.fromPath(rootDirectory)); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Florian Weikert | 92b2236 | 2015-12-03 10:17:18 +0000 | [diff] [blame] | 185 | @Test |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 186 | public void testContainingPackageIsSelf() throws Exception { |
| 187 | scratch.file("a/b/BUILD"); |
| 188 | ContainingPackageLookupValue value = lookupContainingPackage("a/b"); |
lberki | aea56b3 | 2017-05-30 12:35:33 +0200 | [diff] [blame] | 189 | assertThat(value.hasContainingPackage()).isTrue(); |
| 190 | assertThat(value.getContainingPackageName()) |
| 191 | .isEqualTo(PackageIdentifier.createInMainRepo("a/b")); |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 192 | assertThat(value.getContainingPackageRoot()).isEqualTo(Root.fromPath(rootDirectory)); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 193 | } |
| 194 | |
Florian Weikert | 92b2236 | 2015-12-03 10:17:18 +0000 | [diff] [blame] | 195 | @Test |
John Cater | 4593296 | 2017-09-06 21:57:46 +0200 | [diff] [blame] | 196 | public void testContainingPackageIsExternalRepositoryViaExternalRepository() throws Exception { |
| 197 | scratch.overwriteFile( |
| 198 | "WORKSPACE", |
| 199 | "local_repository(name='a', path='a')"); |
| 200 | scratch.file("a/WORKSPACE"); |
| 201 | scratch.file("a/BUILD"); |
| 202 | scratch.file("a/b/BUILD"); |
| 203 | ContainingPackageLookupValue value = |
| 204 | lookupContainingPackage( |
| 205 | PackageIdentifier.create(RepositoryName.create("@a"), PathFragment.create("b"))); |
| 206 | assertThat(value.hasContainingPackage()).isTrue(); |
| 207 | assertThat(value.getContainingPackageName()) |
| 208 | .isEqualTo(PackageIdentifier.create(RepositoryName.create("@a"), PathFragment.create("b"))); |
| 209 | } |
| 210 | |
| 211 | @Test |
| 212 | public void testContainingPackageIsExternalRepositoryViaLocalPath() throws Exception { |
| 213 | scratch.overwriteFile( |
| 214 | "WORKSPACE", |
| 215 | "local_repository(name='a', path='a')"); |
| 216 | scratch.file("a/WORKSPACE"); |
| 217 | scratch.file("a/BUILD"); |
| 218 | scratch.file("a/b/BUILD"); |
| 219 | ContainingPackageLookupValue value = lookupContainingPackage("a/b"); |
| 220 | assertThat(value.hasContainingPackage()).isTrue(); |
| 221 | assertThat(value.getContainingPackageName()) |
| 222 | .isEqualTo(PackageIdentifier.create(RepositoryName.create("@a"), PathFragment.create("b"))); |
| 223 | } |
| 224 | |
| 225 | @Test |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 226 | public void testEqualsAndHashCodeContract() throws Exception { |
| 227 | ContainingPackageLookupValue valueA1 = ContainingPackageLookupValue.NONE; |
| 228 | ContainingPackageLookupValue valueA2 = ContainingPackageLookupValue.NONE; |
| 229 | ContainingPackageLookupValue valueB1 = |
| 230 | ContainingPackageLookupValue.withContainingPackage( |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 231 | PackageIdentifier.createInMainRepo("b"), Root.fromPath(rootDirectory)); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 232 | ContainingPackageLookupValue valueB2 = |
| 233 | ContainingPackageLookupValue.withContainingPackage( |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 234 | PackageIdentifier.createInMainRepo("b"), Root.fromPath(rootDirectory)); |
Brian Silverman | d7d6d62 | 2016-03-17 09:53:39 +0000 | [diff] [blame] | 235 | PackageIdentifier cFrag = PackageIdentifier.createInMainRepo("c"); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 236 | ContainingPackageLookupValue valueC1 = |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 237 | ContainingPackageLookupValue.withContainingPackage(cFrag, Root.fromPath(rootDirectory)); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 238 | ContainingPackageLookupValue valueC2 = |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 239 | ContainingPackageLookupValue.withContainingPackage(cFrag, Root.fromPath(rootDirectory)); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 240 | ContainingPackageLookupValue valueCOther = |
| 241 | ContainingPackageLookupValue.withContainingPackage( |
tomlu | ee6a686 | 2018-01-17 14:36:26 -0800 | [diff] [blame] | 242 | cFrag, Root.fromPath(rootDirectory.getRelative("other_root"))); |
Han-Wen Nienhuys | 81b9083 | 2015-10-26 16:57:27 +0000 | [diff] [blame] | 243 | new EqualsTester() |
| 244 | .addEqualityGroup(valueA1, valueA2) |
| 245 | .addEqualityGroup(valueB1, valueB2) |
| 246 | .addEqualityGroup(valueC1, valueC2) |
| 247 | .addEqualityGroup(valueCOther) |
| 248 | .testEquals(); |
| 249 | } |
| 250 | } |