Example #1
0
 /**
  * Assistent function to compile the java code
  *
  * @param string $file the .java file that should be compiled
  * @return array $compileroutput and $time
  */
 function compile($file)
 {
     $cfg = get_config('qtype_javaunittest');
     $command = $cfg->pathjavac . ' -nowarn -cp ' . $cfg->pathjunit . ' -sourcepath ' . dirname($file) . ' ' . $file;
     // execute the command
     $compileroutput = '';
     $time = 0;
     $ret = open_process($cfg->precommand . ';' . escapeshellcmd($command), $cfg->timeoutreal, $cfg->memory_limit_output * 1024, $compileroutput, $time);
     $compileroutput_compose = $compileroutput;
     if ($ret != OPEN_PROCESS_SUCCESS && empty($compileroutput)) {
         $compileroutput_compose = 'error (timeout?)';
     }
     return array('compileroutput' => $compileroutput_compose, 'time' => $time);
 }
Example #2
0
/**
 * Assistent function to compile the java code
 *
 * @param string $file the .java file that should be compiled
 * @return string $compileroutput the output of the compiler
 */
function compile($file)
{
    global $memory_limit_output, $timeoutreal;
    $command = PATH_TO_JAVAC . ' -nowarn -cp ' . PATH_TO_JUNIT . ' -sourcepath ' . dirname($file) . ' ' . $file;
    // execute the command
    $compileroutput = '';
    $time = 0;
    $ret = open_process(PRECOMMAND . ';' . escapeshellcmd($command), $timeoutreal, $memory_limit_output * 1024, $compileroutput, $time);
    if ($ret != OPEN_PROCESS_SUCCESS && empty($compileroutput)) {
        $compileroutput = 'error (timeout?)';
    }
    return array('compileroutput' => $compileroutput, 'time' => $time);
}
Example #3
0
 /**
  * Assistent function to compile the java code
  *
  * @param string $file the .java file that should be compiled
  * @return array $compileroutput and $time
  */
 function compile($file)
 {
     $cfg = get_config('qtype_javaunittest');
     $command = $cfg->pathjavac . ' -nowarn -cp ' . $cfg->pathjunit . ' -sourcepath ' . dirname($file) . ' ' . $file;
     // execute the command
     $compileroutput = '';
     $time = 0;
     $ret = open_process($cfg->precommand . ';' . escapeshellcmd($command), $cfg->timeoutreal, $cfg->memory_limit_output * 1024, $compileroutput, $time);
     #$checkstylecommand = 'checkstyle -c /usr/share/checkstyle/sun_checks.xml YourCode.java';
     #$checkstylecommand = 'checkstyle -c /usr/share/checkstyle/sun_checks.xml ' . dirname ( $file ) . '/' . $file;
     $checkstylecommand = 'checkstyle -c ' . getcwd() . '/google_checks.xml ' . $file;
     $ret_check = open_process($cfg->precommand . ';' . escapeshellcmd($checkstylecommand), $cfg->timeoutreal, $cfg->memory_limit_output * 1024, $compileroutput, $time);
     $fp = fopen(getcwd() . '\\data.txt', 'w');
     fwrite($fp, 'checkstylecommand ' . checkstylecommand);
     fwrite($fp, ret_check);
     fclose($fp);
     $compileroutput = $checkstylecommand . ' £££' . $compileroutput;
     if ($ret != OPEN_PROCESS_SUCCESS && empty($compileroutput)) {
         $compileroutput = 'error (timeout?)';
     }
     return array('compileroutput' => $compileroutput, 'time' => $time);
 }