forked from facebook/buck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Buck invocations with isolated daemon/cache/outputs
Summary: This diff proposes some changes to allow Buck to run in an "isolated" mode - where outputs, intermediate files etc. are not written to the usual `buck-out` directory. Instead, they are written to a directory whose name is a user-supplied prefix plus `-buck-out` that sits next to where the traditional `buck-out` would go (i.e. at the repository root). The change also means a separate `buckd` will be launched that is tied to this isolated output directory. The motivation for the change is to support Nuclide Language Services (and potentially other clients too) that want to use Buck to harvest information about the source tree and build process, but do not want to conflict with user-initiated build/test commands. A key principle I've tried to follow with the change is to not interfere with "normal" Buck usage in any way. So this diff should leave all existing Buck invocations and usage unaffected. Reviewed By: bobyangyf shipit-source-id: b68b8f211f
- Loading branch information
1 parent
117a350
commit c85b760
Showing
8 changed files
with
216 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
test/com/facebook/buck/cli/endtoend/BaseDirEndToEndTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright 2018-present Facebook, Inc. | ||
* | ||
* 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 com.facebook.buck.cli.endtoend; | ||
|
||
import com.facebook.buck.testutil.ProcessResult; | ||
import com.facebook.buck.testutil.endtoend.EndToEndEnvironment; | ||
import com.facebook.buck.testutil.endtoend.EndToEndRunner; | ||
import com.facebook.buck.testutil.endtoend.EndToEndTestDescriptor; | ||
import com.facebook.buck.testutil.endtoend.EndToEndWorkspace; | ||
import com.facebook.buck.testutil.endtoend.Environment; | ||
import com.facebook.buck.testutil.endtoend.EnvironmentFor; | ||
import com.google.common.collect.ImmutableMap; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(EndToEndRunner.class) | ||
public class BaseDirEndToEndTest { | ||
|
||
@Environment | ||
public static EndToEndEnvironment getBaseDirSetEnvironment() { | ||
return new EndToEndEnvironment() | ||
.withCommand("build") | ||
.addLocalConfigSet( | ||
ImmutableMap.of("parser", ImmutableMap.of("default_build_file_syntax", "SKYLARK"))) | ||
.addLocalConfigSet( | ||
ImmutableMap.of("parser", ImmutableMap.of("default_build_file_syntax", "PYTHON_DSL"))); | ||
} | ||
|
||
@EnvironmentFor(testNames = {"usingBaseDirShouldNotTouchBuckOutDir"}) | ||
public static EndToEndEnvironment setSuccessfulTargetPath() { | ||
return getBaseDirSetEnvironment() | ||
.addTemplates("cxx") | ||
.withTargets("simple_successful_helloworld"); | ||
} | ||
|
||
@Test | ||
public void usingBaseDirShouldNotTouchBuckOutDir( | ||
EndToEndTestDescriptor test, EndToEndWorkspace workspace) throws Throwable { | ||
for (String template : test.getTemplateSet()) { | ||
workspace.addPremadeTemplate(template); | ||
} | ||
|
||
ProcessResult result = | ||
workspace.runBuckCommand( | ||
"--isolation_prefix", | ||
"mybase", | ||
"build", | ||
"//simple_successful_helloworld:simple_successful_helloworld"); | ||
result.assertSuccess(); | ||
|
||
Path output = | ||
workspace | ||
.getDestPath() | ||
.resolve( | ||
Paths.get( | ||
"mybase-buck-out", | ||
"gen", | ||
"simple_successful_helloworld", | ||
"simple_successful_helloworld")); | ||
Assert.assertTrue(Files.exists(output)); | ||
|
||
Path usualOutput = | ||
workspace | ||
.getDestPath() | ||
.resolve( | ||
Paths.get( | ||
"buck-out", | ||
"gen", | ||
"simple_successful_helloworld", | ||
"simple_successful_helloworld")); | ||
Assert.assertFalse(Files.exists(usualOutput)); | ||
|
||
workspace.deleteRecursivelyIfExists(output.toString()); | ||
|
||
result = | ||
workspace.runBuckCommand( | ||
"build", "//simple_successful_helloworld:simple_successful_helloworld"); | ||
result.assertSuccess(); | ||
|
||
output = | ||
workspace | ||
.getDestPath() | ||
.resolve( | ||
Paths.get( | ||
"mybase-buck-out", | ||
"gen", | ||
"simple_successful_helloworld", | ||
"simple_successful_helloworld")); | ||
Assert.assertFalse(Files.exists(output)); | ||
|
||
usualOutput = | ||
workspace | ||
.getDestPath() | ||
.resolve( | ||
Paths.get( | ||
"buck-out", | ||
"gen", | ||
"simple_successful_helloworld", | ||
"simple_successful_helloworld")); | ||
Assert.assertTrue(Files.exists(usualOutput)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters