@Mutate public void createGoogleTestTestBinaries( final BinaryContainer binaries, TestSuiteContainer testSuites, @Path("buildDir") File buildDir, ServiceRegistry serviceRegistry, ITaskFactory taskFactory) { for (final GoogleTestTestSuiteSpec googleTestTestSuite : testSuites.withType(GoogleTestTestSuiteSpec.class)) { for (NativeBinarySpec testedBinary : googleTestTestSuite .getTestedComponent() .getBinaries() .withType(NativeBinarySpec.class)) { if (testedBinary instanceof SharedLibraryBinary) { // TODO:DAZ For now, we only create test suites for static library variants continue; } DefaultGoogleTestTestSuiteBinary testBinary = createTestBinary(serviceRegistry, googleTestTestSuite, testedBinary, taskFactory); configure(testBinary, buildDir); googleTestTestSuite.getBinaries().add(testBinary); binaries.add(testBinary); } } }
@Finalize public void configureGoogleTestTestSuiteSources( TestSuiteContainer testSuites, @Path("buildDir") File buildDir) { for (final GoogleTestTestSuiteSpec suite : testSuites.withType(GoogleTestTestSuiteSpec.class)) { FunctionalSourceSet suiteSourceSet = ((ComponentSpecInternal) suite).getSources(); CppSourceSet testSources = suiteSourceSet.maybeCreate("cpp", CppSourceSet.class); testSources.getSource().srcDir(String.format("src/%s/%s", suite.getName(), "cpp")); testSources.getExportedHeaders().srcDir(String.format("src/%s/headers", suite.getName())); } }
private GoogleTestTestSuiteSpec createGoogleTestTestSuite( final NativeComponentSpec testedComponent, Instantiator instantiator, ProjectSourceSet projectSourceSet, FileResolver fileResolver) { String suiteName = String.format("%sTest", testedComponent.getName()); String path = testedComponent.getProjectPath(); ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(path, suiteName); FunctionalSourceSet testSuiteSourceSet = createGoogleTestSources(instantiator, suiteName, projectSourceSet, fileResolver); GoogleTestTestSuiteSpec testSuiteSpec = BaseComponentSpec.create( DefaultGoogleTestTestSuiteSpec.class, id, testSuiteSourceSet, instantiator); testSuiteSpec.setTestedComponent(testedComponent); return testSuiteSpec; }
private DefaultGoogleTestTestSuiteBinary createTestBinary( ServiceRegistry serviceRegistry, GoogleTestTestSuiteSpec googleTestTestSuite, NativeBinarySpec testedBinary, ITaskFactory taskFactory) { BinaryNamingScheme namingScheme = new DefaultBinaryNamingSchemeBuilder( ((NativeBinarySpecInternal) testedBinary).getNamingScheme()) .withComponentName(googleTestTestSuite.getBaseName()) .withTypeString("GoogleTestExe") .build(); Instantiator instantiator = serviceRegistry.get(Instantiator.class); NativeDependencyResolver resolver = serviceRegistry.get(NativeDependencyResolver.class); return DefaultGoogleTestTestSuiteBinary.create( googleTestTestSuite, (NativeBinarySpecInternal) testedBinary, namingScheme, resolver, instantiator, taskFactory); }