Search in sources :

Example 86 with BuckConfig

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

the class ProGuardConfigTest method proGuardJarOverrideUsedShouldBeRelativeToTheProjectRoot.

@Test
public void proGuardJarOverrideUsedShouldBeRelativeToTheProjectRoot() throws IOException {
    Path proGuardJar = Paths.get("proguard.jar");
    FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
    filesystem.touch(proGuardJar);
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("tools", ImmutableMap.of("proguard", proGuardJar.toString()))).setFilesystem(filesystem).build();
    ProGuardConfig proGuardConfig = new ProGuardConfig(buckConfig);
    Optional<SourcePath> proGuardJarOverride = proGuardConfig.getProguardJarOverride();
    assertTrue(proGuardJarOverride.isPresent());
    assertEquals(new PathSourcePath(filesystem, proGuardJar), proGuardJarOverride.get());
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PathSourcePath(com.facebook.buck.rules.PathSourcePath) Test(org.junit.Test)

Example 87 with BuckConfig

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

the class ProGuardConfigTest method whenProGuardJarNotFound.

@Test(expected = HumanReadableException.class)
public void whenProGuardJarNotFound() throws IOException {
    Path proGuardJar = Paths.get("proguard.jar");
    FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("tools", ImmutableMap.of("proguard", proGuardJar.toString()))).setFilesystem(filesystem).build();
    ProGuardConfig proGuardConfig = new ProGuardConfig(buckConfig);
    Optional<SourcePath> proGuardJarOverride = proGuardConfig.getProguardJarOverride();
    assertTrue(proGuardJarOverride.isPresent());
    assertEquals(new PathSourcePath(filesystem, proGuardJar), proGuardJarOverride.get());
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PathSourcePath(com.facebook.buck.rules.PathSourcePath) Test(org.junit.Test)

Example 88 with BuckConfig

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

the class ProGuardConfigTest method whenProGuardMaxHeapSizeOverrideUsed.

@Test
public void whenProGuardMaxHeapSizeOverrideUsed() throws IOException {
    String proGuardMaxHeapSize = "1234M";
    FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("tools", ImmutableMap.of("proguard-max-heap-size", proGuardMaxHeapSize))).setFilesystem(filesystem).build();
    ProGuardConfig proGuardConfig = new ProGuardConfig(buckConfig);
    assertEquals(proGuardMaxHeapSize, proGuardConfig.getProguardMaxHeapSize());
}
Also used : FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Test(org.junit.Test)

Example 89 with BuckConfig

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

the class AppleConfigTest method getSpecifiedAppleDeveloperDirectorySupplierForTests.

@Test
public void getSpecifiedAppleDeveloperDirectorySupplierForTests() {
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("apple", ImmutableMap.of("xcode_developer_dir", "/path/to/somewhere", "xcode_developer_dir_for_tests", "/path/to/somewhere2"))).build();
    AppleConfig config = new AppleConfig(buckConfig);
    Supplier<Optional<Path>> supplier = config.getAppleDeveloperDirectorySupplier(new FakeProcessExecutor());
    assertNotNull(supplier);
    assertEquals(Optional.of(Paths.get("/path/to/somewhere")), supplier.get());
    Supplier<Optional<Path>> supplierForTests = config.getAppleDeveloperDirectorySupplierForTests(new FakeProcessExecutor());
    assertNotNull(supplierForTests);
    assertEquals(Optional.of(Paths.get("/path/to/somewhere2")), supplierForTests.get());
}
Also used : FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Optional(java.util.Optional) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) Test(org.junit.Test)

Example 90 with BuckConfig

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

the class StackedDownloaderTest method shouldNotUseRetryingDownloaderIfMaxNumberOfRetriesIsSet.

@Test
public void shouldNotUseRetryingDownloaderIfMaxNumberOfRetriesIsSet() throws IOException {
    BuckConfig config = FakeBuckConfig.builder().build();
    Downloader downloader = StackedDownloader.createFromConfig(config, Optional.empty());
    assertThat(downloader, not(includes(RetryingDownloader.class)));
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) Test(org.junit.Test)

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