Ejemplo n.º 1
0
	def run(self, env):
		java_builder = IgnoringJavaBuilder(_flags="", _libs=self.junit_version,_file_pattern=r"^.*\.[jJ][aA][vV][aA]$",_output_flags="")
		java_builder._ignore = self.ignore.split(" ")

		
		build_result = java_builder.run(env)

		if not build_result.passed:
			result = CheckerResult(checker=self)
			result.set_passed(False)
			result.set_log('<pre>' + escape(self.test_description) + '\n\n======== Test Results ======\n\n</pre><br/>\n'+build_result.log)
			return result

		environ = {}

		environ['UPLOAD_ROOT'] = settings.UPLOAD_ROOT
		environ['JAVA'] = settings.JVM
		environ['POLICY'] = os.path.join(os.path.join(os.path.dirname(os.path.dirname(__file__)),"scripts"),"junit.policy")

		cmd = [settings.JVM_SECURE, "-cp", settings.JAVA_LIBS[self.junit_version]+":.", self.runner(), self.class_name]
		[output, error, exitcode,timed_out] = execute_arglist(cmd, env.tmpdir(),environment_variables=environ,timeout=settings.TEST_TIMEOUT,fileseeklimit=settings.TEST_MAXFILESIZE)

		result = CheckerResult(checker=self)

		(output,truncated) = truncated_log(output)
		output = '<pre>' + escape(self.test_description) + '\n\n======== Test Results ======\n\n</pre><br/><pre>' + escape(output) + '</pre>'


		result.set_log(output,timed_out=timed_out,truncated=truncated)
		result.set_passed(not exitcode and not timed_out and self.output_ok(output) and not truncated)
		return result
Ejemplo n.º 2
0
	def run(self, env):
		""" Runs tests in a special environment. Here's the actual work. 
		This runs the check in the environment ENV, returning a CheckerResult. """

		# Setup
		copy_file(self.shell_script.path, env.tmpdir(), to_is_directory=True)
		os.chmod(env.tmpdir()+'/'+os.path.basename(self.shell_script.name),0750)
		
		# Run the tests -- execute dumped shell script 'script.sh'

		filenames = [quote(name) for (name,content) in env.sources()]
		args = [env.tmpdir()+'/'+os.path.basename(self.shell_script.name)] + filenames

		environ = {}
		environ['USER'] = str(env.user().id)
		environ['HOME'] = env.tmpdir()
		environ['JAVA'] = settings.JVM
		environ['JAVA_SECURE'] = settings.JVM_SECURE
		environ['PROGRAM'] = env.program() or ''

		[output, error, exitcode,timed_out] = execute_arglist(args, working_directory=env.tmpdir(), environment_variables=environ,timeout=settings.TEST_TIMEOUT,fileseeklimit=settings.TEST_MAXFILESIZE)
		output = force_unicode(output, errors='replace')

		result = CheckerResult(checker=self)
		(output,truncated) = truncated_log(output)

		if self.remove:
			output = re.sub(self.remove, "", output)
		if not self.returns_html or truncated:
			output = '<pre>' + escape(output) + '</pre>'

		result.set_log(output,timed_out=timed_out,truncated=truncated)
		result.set_passed(not exitcode and not timed_out and not truncated)
		
		return result
Ejemplo n.º 3
0
    def run(self, env):
        java_builder = IgnoringJavaBuilder(
            _flags="",
            _libs=self.junit_version,
            _file_pattern=r"^.*\.[jJ][aA][vV][aA]$",
            _output_flags="")
        java_builder._ignore = self.ignore.split(" ")

        build_result = java_builder.run(env)

        if not build_result.passed:
            result = self.create_result(env)
            result.set_passed(False)
            result.set_log(
                '<pre>' + escape(self.test_description) +
                '\n\n======== Test Results ======\n\n</pre><br/>\n' +
                build_result.log)
            return result

        environ = {}

        environ['UPLOAD_ROOT'] = settings.UPLOAD_ROOT
        environ['JAVA'] = settings.JVM
        script_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                  'scripts')
        environ['POLICY'] = os.path.join(script_dir, "junit.policy")

        cmd = [
            settings.JVM_SECURE, "-cp",
            settings.JAVA_LIBS[self.junit_version] + ":.",
            self.runner(), self.class_name
        ]
        [output, error, exitcode, timed_out,
         oom_ed] = execute_arglist(cmd,
                                   env.tmpdir(),
                                   environment_variables=environ,
                                   timeout=settings.TEST_TIMEOUT,
                                   fileseeklimit=settings.TEST_MAXFILESIZE,
                                   extradirs=[script_dir])

        result = self.create_result(env)

        (output, truncated) = truncated_log(output)
        output = '<pre>' + escape(
            self.test_description
        ) + '\n\n======== Test Results ======\n\n</pre><br/><pre>' + escape(
            output) + '</pre>'

        result.set_log(output,
                       timed_out=timed_out or oom_ed,
                       truncated=truncated)
        result.set_passed(not exitcode and not timed_out and not oom_ed
                          and self.output_ok(output) and not truncated)
        return result
Ejemplo n.º 4
0
    def run(self, env):
        """ Runs tests in a special environment. Here's the actual work. 
		This runs the check in the environment ENV, returning a CheckerResult. """

        # Setup
        copy_file(self.shell_script.path, env.tmpdir(), to_is_directory=True)
        os.chmod(env.tmpdir() + '/' + os.path.basename(self.shell_script.name),
                 0750)

        # Run the tests -- execute dumped shell script 'script.sh'

        filenames = [name for (name, content) in env.sources()]
        args = [env.tmpdir() + '/' + os.path.basename(self.shell_script.name)
                ] + filenames

        environ = {}
        environ['USER'] = str(env.user().id)
        environ['HOME'] = env.tmpdir()
        environ['JAVA'] = settings.JVM
        environ['JAVA_SECURE'] = settings.JVM_SECURE
        environ['POLICY'] = settings.JVM_POLICY
        environ['PROGRAM'] = env.program() or ''

        script_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                  'scripts')

        [output, error, exitcode, timed_out, oom_ed] = execute_arglist(
            args,
            working_directory=env.tmpdir(),
            environment_variables=environ,
            timeout=settings.TEST_TIMEOUT,
            maxmem=settings.TEST_MAXMEM,
            fileseeklimit=settings.TEST_MAXFILESIZE,
            extradirs=[script_dir],
        )
        output = force_unicode(output, errors='replace')

        result = self.create_result(env)
        (output, truncated) = truncated_log(output)

        if self.remove:
            output = re.sub(self.remove, "", output)
        if not self.returns_html or truncated or timed_out or oom_ed:
            output = '<pre>' + escape(output) + '</pre>'

        result.set_log(output, timed_out=timed_out, truncated=truncated)
        result.set_passed(not exitcode and not timed_out and not oom_ed
                          and not truncated)

        return result
	def run(self, env):
                filecopy_result = self.run_file(env)
                if not filecopy_result.passed: return filecopy_result
                

                if self.require_safe:
                        safe_builder = IgnoringHaskellBuilder(_flags="-XSafe", _file_pattern = r"^.*\.[hH][sS]$", _main_required=False)
                        safe_builder._ignore=self.ignore.split(" ") + [self.path_relative_to_sandbox()]
                        safe_build_result = safe_builder.run(env)
                        if not safe_build_result.passed:
                                result = self.create_result(env)
                                result.set_passed(False)
                                result.set_log('<pre>' + escape(self.test_description) + '\n\n======== Test Results  (Safe) ======\n\n</pre><br/>\n'+safe_build_result.log)
                                return result

                test_builder = TestOnlyBuildingBuilder(_flags="-main-is "+self.module_name(), _libs="test-framework test-framework-quickcheck2 test-framework-hunit")
                test_builder._testsuite_filename=self.path_relative_to_sandbox()
                test_build_result = test_builder.run(env)

                if not test_build_result.passed:
                        result = self.create_result(env)
			result.set_passed(False)
			result.set_log('<pre>' + escape(self.test_description) + '\n\n======== Test Results (Building all) ======\n\n</pre><br/>\n'+test_build_result.log)
			return result

		environ = {}

		environ['UPLOAD_ROOT'] = settings.UPLOAD_ROOT

		cmd = ["./"+self.module_binary_name(), "--maximum-generated-tests=5000"]
		[output, error, exitcode,timed_out, oom_ed] = execute_arglist(cmd, env.tmpdir(),environment_variables=environ,timeout=settings.TEST_TIMEOUT,fileseeklimit=settings.TEST_MAXFILESIZE)

		result = self.create_result(env)

		(output,truncated) = truncated_log(output)
		output = '<pre>' + escape(self.test_description) + '\n\n======== Test Results ======\n\n</pre><br/><pre>' + escape(output) + '</pre>'
                
                if self.include_testcase_in_report in ["FULL","DL"]:
                        testsuit_template = get_template('checker/checker/haskell_test_framework_report.html')
                        output += testsuit_template.render(Context({'showSource' : (self.include_testcase_in_report=="FULL"), 'testfile' : self.file, 'testfilename' : self.path_relative_to_sandbox(), 'testfileContent': encoding.get_unicode(self.file.read())}))


		result.set_log(output,timed_out=timed_out or oom_ed,truncated=truncated)
		result.set_passed(not exitcode and not timed_out and not oom_ed and self.output_ok(output) and not truncated)
		return result
    def run(self, env):
        filecopy_result = self.run_file(env)
        if not filecopy_result.passed: return filecopy_result

        if self.require_safe:
            safe_builder = IgnoringHaskellBuilder(
                _flags="-XSafe",
                _file_pattern=r"^.*\.[hH][sS]$",
                _main_required=False)
            safe_builder._ignore = self.ignore.split(" ") + [
                self.path_relative_to_sandbox()
            ]
            safe_build_result = safe_builder.run(env)
            if not safe_build_result.passed:
                result = CheckerResult(checker=self)
                result.set_passed(False)
                result.set_log(
                    '<pre>' + escape(self.test_description) +
                    '\n\n======== Test Results  (Safe) ======\n\n</pre><br/>\n'
                    + safe_build_result.log)
                return result

        test_builder = TestOnlyBuildingBuilder(
            _flags="-main-is " + self.module_name(),
            _libs=
            "test-framework test-framework-quickcheck2 test-framework-hunit")
        test_builder._testsuite_filename = self.path_relative_to_sandbox()
        test_build_result = test_builder.run(env)

        if not test_build_result.passed:
            result = CheckerResult(checker=self)
            result.set_passed(False)
            result.set_log(
                '<pre>' + escape(self.test_description) +
                '\n\n======== Test Results (Building all) ======\n\n</pre><br/>\n'
                + test_build_result.log)
            return result

        environ = {}

        environ['UPLOAD_ROOT'] = settings.UPLOAD_ROOT

        cmd = [
            "./" + self.module_binary_name(), "--maximum-generated-tests=5000"
        ]
        [output, error, exitcode,
         timed_out] = execute_arglist(cmd,
                                      env.tmpdir(),
                                      environment_variables=environ,
                                      timeout=settings.TEST_TIMEOUT,
                                      fileseeklimit=settings.TEST_MAXFILESIZE)

        result = CheckerResult(checker=self)

        (output, truncated) = truncated_log(output)
        output = '<pre>' + escape(
            self.test_description
        ) + '\n\n======== Test Results ======\n\n</pre><br/><pre>' + escape(
            output) + '</pre>'

        if self.include_testcase_in_report in ["FULL", "DL"]:
            testsuit_template = get_template(
                'checker/checker/haskell_test_framework_report.html')
            output += testsuit_template.render(
                Context({
                    'showSource': (self.include_testcase_in_report == "FULL"),
                    'testfile':
                    self.file,
                    'testfilename':
                    self.path_relative_to_sandbox(),
                    'testfileContent':
                    encoding.get_unicode(self.file.read())
                }))

        result.set_log(output, timed_out=timed_out, truncated=truncated)
        result.set_passed(not exitcode and not timed_out
                          and self.output_ok(output) and not truncated)
        return result