Skip to content

Commit

Permalink
Removed Unnecessary comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
AtillaColak committed Aug 3, 2023
1 parent cec3e5a commit e1e257a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,58 +69,6 @@ public boolean execute(Context ctx, DirectoryConfiguration dirCfg, RunConfigurat
return passesTheMetaTest;
}
}
// This was the execute method I updated, but this was causing a failing test in LibraryMetaTestsTest.
// So I decided to work on the RunMetaTestsStep class for error handling.
// @Override
// public boolean execute(Context ctx, DirectoryConfiguration dirCfg, RunConfiguration runCfg){
// try {/* Get the student solution, which we will run for each meta test */
// String solutionFile = findSolution(dirCfg.getWorkingDir());
//
// /* Get the original library content that we will keep changing according to the meta test */
// File libraryFile = new File(findLibrary(dirCfg.getWorkingDir()));
// String originalLibraryContent = readFile(libraryFile);
//
// /*
// * For each meta test, we basically perform a string replace in the
// * original library code, recompile it, and run the tests.
// * If there's a failing test, the meta test is killed.
// *
// * We reuse our execution framework to run the code with the meta test.
// */
//
// /* Copy the library and replace the library by the meta test */
// File metaWorkingDir = createTemporaryDirectory("metaWorkplace").toFile();
// copyFile(solutionFile, metaWorkingDir.getAbsolutePath());
// String metaFileContent = generateMetaFileContent(originalLibraryContent);
// createMetaTestFile(metaWorkingDir, metaFileContent);
//
// /* We then run the meta test, using our infrastructure */
// Result metaResult = runMetaTest(ctx, dirCfg, metaWorkingDir);
//
// /* And check the result. If there's a failing test, the test suite is good! */
// int testsRan = metaResult.getTests().getTestsRan();
// int testsSucceeded = metaResult.getTests().getTestsSucceeded();
// boolean passesTheMetaTest = testsSucceeded < testsRan;
//
// /* Clean up the directory */
// deleteDirectory(metaWorkingDir);
//
// /* Set the classloader back to the one with the student's original code */
// Thread.currentThread().setContextClassLoader(ctx.getClassloaderWithStudentsCode());
//
// return passesTheMetaTest;
// } catch (Exception e){
// if(runCfg.mode().equals(Mode.EXAM)){
// System.out.println("Meta test compilation error occurred.");
// }
// else{
// System.err.println("Meta test compilation error occurred:");
// e.printStackTrace(System.err);
// }
// // if test fails, return false to keep it organized.
// return false;
// }
// }

private String generateMetaFileContent(String originalLibraryContent) {
String metaFileContent = evaluate(originalLibraryContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,42 +173,4 @@ void withStringReplacementNotFound() {
assertThrows(RuntimeException.class,
() -> metaTest.evaluate("line 1\nline 2\nline 3\nline 4\nline 5"));
}
// I initially wrote this test because try-catch was inside LibraryMetaTest. Will remove it when decision is final.
// @Test
// void testExecuteWithCompilationErrorExamMode() throws Exception {
// // Create mock objects
// Context ctxMock = mock(Context.class);
// DirectoryConfiguration dirCfgMock = mock(DirectoryConfiguration.class);
// RunConfiguration runCfgMock = mock(RunConfiguration.class);
//
// // Set up the behavior of the mock objects
// when(runCfgMock.mode()).thenReturn(Mode.EXAM);
// when(dirCfgMock.getWorkingDir()).thenThrow(new RuntimeException("Working directory exception."));
//
// // Create the LibraryMetaTest object
// LibraryMetaTest metaTest = (LibraryMetaTest) MetaTest.withStringReplacement("some meta test",
// "line 5\nline 6",
// "extra line 1\nextra line 2");
//
// // Create a stream to hold the output
// // if tests run in parallel, this could cause an issue as we capture logging and change system out settings.
// ByteArrayOutputStream outContent = new ByteArrayOutputStream();
// PrintStream originalOut = System.out;
// System.setOut(new PrintStream(outContent));
//
// // Test the execute method with the mocked objects
// boolean result = metaTest.execute(ctxMock, dirCfgMock, runCfgMock);
//
// // Assertions
// assertFalse(result); // The test should fail due to the compilation error
//
// // Verify that the proper methods were called on the mock objects
// verify(runCfgMock, times(1)).mode();
//
// // Assert that the correct message was logged
// assertEquals("Meta test compilation error occurred.\n", outContent.toString());
//
// // Restore System.out to its original
// System.setOut(originalOut);
// }
}

0 comments on commit e1e257a

Please sign in to comment.