Run a given test. @param path @throws IOException
(Trie test)
| 59 | * @throws IOException |
| 60 | */ |
| 61 | public Result run(Trie test) throws IOException { |
| 62 | // Parse the target test file |
| 63 | TestFile tf = readTestFile(srcDir, test); |
| 64 | // Setup test directory |
| 65 | Path testDir = setup(test); |
| 66 | // |
| 67 | try { |
| 68 | // Iterate test frames |
| 69 | int index = 0; |
| 70 | HashMap<Trie, TextFile> state = new HashMap<>(); |
| 71 | for (TestFile.Frame f : tf) { |
| 72 | boolean isLastFrame = ((index+1) == tf.size()); |
| 73 | // Apply frame to current state |
| 74 | f.apply(state); |
| 75 | // Determine frame directory |
| 76 | Path frameDir = testDir.resolve("_" + index); |
| 77 | // Mirror state in frame directory |
| 78 | mirror(state, frameDir); |
| 79 | // Apply each stage generating errors as appropriate |
| 80 | for (TestStage stage : stages) { |
| 81 | // Apply stage producing a set of errors |
| 82 | TestStage.Result result = stage.apply(test, frameDir, state, tf); |
| 83 | // Extract actual errors |
| 84 | Error[] actual = result.markers; |
| 85 | // Determine set of expected errors |
| 86 | Error[] expected = stage.filter(f.markers); |
| 87 | // Check we got what we expected. |
| 88 | Diff diff = compareReportedErrors(expected, actual); |
| 89 | // |
| 90 | if(diff.isEmpty() && result.ignored && isLastFrame) { |
| 91 | // In this case, the stage appears to have run correctly but is ignored. This |
| 92 | // suggests it doesn't need to be ignored any more. |
| 93 | return Result.INVALIDIGNORED; |
| 94 | } else if(diff.isEmpty()) { |
| 95 | // Stage completed successfully |
| 96 | if(actual.length > 0 && stage.required()) { |
| 97 | // Errors have been produced and this stage is required, so we cannot continue |
| 98 | // with this frame. |
| 99 | break; |
| 100 | } |
| 101 | } else if(result.ignored) { |
| 102 | // In this case, the test has failed and it was correctly ignored. Therefore, it |
| 103 | // should continue to be ignored. |
| 104 | return Result.IGNORED; |
| 105 | } else { |
| 106 | // In this case, the test has failed so something is up. |
| 107 | for(Error e : diff.missingExpected) { |
| 108 | System.out.println("expected error (frame " + index + "): " + e); |
| 109 | } |
| 110 | for(Error e : diff.missingActual) { |
| 111 | System.out.println("unexpected error (frame " + index + "): " + e); |
| 112 | } |
| 113 | return Result.FAILURE; |
| 114 | } |
| 115 | } |
| 116 | // |
| 117 | index = index + 1; |
| 118 | } |
nothing calls this directly
no test coverage detected