def test_codegen_simple(self): build_request = self.request(['compile'], self.java) walk = self.build_and_walk(build_request) # The subgraph below 'src/thrift/codegen/simple' will be affected by its default variants. subjects = [self.guava, self.java, self.thrift] variant_subjects = [ Jar(org='org.apache.thrift', name='libthrift', rev='0.9.2', type_alias='jar'), Jar(org='commons-lang', name='commons-lang', rev='2.5', type_alias='jar'), Address.parse('src/thrift:slf4j-api') ] # Root: expect a DependenciesNode depending on a SelectNode with compilation via javac. self.assert_root(walk, SelectNode(self.java, Classpath, None, None), Classpath(creator='javac')) # Confirm that exactly the expected subjects got Classpaths. self.assert_select_for_subjects(walk, Classpath, subjects) self.assert_select_for_subjects(walk, Classpath, variant_subjects, variants={'thrift': 'apache_java'})
def test_managed_resolve(self): """A managed resolve should consume a ManagedResolve and ManagedJars to produce Jars.""" build_request = self.request(['compile'], self.consumes_managed_thirdparty) walk = self.build_and_walk(build_request) # Validate the root. self.assertEqual( (SelectNode(self.consumes_managed_thirdparty, Classpath, None, None), Return(Classpath(creator='javac'))), walk[0][0]) # Confirm that we produced classpaths for the managed jars. managed_jars = [self.managed_guava, self.managed_hadoop] self.assert_select_for_subjects(walk, Classpath, [self.consumes_managed_thirdparty]) self.assert_select_for_subjects(walk, Classpath, managed_jars, variants={'resolve': 'latest-hadoop'}) # Confirm that the produced jars had the appropriate versions. self.assertEquals( { Jar('org.apache.hadoop', 'hadoop-common', '2.7.0'), Jar('com.google.guava', 'guava', '18.0') }, { ret.value for (node, ret), _ in walk if node.product == Jar and isinstance(node, SelectNode) })
def assert_engine(self, engine): build_request = BuildRequest(goals=['compile'], addressable_roots=[self.java.address]) result = engine.execute(build_request) self.assertEqual( { SelectNode(self.java, Classpath, None): Return(Classpath(creator='javac')) }, result.root_products) self.assertIsNone(result.error)
def test_dependency_inference(self): """Scala dependency inference introduces dependencies that do not exist in BUILD files.""" build_request = self.request(['compile'], self.inferred_deps) walk = self.build_and_walk(build_request) # Validate the root. self.assertEqual( (SelectNode(self.inferred_deps, Classpath, None, None), Return(Classpath(creator='scalac'))), walk[0][0]) # Confirm that we requested a classpath for the root and inferred targets. self.assert_select_for_subjects(walk, Classpath, [self.inferred_deps, self.java_simple])
def test_consumes_resources(self): build_request = self.request(['compile'], self.consumes_resources) walk = self.build_and_walk(build_request) # Validate the root. self.assertEqual( (SelectNode(self.consumes_resources, Classpath, None, None), Return(Classpath(creator='javac'))), walk[0][0]) # Confirm a classpath for the resources target and other subjects. We know that they are # reachable from the root (since it was involved in this walk). subjects = [self.resources, self.consumes_resources, self.guava] self.assert_select_for_subjects(walk, Classpath, subjects)
def test_codegen_simple(self): build_request = BuildRequest(goals=['compile'], addressable_roots=[self.java.address]) walk = self.build_and_walk(build_request) subjects = [self.guava, Jar(org='org.apache.thrift', name='libthrift', rev='0.9.2'), Jar(org='commons-lang', name='commons-lang', rev='2.5'), self.graph.resolve(Address.parse('src/thrift:slf4j-api')), self.java, self.thrift] # Root: expect compilation via javac. self.assertEqual((SelectNode(self.java, Classpath, None), Return(Classpath(creator='javac'))), walk[0][0]) # Confirm that exactly the expected subjects got Classpaths. self.assert_product_for_subjects(walk, Classpath, subjects)
def test_codegen_simple(self): build_request = BuildRequest(goals=['compile'], addressable_roots=[self.java]) walk = self.build_and_walk(build_request) # The subgraph below 'src/thrift/codegen/simple' will be affected by its default variants. subjects = [self.guava, self.java, self.thrift] variant_subjects = [ Jar(org='org.apache.thrift', name='libthrift', rev='0.9.2'), Jar(org='commons-lang', name='commons-lang', rev='2.5'), Address.parse('src/thrift:slf4j-api') ] # Root: expect compilation via javac. self.assertEqual( (SelectNode(self.java, Classpath, None, None), Return(Classpath(creator='javac'))), walk[0][0]) # Confirm that exactly the expected subjects got Classpaths. self.assert_select_for_subjects(walk, Classpath, subjects) self.assert_select_for_subjects(walk, Classpath, variant_subjects, variants={'thrift': 'apache_java'})
def assert_engine(self, engine): result = engine.execute(self.request(['compile'], self.java)) self.assertEqual({SelectNode(self.java, Classpath, None, None): Return(Classpath(creator='javac'))}, result.root_products) self.assertIsNone(result.error)