blob: 42b0d0c279a63c3bccd4267262ae9c7493c0098b [file] [log] [blame]
/*
* Copyright 2014-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.cxx;
import static org.junit.Assert.assertTrue;
import com.facebook.buck.cli.FakeBuckConfig;
import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.model.BuildTargetFactory;
import com.facebook.buck.model.Flavor;
import com.facebook.buck.model.FlavorDomain;
import com.facebook.buck.rules.SourcePath;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import org.junit.Test;
import java.util.Map;
public class CxxTestDescriptionTest {
@Test
public void findDepsFromParams() {
BuildTarget gtest = BuildTargetFactory.newInstance("//:gtest");
FakeBuckConfig buckConfig = new FakeBuckConfig(
ImmutableMap.<String, Map<String, String>>of(
"cxx",
ImmutableMap.of("gtest_dep", gtest.toString())));
CxxBuckConfig cxxBuckConfig = new CxxBuckConfig(buckConfig);
CxxPlatform cxxPlatform = DefaultCxxPlatforms.build(buckConfig);
CxxTestDescription desc = new CxxTestDescription(
cxxBuckConfig,
cxxPlatform,
new FlavorDomain<>("platform", ImmutableMap.<Flavor, CxxPlatform>of()));
BuildTarget target = BuildTargetFactory.newInstance("//:target");
CxxTestDescription.Arg constructorArg = desc.createUnpopulatedConstructorArg();
constructorArg.framework = Optional.of(CxxTestType.GTEST);
constructorArg.lexSrcs = Optional.of(ImmutableList.<SourcePath>of());
Iterable<BuildTarget> implicit = desc
.findDepsForTargetFromConstructorArgs(target, constructorArg);
assertTrue(Iterables.contains(implicit, gtest));
}
}