Beispiel #1
0
    def test_error_checkout(self):
        self.checkout.exists = MagicMock(return_value=False)
        self.checkout.create = MagicMock(side_effect=CommandFailedError("-cmd-", "-out-"))

        response = self.uut.process_project_version(self.project, self.version)

        assert_equals([self.version.id], response)
Beispiel #2
0
    def test_execute_sets_error(self, write_yaml_mock):
        self.detector.runner_interface.execute = MagicMock(
            side_effect=CommandFailedError("-cmd-", "-out-"))

        self.uut._execute("-compiles-", 42, 0, self.logger)

        assert_equals(Result.error, self.uut.result)
Beispiel #3
0
    def test_execute_captures_error_output(self, write_yaml_mock):
        self.detector.runner_interface.execute = MagicMock(
            side_effect=CommandFailedError("-cmd-", "-out-"))

        self.uut._execute("-compiles-", 42, 0, self.logger)

        assert_equals("Failed to execute '-cmd-': -out-", self.uut.message)
Beispiel #4
0
    def test_filter_error_lines_from_output(self, shell_mock, copy_mock):
        full_output = """15:46:17.784 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Transitioning model element 'tasks.wrapper' to state Discovered.
15:46:17.799 [ERROR] [org.gradle.BuildExceptionReporter]
15:46:17.802 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.abs15:46:17.811 [ERROR] [org.gradle.BuildExceptionReporter]
15:46:17.816 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
15:46:17.818 [ERROR] [org.gradle.BuildExceptionReporter] Could not create service of type TaskArtifactStateCacheAccess using TaskExecutionServices.createCacheAccess().
15:46:17.819 [ERROR] [org.gradle.BuildExceptionReporter] > Failed to create parent directory '/mubench/checkouts/synthetic/wait-loop/build/.gradle/2.10' when creating directory '/mubench/checkouts/synthetic/wait-loop/build/.gradle/2.10/taskArtifacts'
15:46:17.821 [ERROR] [org.gradle.BuildExceptionReporter]
15:46:17.822 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
15:46:17.823 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
15:46:17.824 [LIFECYCLE] [org.gradle.BuildResultLogger]
15:46:17.825 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
15:46:17.826 [LIFECYCLE] [org.gradle.BuildResultLogger]
15:46:17.827 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 3.061 secs"""
        shell_mock.side_effect = CommandFailedError("gradle build",
                                                    full_output)

        expected_error_output = """
15:46:17.799 [ERROR] [org.gradle.BuildExceptionReporter]
15:46:17.802 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.abs15:46:17.811 [ERROR] [org.gradle.BuildExceptionReporter]
15:46:17.816 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
15:46:17.818 [ERROR] [org.gradle.BuildExceptionReporter] Could not create service of type TaskArtifactStateCacheAccess using TaskExecutionServices.createCacheAccess().
15:46:17.819 [ERROR] [org.gradle.BuildExceptionReporter] > Failed to create parent directory '/mubench/checkouts/synthetic/wait-loop/build/.gradle/2.10' when creating directory '/mubench/checkouts/synthetic/wait-loop/build/.gradle/2.10/taskArtifacts'
15:46:17.821 [ERROR] [org.gradle.BuildExceptionReporter]
15:46:17.822 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
15:46:17.823 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace."""

        try:
            GradleCommand("gradle", ["build"]).execute("-project_dir-",
                                                       self.logger)
        except CommandFailedError as e:
            assert_equals(expected_error_output, e.output)
Beispiel #5
0
    def test_skips_on_build_error(self):
        self.mock_with_fake_compile()
        self.uut._compile.side_effect = CommandFailedError("-cmd-", "-error message-")

        response = self.uut.process_project_version(self.project, self.version)

        assert_equals([self.version.id], response)
Beispiel #6
0
    def test_filter_error_lines_from_output(self, shell_mock, copy_mock):
        full_output = """
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.122 s
[INFO] Finished at: 2017-06-20T15:11:39+02:00
[INFO] Final Memory: 5M/176M
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException"""
        shell_mock.side_effect = CommandFailedError("mvn build", full_output)

        expected_error_output = """
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException"""

        try:
            MavenCommand("mvn", ["build"]).execute("-project_dir-",
                                                   self.logger)
        except CommandFailedError as e:
            assert_equals(expected_error_output, e.output)
Beispiel #7
0
    def test_extraction_error(self, utils_mock):
        utils_mock.side_effect = CommandFailedError("cmd", "output")

        finding = Finding({"file": "-file-", "method": "-method-"})

        with assert_raises(SnippetUnavailableException):
            finding.get_snippets(["/base"])
Beispiel #8
0
    def test_execute_captures_error_output(self):
        Shell.exec = MagicMock(
            side_effect=CommandFailedError("-cmd-", "-out-"))

        self.uut.execute("-compiles-", 42, self.logger)

        assert_equals("Failed to execute '-cmd-': -out-", self.uut.message)
Beispiel #9
0
    def test_execute_sets_error(self):
        Shell.exec = MagicMock(
            side_effect=CommandFailedError("-cmd-", "-out-"))

        self.uut.execute("-compiles-", 42, self.logger)

        assert_equals(Result.error, self.uut.result)
Beispiel #10
0
    def test_default_does_not_filter_output_on_error(self, shell_mock):
        shell_mock.side_effect = CommandFailedError("-command-", "-output-")
        uut = BuildCommand.create("-some_command-")

        try:
            uut.execute("-project_dir-", self.logger)
        except CommandFailedError as e:
            assert_equals("\n-output-", e.output)
    def test_execute_cuts_output_if_too_long(self, write_yaml_mock):
        long_output = "\n".join(["line " + str(i) for i in range(1, 8000)])
        self.detector.runner_interface.execute = MagicMock(side_effect=CommandFailedError("-cmd-", long_output))

        self.uut.execute("-compiles-", 42, self.logger)

        print(self.uut.message)
        assert_equals(5000, len(str.splitlines(self.uut.message)))
Beispiel #12
0
    def test_error_outputs_error_stream(self, shell_mock, copy_mock):
        error = "-error-"
        shell_mock.side_effect = CommandFailedError("ant", "", error)

        expected_error_output = '\n' + error

        try:
            AntCommand("ant", []).execute("-project_dir-", self.logger)
        except CommandFailedError as e:
            assert_equals(expected_error_output, e.output)
Beispiel #13
0
    def test_extraction_error(self, utils_mock):
        utils_mock.side_effect = CommandFailedError("cmd", "output")

        finding = Finding({"file": "-file-", "method": "-method-"})

        with assert_raises(SnippetUnavailableException) as context:
            finding.get_snippets("/base")

        assert_equals('/base/-file-', context.exception.file)
        assert_equals(utils_mock.side_effect, context.exception.exception)
Beispiel #14
0
    def test_raises_on_error(self, shell_mock):
        shell_mock.side_effect = CommandFailedError("-command-", "-output-")
        uut = BuildCommand.create("-some_command-")

        assert_raises(CommandFailedError, uut.execute, "-p-", self.logger)
    def test_extraction_error(self, utils_mock):
        utils_mock.side_effect = CommandFailedError("cmd", "output")

        finding = Finding({"file": "-file-", "method": "-method-"})

        assert_equals([Snippet("Failed to execute 'cmd': output", 1)], finding.get_snippets("/base"))
Beispiel #16
0
    def test_error_checkout(self):
        self.checkout.exists = MagicMock(return_value=False)
        self.checkout.create = MagicMock(
            side_effect=CommandFailedError("-cmd-", "-out-"))

        assert_raises(CommandFailedError, self.uut.run, self.version)