Search in sources :

Example 46 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class KnownBuildRuleTypesTest method createInstanceShouldReturnDifferentInstancesIfCalledWithDifferentParameters.

@Test
public void createInstanceShouldReturnDifferentInstancesIfCalledWithDifferentParameters() throws Exception {
    ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
    KnownBuildRuleTypes knownBuildRuleTypes1 = KnownBuildRuleTypes.createInstance(FakeBuckConfig.builder().build(), filesystem, createExecutor(), new FakeAndroidDirectoryResolver());
    final Path javac = temporaryFolder.newExecutableFile();
    ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("tools", ImmutableMap.of("javac", javac.toString()));
    BuckConfig buckConfig = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(sections).build();
    ProcessExecutor processExecutor = createExecutor(javac.toString(), "");
    KnownBuildRuleTypes knownBuildRuleTypes2 = KnownBuildRuleTypes.createInstance(buckConfig, filesystem, processExecutor, new FakeAndroidDirectoryResolver());
    assertNotEquals(knownBuildRuleTypes1, knownBuildRuleTypes2);
}
Also used : Path(java.nio.file.Path) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 47 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class KnownBuildRuleTypesTestUtil method getDefaultKnownBuildRuleTypes.

public static KnownBuildRuleTypes getDefaultKnownBuildRuleTypes(ProjectFilesystem filesystem, ImmutableMap<String, String> environment) throws InterruptedException, IOException {
    BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).build();
    List<String> paths = getPaths(environment);
    return KnownBuildRuleTypes.createInstance(config, filesystem, new FakeProcessExecutor(ImmutableMap.<ProcessExecutorParams, FakeProcess>builder().put(XCODE_SELECT_PARAMS, XCODE_SELECT_PROCESS).putAll(getPythonProcessMap(paths)).build()), new FakeAndroidDirectoryResolver());
}
Also used : FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor)

Example 48 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class RageConfigTest method testUploadConfigs.

@Test
public void testUploadConfigs() {
    String testPath = "rage/upload/test";
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("rage", ImmutableMap.of("report_upload_path", testPath, "slb_server_pool", "http://buck-frontend-dual.05.atn1.facebook.com"))).build();
    RageConfig config = RageConfig.of(buckConfig);
    assertThat(config.getReportUploadPath(), Matchers.equalTo(testPath));
    assertThat(config.getFrontendConfig().get().tryCreatingClientSideSlb(clock, eventBus, threadFactory), Matchers.not(Matchers.equalTo(Optional.empty())));
}
Also used : FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Test(org.junit.Test)

Example 49 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class TestCellBuilder method build.

public Cell build() throws IOException, InterruptedException {
    ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
    BuckConfig config = buckConfig == null ? FakeBuckConfig.builder().setFilesystem(filesystem).build() : buckConfig;
    KnownBuildRuleTypesFactory typesFactory = new KnownBuildRuleTypesFactory(executor, androidDirectoryResolver);
    if (parserFactory == null) {
        return CellProvider.createForLocalBuild(filesystem, watchman, config, cellConfig, typesFactory).getCellByPath(filesystem.getRootPath());
    }
    // The constructor for `Cell` is private, and it's in such a central location I don't really
    // want to make it public. Brace yourselves.
    Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(Cell.class);
    enhancer.setCallback((MethodInterceptor) (obj, method, args, proxy) -> {
        if ("createBuildFileParserFactory".equals(method.getName())) {
            return parserFactory;
        }
        return proxy.invokeSuper(obj, args);
    });
    return (Cell) enhancer.create();
}
Also used : MethodInterceptor(net.sf.cglib.proxy.MethodInterceptor) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) IOException(java.io.IOException) ProjectBuildFileParserFactory(com.facebook.buck.json.ProjectBuildFileParserFactory) Watchman(com.facebook.buck.io.Watchman) NULL_WATCHMAN(com.facebook.buck.io.Watchman.NULL_WATCHMAN) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) BuckConfig(com.facebook.buck.cli.BuckConfig) CellConfig(com.facebook.buck.config.CellConfig) TestConsole(com.facebook.buck.testutil.TestConsole) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) AndroidDirectoryResolver(com.facebook.buck.android.AndroidDirectoryResolver) Enhancer(net.sf.cglib.proxy.Enhancer) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Nullable(javax.annotation.Nullable) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Enhancer(net.sf.cglib.proxy.Enhancer) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole)

Example 50 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class WorkspaceAndProjectGeneratorTest method setUp.

@Before
public void setUp() throws InterruptedException, IOException {
    rootCell = (new TestCellBuilder()).build();
    ProjectFilesystem projectFilesystem = rootCell.getFilesystem();
    halideBuckConfig = HalideLibraryBuilder.createDefaultHalideConfig(projectFilesystem);
    cxxBuckConfig = CxxLibraryBuilder.createDefaultConfig();
    BuckConfig fakeBuckConfig = FakeBuckConfig.builder().build();
    appleConfig = new AppleConfig(fakeBuckConfig);
    swiftBuckConfig = new SwiftBuckConfig(fakeBuckConfig);
    setUpWorkspaceAndProjects();
}
Also used : AppleConfig(com.facebook.buck.apple.AppleConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) SwiftBuckConfig(com.facebook.buck.swift.SwiftBuckConfig) HalideBuckConfig(com.facebook.buck.halide.HalideBuckConfig) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) SwiftBuckConfig(com.facebook.buck.swift.SwiftBuckConfig) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) Before(org.junit.Before)

Aggregations

BuckConfig (com.facebook.buck.cli.BuckConfig)98 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)89 Test (org.junit.Test)74 Path (java.nio.file.Path)46 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)37 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)29 PathSourcePath (com.facebook.buck.rules.PathSourcePath)27 Cell (com.facebook.buck.rules.Cell)22 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)17 ImmutableMap (com.google.common.collect.ImmutableMap)17 Config (com.facebook.buck.config.Config)15 DefaultCellPathResolver (com.facebook.buck.rules.DefaultCellPathResolver)14 BuildTarget (com.facebook.buck.model.BuildTarget)12 FakeAndroidDirectoryResolver (com.facebook.buck.android.FakeAndroidDirectoryResolver)9 ParserConfig (com.facebook.buck.parser.ParserConfig)8 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)7 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)7 TestConsole (com.facebook.buck.testutil.TestConsole)7 Optional (java.util.Optional)7 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)6