use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelCommandExecutor in project synopsys-detect by blackducksoftware.
the class PipelinesTest method doTest.
private List<Dependency> doTest(WorkspaceRule workspaceRule, List<String> expectedBazelCommandArgs, List<String> userProvidedCqueryAdditionalOptions, String input) throws IntegrationException, ExecutableFailedException {
BazelCommandExecutor bazelCommandExecutor = Mockito.mock(BazelCommandExecutor.class);
Mockito.when(bazelCommandExecutor.executeToString(expectedBazelCommandArgs)).thenReturn(Optional.of(input));
BazelVariableSubstitutor bazelVariableSubstitutor = new BazelVariableSubstitutor("/:testTarget", userProvidedCqueryAdditionalOptions);
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
HaskellCabalLibraryJsonProtoParser haskellCabalLibraryJsonProtoParser = new HaskellCabalLibraryJsonProtoParser(new Gson());
Pipelines pipelines = new Pipelines(bazelCommandExecutor, bazelVariableSubstitutor, externalIdFactory, haskellCabalLibraryJsonProtoParser);
Pipeline pipeline = pipelines.get(workspaceRule);
return pipeline.run();
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelCommandExecutor in project synopsys-detect by blackducksoftware.
the class BazelExtractor method extract.
public Extraction extract(ExecutableTarget bazelExe, File workspaceDir, File workspaceFile) throws ExecutableFailedException, DetectableException {
toolVersionLogger.log(workspaceDir, bazelExe, "version");
BazelCommandExecutor bazelCommandExecutor = new BazelCommandExecutor(executableRunner, workspaceDir, bazelExe);
Pipelines pipelines = new Pipelines(bazelCommandExecutor, bazelVariableSubstitutor, externalIdFactory, haskellCabalLibraryJsonProtoParser);
Set<WorkspaceRule> workspaceRulesFromFile = parseWorkspaceRulesFromFile(workspaceFile);
Set<WorkspaceRule> workspaceRulesToQuery = workspaceRuleChooser.choose(workspaceRulesFromFile, workspaceRulesFromProperty);
CodeLocation codeLocation = generateCodelocation(pipelines, workspaceRulesToQuery);
return buildResults(codeLocation, bazelProjectNameGenerator.generateFromBazelTarget(bazelTarget));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelCommandExecutor in project synopsys-detect by blackducksoftware.
the class IntermediateStepExecuteBazelOnEachLineTest method testNoInput.
@Test
public void testNoInput() throws ExecutableRunnerException, IntegrationException, ExecutableFailedException {
File workspaceDir = new File(".");
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
ExecutableTarget bazelExe = ExecutableTarget.forCommand("/usr/bin/bazel");
ExecutableOutput bazelCmdExecutableOutput = Mockito.mock(ExecutableOutput.class);
Mockito.when(bazelCmdExecutableOutput.getReturnCode()).thenReturn(0);
Mockito.when(bazelCmdExecutableOutput.getStandardOutput()).thenReturn("@org_apache_commons_commons_io//jar:jar\n@com_google_guava_guava//jar:jar");
Mockito.when(executableRunner.executeSuccessfully(Mockito.any(Executable.class))).thenReturn(bazelCmdExecutableOutput);
BazelCommandExecutor bazelCommandExecutor = new BazelCommandExecutor(executableRunner, workspaceDir, bazelExe);
BazelVariableSubstitutor bazelVariableSubstitutor = new BazelVariableSubstitutor("//:ProjectRunner", null);
IntermediateStep executor = new IntermediateStepExecuteBazelOnEachLine(bazelCommandExecutor, bazelVariableSubstitutor, Arrays.asList("cquery", "filter(\\\"@.*:jar\\\", deps(${detect.bazel.target}))"), false);
List<String> input = new ArrayList<>(0);
List<String> output = executor.process(input);
assertEquals(1, output.size());
assertEquals("@org_apache_commons_commons_io//jar:jar\n@com_google_guava_guava//jar:jar", output.get(0));
}
Aggregations