@Override public TestCase[] getNonSecretTestCasesForProblem(int problemId) throws CloudCoderAuthenticationException { User user = ServletUtil.checkClientIsAuthenticated( getThreadLocalRequest(), GetCoursesAndProblemsServiceImpl.class); TestCase[] testCases = Database.getInstance().getTestCasesForProblem(user, false, problemId); ArrayList<TestCase> nonSecretTestCases = new ArrayList<TestCase>(); for (TestCase tc : testCases) { if (!tc.isSecret()) { nonSecretTestCases.add(tc); } } return nonSecretTestCases.toArray(new TestCase[nonSecretTestCases.size()]); }
private void testOne(ProblemAndTestCaseList problemWithTestCases, String fileName) throws IOException, SubmissionException, InterruptedException { String programText = readProgram(fileName); OOPBuildServiceSubmission future = new OOPBuildServiceSubmission( new Submission( problemWithTestCases.getProblem(), Arrays.asList(problemWithTestCases.getTestCaseList()), programText)); serverTask.submit(future); SubmissionResult result; while (true) { result = future.poll(); if (result != null) { break; } Thread.sleep(200L); } if (fileName.startsWith("./")) { fileName = fileName.substring(2); } System.out.println("program: " + fileName); if (result.getCompilationResult().getOutcome() != CompilationOutcome.SUCCESS) { System.out.println("compiled: false"); return; } System.out.println("compiled: true"); for (int i = 0; i < problemWithTestCases.getTestCaseList().length; i++) { TestCase testCase = problemWithTestCases.getTestCaseList()[i]; TestResult testResult = result.getTestResults()[i]; String outcome; switch (testResult.getOutcome()) { case PASSED: outcome = "passed"; break; case FAILED_WITH_EXCEPTION: outcome = "crashed"; break; case FAILED_FROM_TIMEOUT: outcome = "timeout"; break; default: outcome = "failed"; break; } System.out.println("test " + testCase.getTestCaseName() + ":" + outcome); if (testResult.getOutcome() != TestOutcome.PASSED) { String output = testResult.getStdout(); if (!output.endsWith("\n")) { output = output + "\n"; } System.out.print(output); } } }