/*
 * 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;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import com.facebook.buck.core.config.FakeBuckConfig;
import com.facebook.buck.util.environment.Architecture;
import com.facebook.buck.util.environment.Platform;
import java.util.Optional;
import org.junit.Test;

public class CliConfigTest {

  @Test
  public void testCreateAnsi() {
    CliConfig windowsConfig =
        FakeBuckConfig.builder()
            .setArchitecture(Architecture.X86_64)
            .setPlatform(Platform.WINDOWS)
            .build()
            .getView(CliConfig.class);
    // "auto" on Windows is equivalent to "never".
    assertFalse(windowsConfig.createAnsi(Optional.empty()).isAnsiTerminal());
    assertFalse(windowsConfig.createAnsi(Optional.of("auto")).isAnsiTerminal());
    assertTrue(windowsConfig.createAnsi(Optional.of("always")).isAnsiTerminal());
    assertFalse(windowsConfig.createAnsi(Optional.of("never")).isAnsiTerminal());

    CliConfig linuxConfig =
        FakeBuckConfig.builder()
            .setArchitecture(Architecture.I386)
            .setPlatform(Platform.LINUX)
            .build()
            .getView(CliConfig.class);
    // We don't test "auto" on Linux, because the behavior would depend on how the test was run.
    assertTrue(linuxConfig.createAnsi(Optional.of("always")).isAnsiTerminal());
    assertFalse(linuxConfig.createAnsi(Optional.of("never")).isAnsiTerminal());
  }
}

@@ -632,16 +632,56 @@
 k.cli;%0A%0A
+import static org.hamcrest.Matchers.is;%0A
 import s
@@ -758,16 +758,59 @@
 ertTrue;
+%0Aimport static org.junit.Assume.assumeThat;
 %0A%0Aimport
@@ -1044,17 +1044,16 @@
 gTest %7B%0A
-%0A
   @Test%0A
@@ -1084,12 +1084,79 @@
 Ansi
-() %7B
+ForWindows() %7B%0A    assumeThat(Platform.detect(), is(Platform.WINDOWS));
 %0A   
@@ -1742,16 +1742,124 @@
 nal());%0A
+  %7D%0A%0A  @Test%0A  public void testCreateAnsiForLinux() %7B%0A    assumeThat(Platform.detect(), is(Platform.LINUX));
 %0A    Cli

Fix a test to run only the relevant part, depending on the platform it runs on.