Search in sources :

Example 46 with ExecutableOutput

use of com.synopsys.integration.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.

the class ApkPackageManagerTest method canParseArchitecture.

@Test
public void canParseArchitecture() throws ExecutableRunnerException {
    final String exampleOutput = "x86_64\n";
    DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
    Mockito.when(executableRunner.execute(null, "apk", Arrays.asList("info", "--print-arch"))).thenReturn(new ExecutableOutput(0, exampleOutput, ""));
    ApkArchitectureResolver architectureResolver = new ApkArchitectureResolver();
    Optional<String> architecture = architectureResolver.resolveArchitecture(new ClangPackageManagerInfoFactory().apk(), null, executableRunner);
    assertTrue(architecture.isPresent());
    Assertions.assertEquals("x86_64", architecture.get());
}
Also used : ClangPackageManagerInfoFactory(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfoFactory) DetectableExecutableRunner(com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner) ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) ApkArchitectureResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver) Test(org.junit.jupiter.api.Test)

Example 47 with ExecutableOutput

use of com.synopsys.integration.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.

the class DockerExtractorTest method getDetectableExecutableRunner.

@NotNull
private DetectableExecutableRunner getDetectableExecutableRunner() throws ExecutableRunnerException {
    DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
    ExecutableOutput executableOutput = Mockito.mock(ExecutableOutput.class);
    Mockito.when(executableOutput.getReturnCode()).thenReturn(0);
    Mockito.when(executableRunner.execute(Mockito.any(Executable.class))).thenReturn(executableOutput);
    return executableRunner;
}
Also used : DetectableExecutableRunner(com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner) ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) Executable(com.synopsys.integration.executable.Executable) NotNull(org.jetbrains.annotations.NotNull)

Example 48 with ExecutableOutput

use of com.synopsys.integration.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.

the class CondaCliDetectableTest method setup.

@Override
protected void setup() throws IOException {
    addFile("environment.yml");
    ExecutableOutput condaListOutput = createStandardOutput("[", "   {", "       \"base_url\": null,", "       \"build_number\": 0,", "       \"build_string\": \"0\",", "       \"channel\": \"defaults\",", "       \"dist_name\": \"mkl-2017.0.3-0\",", "       \"name\": \"mkl\",", "       \"platform\": null,", "       \"version\": \"2017.0.3\",", "       \"with_features_depends\": null", "   },", "   {", "       \"base_url\": null,", "       \"build_number\": 0,", "       \"build_string\": \"py36_0\",", "       \"channel\": \"defaults\",", "       \"dist_name\": \"numpy-1.13.1-py36_0\",", "       \"name\": \"numpy\",", "       \"platform\": null,", "       \"version\": \"1.13.1\",", "       \"with_features_depends\": null", "   }", "]");
    addExecutableOutput(condaListOutput, "conda", "list", "-n", "conda-env", "--json");
    ExecutableOutput condaInfoOutput = createStandardOutput("{", "   \"conda_build_version\": \"not installed\",", "   \"conda_env_version\": \"4.3.22\",", "   \"conda_location\": \"/usr/local/miniconda3/lib/python3.6/site-packages/conda\",", "   \"conda_prefix\": \"/usr/local/miniconda3\",", "   \"conda_private\": false,", "   \"conda_version\": \"4.3.22\",", "   \"default_prefix\": \"/usr/local/miniconda3\",", "   \"platform\": \"osx-64\"", "}");
    addExecutableOutput(getOutputDirectory(), condaInfoOutput, "conda", "info", "--json");
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput)

Example 49 with ExecutableOutput

use of com.synopsys.integration.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.

the class CpanCliDetectableTest method setup.

@Override
protected void setup() throws IOException {
    // TODO: The difference between LIST and SHOWDEPS is not clear from this test.
    addFile("Makefile.PL");
    ExecutableOutput cpanListOutput = createStandardOutput("ExtUtils::MakeMaker\t7.24", "perl\t5.1", "Test::More\t1.3");
    addExecutableOutput(getOutputDirectory(), cpanListOutput, "cpan", "-l");
    ExecutableOutput cpanmShowDepsOutput = createStandardOutput("--> Working on .", "Configuring App-cpanminus-1.7043 ... OK", "ExtUtils::MakeMaker~6.58", "Test::More", "perl~5.008001", "ExtUtils::MakeMaker");
    addExecutableOutput(getOutputDirectory(), cpanmShowDepsOutput, "cpanm", "--showdeps", ".");
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput)

Example 50 with ExecutableOutput

use of com.synopsys.integration.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.

the class GoModDetectableTest method setup.

@Override
protected void setup() throws IOException {
    addFile(Paths.get("go.mod"));
    ExecutableOutput goListOutput = createStandardOutputFromResource("/go/go-list.xout");
    addExecutableOutput(goListOutput, "go", "list", "-m", "-json");
    ExecutableOutput goVersionOutput = createStandardOutput("go version go1.16.5 darwin/amd64");
    addExecutableOutput(goVersionOutput, "go", "version");
    ExecutableOutput goListUJsonOutput = createStandardOutputFromResource("/go/go-list-all.xout");
    addExecutableOutput(goListUJsonOutput, "go", "list", "-mod=readonly", "-m", "-json", "all");
    ExecutableOutput goModGraphOutput = createStandardOutput("github.com/gin-gonic/gin golang.org/x/text@v0.3.0", "github.com/gin-gonic/gin sigs.k8s.io/yaml@v1.2.0", "golang.org/x/text@v0.3.0 golang.org/x/tools@v0.0.0-20180917221912-90fa682c2a6e", "gopkg.in/yaml.v2@v2.2.8 gopkg.in/check.v1@v0.0.0-20161208181325-20d25e280405", "sigs.k8s.io/yaml@v1.2.0 github.com/davecgh/go-spew@v1.1.1", "sigs.k8s.io/yaml@v1.2.0 gopkg.in/yaml.v2@v2.2.8");
    addExecutableOutput(goModGraphOutput, "go", "mod", "graph");
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput)

Aggregations

ExecutableOutput (com.synopsys.integration.executable.ExecutableOutput)53 File (java.io.File)18 DetectableExecutableRunner (com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner)14 ArrayList (java.util.ArrayList)14 Extraction (com.synopsys.integration.detectable.extraction.Extraction)13 ExecutableRunnerException (com.synopsys.integration.executable.ExecutableRunnerException)13 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)10 ExecutableTarget (com.synopsys.integration.detectable.ExecutableTarget)9 Executable (com.synopsys.integration.executable.Executable)9 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)8 Test (org.junit.jupiter.api.Test)7 NameVersion (com.synopsys.integration.util.NameVersion)6 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 HashMap (java.util.HashMap)5 List (java.util.List)5 StringUtils (org.apache.commons.lang3.StringUtils)5 ExecutableUtils (com.synopsys.integration.detectable.ExecutableUtils)4 IOException (java.io.IOException)4 Optional (java.util.Optional)4 Gson (com.google.gson.Gson)3