aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar nharmata <nharmata@google.com>2017-04-04 17:11:39 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-04-05 15:18:20 +0200
commitb4060b6e53944a7c3bdc5e62b288e7293a87652a (patch)
tree59b0f1f3d3e8e99412e060bb98b5a37fe90d9b6e /src/test/java/com/google/devtools/build/lib/rules
parent3ac77cb94a4cf1bd1993a97fe79f2005b2b1a711 (diff)
Refactor all ctor callsites of PathFragment to instead call a static 'create' method.
This paves the way for changing PathFragment to e.g. an abstract class with multiple subclasses. This way we can split out the windows-specific stuff into one of these concrete classes, making the code more readable and also saving memory (since the shallow heap size of the NonWindowsPathFragment subclass will hopefully be smaller than that of the current PathFragment). This also lets us pursue gc churn optimizations. We can now do interning in PathFragment#create and can also get rid of unnecessary intermediate PathFragment allocations. RELNOTES: None PiperOrigin-RevId: 152145768
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java28
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java18
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java36
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java23
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/LTOBackendActionTest.java4
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/java/JavaUtilTest.java19
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java2
10 files changed, 76 insertions, 72 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java
index e0789e24d1..7e874d4b8a 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidLibraryTest.java
@@ -1142,21 +1142,21 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
ImmutableList.of(
SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("java/android/assets")),
+ PathFragment.create("java/android/assets")),
SourceDirectory.fromRoot(
targetConfig.getGenfilesDirectory(RepositoryName.MAIN),
- new PathFragment("java/android/assets"))),
+ PathFragment.create("java/android/assets"))),
provider.getAssetDirs());
assertEquals(
ImmutableList.of(
SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("java/android/res"))),
+ PathFragment.create("java/android/res"))),
provider.getResourceDirs());
assertEquals(ImmutableList.of(SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("java/android")
+ PathFragment.create("java/android")
)), provider.getIdlImports());
Set<Artifact> artifactClosure = actionsTestUtil().artifactClosureOf(getFilesToBuild(target));
@@ -1193,11 +1193,13 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
ImmutableList.of(
SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("research/handwriting/java/com/google/research/handwriting/assets")
+ PathFragment.create(
+ "research/handwriting/java/com/google/research/handwriting/assets")
),
SourceDirectory.fromRoot(
targetConfig.getGenfilesDirectory(RepositoryName.MAIN),
- new PathFragment("research/handwriting/java/com/google/research/handwriting/assets")
+ PathFragment.create(
+ "research/handwriting/java/com/google/research/handwriting/assets")
)
),
provider.getAssetDirs());
@@ -1205,14 +1207,14 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
ImmutableList.of(
SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("research/handwriting/java/com/google/research/handwriting/res")
+ PathFragment.create("research/handwriting/java/com/google/research/handwriting/res")
)
),
provider.getResourceDirs());
assertEquals(ImmutableList.of(SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("research/handwriting/java/com/google/research/handwriting")
+ PathFragment.create("research/handwriting/java/com/google/research/handwriting")
)), provider.getIdlImports());
Set<Artifact> artifactClosure = actionsTestUtil().artifactClosureOf(getFilesToBuild(target));
@@ -1252,17 +1254,17 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
ImmutableList.of(
SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("java/android/assets")),
+ PathFragment.create("java/android/assets")),
SourceDirectory.fromRoot(
targetConfig.getGenfilesDirectory(RepositoryName.MAIN),
- new PathFragment("java/android/assets"))
+ PathFragment.create("java/android/assets"))
),
provider.getAssetDirs());
assertEquals(
ImmutableList.of(
SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("java/android/res"))
+ PathFragment.create("java/android/res"))
),
provider.getResourceDirs());
@@ -1270,10 +1272,10 @@ public class AndroidLibraryTest extends AndroidBuildViewTestCase {
ImmutableList.of(
SourceDirectory.fromSourceRoot(
rootDirectory.asFragment(),
- new PathFragment("java/android")),
+ PathFragment.create("java/android")),
SourceDirectory.fromRoot(
targetConfig.getGenfilesDirectory(RepositoryName.MAIN),
- new PathFragment("java/android"))
+ PathFragment.create("java/android"))
),
provider.getIdlImports());
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
index e0fc844f63..4f5b63e26e 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
@@ -410,7 +410,7 @@ public class CcCommonTest extends BuildViewTestCase {
String includesRoot = "bang/bang_includes";
assertThat(foo.getProvider(CppCompilationContext.class).getSystemIncludeDirs())
.containsAllOf(
- new PathFragment(includesRoot),
+ PathFragment.create(includesRoot),
targetConfig.getGenfilesFragment().getRelative(includesRoot));
}
@@ -436,7 +436,7 @@ public class CcCommonTest extends BuildViewTestCase {
List<PathFragment> expected =
new ImmutableList.Builder<PathFragment>()
.addAll(noIncludes.getProvider(CppCompilationContext.class).getSystemIncludeDirs())
- .add(new PathFragment(includesRoot))
+ .add(PathFragment.create(includesRoot))
.add(targetConfig.getGenfilesFragment().getRelative(includesRoot))
.build();
assertThat(foo.getProvider(CppCompilationContext.class).getSystemIncludeDirs())
@@ -548,7 +548,7 @@ public class CcCommonTest extends BuildViewTestCase {
getSkyframeExecutor()
.invalidateFilesUnderPathForTesting(
reporter,
- new ModifiedFileSet.Builder().modify(new PathFragment("WORKSPACE")).build(),
+ new ModifiedFileSet.Builder().modify(PathFragment.create("WORKSPACE")).build(),
rootDirectory);
FileSystemUtils.createDirectoryAndParents(scratch.resolve("/foo/bar"));
scratch.file("/foo/WORKSPACE", "workspace(name = 'pkg')");
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
index b80e00ea2f..b87410c97c 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java
@@ -58,8 +58,8 @@ import org.junit.runners.JUnit4;
*/
@RunWith(JUnit4.class)
public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
- private static final PathFragment STL_CPPMAP = new PathFragment("stl.cppmap");
- private static final PathFragment CROSSTOOL_CPPMAP = new PathFragment("crosstool.cppmap");
+ private static final PathFragment STL_CPPMAP = PathFragment.create("stl.cppmap");
+ private static final PathFragment CROSSTOOL_CPPMAP = PathFragment.create("crosstool.cppmap");
@Before
public final void createFiles() throws Exception {
@@ -501,7 +501,7 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase {
List<String> names = new ArrayList<>();
for (String flag : input) {
if (CppFileTypes.CPP_MODULE.matches(flag)) {
- names.add(new PathFragment(flag).getBaseName());
+ names.add(PathFragment.create(flag).getBaseName());
}
}
return names;
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java
index 72494019fd..71020d95de 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java
@@ -1209,7 +1209,7 @@ public class CcToolchainFeaturesTest {
" implies: 'action-a'",
"}")
.getFeatureConfiguration("activates-action-a");
- PathFragment crosstoolPath = new PathFragment("crosstool/");
+ PathFragment crosstoolPath = PathFragment.create("crosstool/");
PathFragment toolPath = configuration.getToolForAction("action-a").getToolPath(crosstoolPath);
assertThat(toolPath.toString()).isEqualTo("crosstool/toolchain/a");
}
@@ -1251,7 +1251,7 @@ public class CcToolchainFeaturesTest {
" implies: 'action-a'",
"}");
- PathFragment crosstoolPath = new PathFragment("crosstool/");
+ PathFragment crosstoolPath = PathFragment.create("crosstool/");
FeatureConfiguration featureAConfiguration =
toolchainFeatures.getFeatureConfiguration("feature-a", "activates-action-a");
@@ -1310,7 +1310,7 @@ public class CcToolchainFeaturesTest {
" implies: 'action-a'",
"}");
- PathFragment crosstoolPath = new PathFragment("crosstool/");
+ PathFragment crosstoolPath = PathFragment.create("crosstool/");
FeatureConfiguration noFeaturesConfiguration =
toolchainFeatures.getFeatureConfiguration("activates-action-a");
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
index 2889e324a8..1b38da18d5 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java
@@ -254,8 +254,8 @@ public class CppLinkActionTest extends BuildViewTestCase {
@Test
public void testComputeKeyNonStatic() throws Exception {
final RuleContext ruleContext = createDummyRuleContext();
- final PathFragment exeOutputPath = new PathFragment("dummyRuleContext/output/path");
- final PathFragment dynamicOutputPath = new PathFragment("dummyRuleContext/output/path.so");
+ final PathFragment exeOutputPath = PathFragment.create("dummyRuleContext/output/path");
+ final PathFragment dynamicOutputPath = PathFragment.create("dummyRuleContext/output/path.so");
final Artifact staticOutputFile = getBinArtifactWithNoOwner(exeOutputPath.getPathString());
final Artifact dynamicOutputFile = getBinArtifactWithNoOwner(dynamicOutputPath.getPathString());
final Artifact oFile = getSourceArtifact("cc/a.o");
@@ -286,7 +286,7 @@ public class CppLinkActionTest extends BuildViewTestCase {
builder.setNativeDeps((i & 4) == 0);
builder.setUseTestOnlyFlags((i & 8) == 0);
builder.setFake((i & 16) == 0);
- builder.setRuntimeSolibDir((i & 32) == 0 ? null : new PathFragment("so1"));
+ builder.setRuntimeSolibDir((i & 32) == 0 ? null : PathFragment.create("so1"));
builder.setFeatureConfiguration(featureConfiguration);
return builder.build();
@@ -301,8 +301,8 @@ public class CppLinkActionTest extends BuildViewTestCase {
@Test
public void testComputeKeyStatic() throws Exception {
final RuleContext ruleContext = createDummyRuleContext();
- final PathFragment staticOutputPath = new PathFragment("dummyRuleContext/output/path.a");
- final PathFragment dynamicOutputPath = new PathFragment("dummyRuleContext/output/path.so");
+ final PathFragment staticOutputPath = PathFragment.create("dummyRuleContext/output/path.a");
+ final PathFragment dynamicOutputPath = PathFragment.create("dummyRuleContext/output/path.so");
final Artifact staticOutputFile = getBinArtifactWithNoOwner(staticOutputPath.getPathString());
final Artifact dynamicOutputFile = getBinArtifactWithNoOwner(dynamicOutputPath.getPathString());
final Artifact oFile = getSourceArtifact("cc/a.o");
@@ -336,11 +336,11 @@ public class CppLinkActionTest extends BuildViewTestCase {
public void testCommandLineSplitting() throws Exception {
RuleContext ruleContext = createDummyRuleContext();
Artifact output = getDerivedArtifact(
- new PathFragment("output/path.xyz"), getTargetConfiguration().getBinDirectory(
+ PathFragment.create("output/path.xyz"), getTargetConfiguration().getBinDirectory(
RepositoryName.MAIN),
ActionsTestUtil.NULL_ARTIFACT_OWNER);
final Artifact outputIfso = getDerivedArtifact(
- new PathFragment("output/path.ifso"), getTargetConfiguration().getBinDirectory(
+ PathFragment.create("output/path.ifso"), getTargetConfiguration().getBinDirectory(
RepositoryName.MAIN),
ActionsTestUtil.NULL_ARTIFACT_OWNER);
CppLinkActionBuilder builder =
@@ -432,7 +432,7 @@ public class CppLinkActionTest extends BuildViewTestCase {
new CppLinkActionBuilder(
ruleContext,
new Artifact(
- new PathFragment(outputPath),
+ PathFragment.create(outputPath),
getTargetConfiguration()
.getBinDirectory(ruleContext.getRule().getRepository())),
ruleContext.getConfiguration(),
@@ -451,7 +451,7 @@ public class CppLinkActionTest extends BuildViewTestCase {
}
private CppLinkActionBuilder createLinkBuilder(Link.LinkTargetType type) throws Exception {
- PathFragment output = new PathFragment("dummyRuleContext/output/path.a");
+ PathFragment output = PathFragment.create("dummyRuleContext/output/path.a");
return createLinkBuilder(
type,
output.getPathString(),
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
index f6ec5bca7e..07ba4ff058 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CreateIncSymlinkActionTest.java
@@ -43,17 +43,17 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
@Test
public void testDifferentOrderSameActionKey() throws Exception {
Root root = Root.asDerivedRoot(rootDirectory, rootDirectory.getRelative("out"));
- Artifact a = new Artifact(new PathFragment("a"), root);
- Artifact b = new Artifact(new PathFragment("b"), root);
- Artifact c = new Artifact(new PathFragment("c"), root);
- Artifact d = new Artifact(new PathFragment("d"), root);
+ Artifact a = new Artifact(PathFragment.create("a"), root);
+ Artifact b = new Artifact(PathFragment.create("b"), root);
+ Artifact c = new Artifact(PathFragment.create("c"), root);
+ Artifact d = new Artifact(PathFragment.create("d"), root);
CreateIncSymlinkAction action1 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(a, b, c, d), root.getPath());
// Can't reuse the artifacts here; that would lead to DuplicateArtifactException.
- a = new Artifact(new PathFragment("a"), root);
- b = new Artifact(new PathFragment("b"), root);
- c = new Artifact(new PathFragment("c"), root);
- d = new Artifact(new PathFragment("d"), root);
+ a = new Artifact(PathFragment.create("a"), root);
+ b = new Artifact(PathFragment.create("b"), root);
+ c = new Artifact(PathFragment.create("c"), root);
+ d = new Artifact(PathFragment.create("d"), root);
CreateIncSymlinkAction action2 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(c, d, a, b), root.getPath());
assertEquals(action1.computeKey(), action2.computeKey());
@@ -62,13 +62,13 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
@Test
public void testDifferentTargetsDifferentActionKey() throws Exception {
Root root = Root.asDerivedRoot(rootDirectory, rootDirectory.getRelative("out"));
- Artifact a = new Artifact(new PathFragment("a"), root);
- Artifact b = new Artifact(new PathFragment("b"), root);
+ Artifact a = new Artifact(PathFragment.create("a"), root);
+ Artifact b = new Artifact(PathFragment.create("b"), root);
CreateIncSymlinkAction action1 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(a, b), root.getPath());
// Can't reuse the artifacts here; that would lead to DuplicateArtifactException.
- a = new Artifact(new PathFragment("a"), root);
- b = new Artifact(new PathFragment("c"), root);
+ a = new Artifact(PathFragment.create("a"), root);
+ b = new Artifact(PathFragment.create("c"), root);
CreateIncSymlinkAction action2 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(a, b), root.getPath());
assertThat(action2.computeKey()).isNotEqualTo(action1.computeKey());
@@ -77,13 +77,13 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
@Test
public void testDifferentSymlinksDifferentActionKey() throws Exception {
Root root = Root.asDerivedRoot(rootDirectory, rootDirectory.getRelative("out"));
- Artifact a = new Artifact(new PathFragment("a"), root);
- Artifact b = new Artifact(new PathFragment("b"), root);
+ Artifact a = new Artifact(PathFragment.create("a"), root);
+ Artifact b = new Artifact(PathFragment.create("b"), root);
CreateIncSymlinkAction action1 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(a, b), root.getPath());
// Can't reuse the artifacts here; that would lead to DuplicateArtifactException.
- a = new Artifact(new PathFragment("c"), root);
- b = new Artifact(new PathFragment("b"), root);
+ a = new Artifact(PathFragment.create("c"), root);
+ b = new Artifact(PathFragment.create("b"), root);
CreateIncSymlinkAction action2 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(a, b), root.getPath());
assertThat(action2.computeKey()).isNotEqualTo(action1.computeKey());
@@ -96,7 +96,7 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
Root root = Root.asDerivedRoot(rootDirectory, outputDir);
Path symlink = rootDirectory.getRelative("out/a");
Artifact a = new Artifact(symlink, root);
- Artifact b = new Artifact(new PathFragment("b"), root);
+ Artifact b = new Artifact(PathFragment.create("b"), root);
CreateIncSymlinkAction action = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
ImmutableMap.of(a, b), outputDir);
action.execute(null);
@@ -113,7 +113,7 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
Root root = Root.asDerivedRoot(rootDirectory, outputDir);
Path symlink = rootDirectory.getRelative("out/subdir/a");
Artifact a = new Artifact(symlink, root);
- Artifact b = new Artifact(new PathFragment("b"), root);
+ Artifact b = new Artifact(PathFragment.create("b"), root);
CreateIncSymlinkAction action =
new CreateIncSymlinkAction(NULL_ACTION_OWNER, ImmutableMap.of(a, b), outputDir);
Path extra = rootDirectory.getRelative("out/extra");
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
index 1fd7a011ad..30b5af1d95 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java
@@ -540,7 +540,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
CompilationMode.FASTBUILD,
LipoMode.OFF,
LinkingMode.FULLY_STATIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertEquals(
Arrays.asList(
"linker-flag-A-1",
@@ -551,7 +551,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
CompilationMode.DBG,
LipoMode.OFF,
LinkingMode.DYNAMIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertEquals(
Arrays.asList(
"linker-flag-A-1",
@@ -562,7 +562,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
CompilationMode.OPT,
LipoMode.OFF,
LinkingMode.FULLY_STATIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertEquals(
Arrays.asList(
@@ -574,7 +574,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
CompilationMode.OPT,
LipoMode.BINARY,
LinkingMode.FULLY_STATIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertEquals(
Arrays.asList("objcopy-embed-flag-A-1", "objcopy-embed-flag-A-2"),
@@ -597,7 +597,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
Arrays.asList(
getToolPath("/system-include-dir-A-1"), getToolPath("/system-include-dir-A-2")),
toolchainA.getBuiltInIncludeDirectories());
- assertEquals(new PathFragment("some"), toolchainA.getSysroot());
+ assertEquals(PathFragment.create("some"), toolchainA.getSysroot());
// Cursory testing of the "B" toolchain only; assume that if none of
// toolchain B bled through into toolchain A, the reverse also didn't occur. And
@@ -636,21 +636,21 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
CompilationMode.FASTBUILD,
LipoMode.OFF,
LinkingMode.FULLY_STATIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertEquals(
Collections.EMPTY_LIST,
toolchainC.configureLinkerOptions(
CompilationMode.DBG,
LipoMode.OFF,
LinkingMode.DYNAMIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertEquals(
Collections.EMPTY_LIST,
toolchainC.configureLinkerOptions(
CompilationMode.OPT,
LipoMode.OFF,
LinkingMode.FULLY_STATIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertThat(toolchainC.getObjCopyOptionsForEmbedding()).isEmpty();
assertThat(toolchainC.getLdOptionsForEmbedding()).isEmpty();
@@ -669,8 +669,9 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
PackageIdentifier packageIdentifier =
PackageIdentifier.create(
TestConstants.TOOLS_REPOSITORY,
- new PathFragment(
- new PathFragment(TestConstants.TOOLS_REPOSITORY_PATH), new PathFragment(path)));
+ PathFragment.create(
+ PathFragment.create(TestConstants.TOOLS_REPOSITORY_PATH),
+ PathFragment.create(path)));
return packageIdentifier.getPathUnderExecRoot();
}
@@ -690,7 +691,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase {
CompilationMode.DBG,
lipoMode,
LinkingMode.DYNAMIC,
- new PathFragment("hello-world/ld")));
+ PathFragment.create("hello-world/ld")));
assertEquals(
ImmutableList.<String>of(
"compiler-flag-B-1",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LTOBackendActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LTOBackendActionTest.java
index eb196ec627..70284d8003 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LTOBackendActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LTOBackendActionTest.java
@@ -163,10 +163,10 @@ public class LTOBackendActionTest extends BuildViewTestCase {
if ((i & 8) == 0) {
builder.addRunfilesSupplier(
- new RunfilesSupplierImpl(new PathFragment("a"), Runfiles.EMPTY, artifactA));
+ new RunfilesSupplierImpl(PathFragment.create("a"), Runfiles.EMPTY, artifactA));
} else {
builder.addRunfilesSupplier(
- new RunfilesSupplierImpl(new PathFragment("a"), Runfiles.EMPTY, artifactB));
+ new RunfilesSupplierImpl(PathFragment.create("a"), Runfiles.EMPTY, artifactB));
}
if ((i & 16) == 0) {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaUtilTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaUtilTest.java
index df3b4d5ca7..7992575483 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaUtilTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaUtilTest.java
@@ -29,13 +29,14 @@ import org.junit.runners.JUnit4;
public class JavaUtilTest {
private String getRootPath(String path) {
- return JavaUtil.getJavaRoot(new PathFragment(path)).getPathString();
+ return JavaUtil.getJavaRoot(PathFragment.create(path)).getPathString();
}
@Test
public void testGetJavaRoot() {
assertThat(
- JavaUtil.getJavaRoot(new PathFragment("path/without/Java/or/Javatests/or/Src/lowercase")))
+ JavaUtil.getJavaRoot(
+ PathFragment.create("path/without/Java/or/Javatests/or/Src/lowercase")))
.isNull();
assertThat(getRootPath("java/com/google/common/case")).isEqualTo("java");
assertThat(getRootPath("javatests/com/google/common/case")).isEqualTo("javatests");
@@ -103,26 +104,26 @@ public class JavaUtilTest {
@Test
public void testGetJavaPackageName() {
- assertThat(JavaUtil.getJavaPackageName(new PathFragment("java/com/google/foo/FooModule.java")))
- .isEqualTo("com.google.foo");
- assertThat(JavaUtil.getJavaPackageName(new PathFragment("org/foo/FooUtil.java")))
+ assertThat(JavaUtil.getJavaPackageName(
+ PathFragment.create("java/com/google/foo/FooModule.java"))).isEqualTo("com.google.foo");
+ assertThat(JavaUtil.getJavaPackageName(PathFragment.create("org/foo/FooUtil.java")))
.isEqualTo("org.foo");
}
@Test
public void testGetJavaFullClassname() {
assertThat(
- JavaUtil.getJavaFullClassname(new PathFragment("java/com/google/foo/FooModule.java")))
+ JavaUtil.getJavaFullClassname(PathFragment.create("java/com/google/foo/FooModule.java")))
.isEqualTo("com.google.foo.FooModule.java");
- assertThat(JavaUtil.getJavaFullClassname(new PathFragment("org/foo/FooUtil.java"))).isNull();
+ assertThat(JavaUtil.getJavaFullClassname(PathFragment.create("org/foo/FooUtil.java"))).isNull();
}
@Test
public void testGetJavaPath() {
assertThat(
JavaUtil.getJavaPath(
- new PathFragment("java/com/google/foo/FooModule.java")).getPathString())
+ PathFragment.create("java/com/google/foo/FooModule.java")).getPathString())
.isEqualTo("com/google/foo/FooModule.java");
- assertThat(JavaUtil.getJavaPath(new PathFragment("org/foo/FooUtil.java"))).isNull();
+ assertThat(JavaUtil.getJavaPath(PathFragment.create("org/foo/FooUtil.java"))).isNull();
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java
index 629a418e2c..c9e1afacc0 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java
@@ -79,7 +79,7 @@ public class RepositoryFunctionTest extends BuildViewTestCase {
" name = 'w',",
" path = '/a/b/c',",
")");
- assertEquals(new PathFragment("/a/b/c"),
+ assertEquals(PathFragment.create("/a/b/c"),
TestingRepositoryFunction.getTargetPath(rule, rootDirectory));
}