Skip to content

Commit e499753

Browse files
committed
Add updates on tcframe
1 parent 16cab14 commit e499753

File tree

14 files changed

+299
-61
lines changed

14 files changed

+299
-61
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

include/tcframe/driver/TestCaseDriver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class TestCaseDriver {
3838
IOManipulator* ioManipulator,
3939
Verifier* verifier,
4040
MultipleTestCasesConfig multipleTestCasesConfig)
41-
: ioManipulator_(ioManipulator)
42-
, rawIOManipulator_(rawIOManipulator)
41+
: rawIOManipulator_(rawIOManipulator)
42+
, ioManipulator_(ioManipulator)
4343
, verifier_(verifier)
4444
, multipleTestCasesConfig_(move(multipleTestCasesConfig)) {}
4545

include/tcframe/runner/grader/Grader.hpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <map>
55
#include <string>
66
#include <vector>
7-
87
#include "GradingOptions.hpp"
98
#include "GraderLogger.hpp"
109
#include "TestCaseGrader.hpp"
@@ -78,7 +77,7 @@ class Grader {
7877
private:
7978
map<int, double> getSubtaskPoints(const GradingOptions& options) {
8079
map<int, double> subtaskPointsByIds;
81-
for (int id = 1; id <= options.subtaskPoints().size(); id++) {
80+
for (unsigned id = 1; id <= options.subtaskPoints().size(); id++) {
8281
subtaskPointsByIds[id] = options.subtaskPoints()[id - 1];
8382
}
8483
if (subtaskPointsByIds.empty()) {
@@ -107,21 +106,29 @@ class Grader {
107106
.build();
108107
gradeTestCase(testCase, options, verdictsBySubtaskId);
109108
} else {
109+
bool skipping = 0;
110110
for (const TestCase& testCase : testGroup.testCases()) {
111-
gradeTestCase(testCase, options, verdictsBySubtaskId);
111+
TestCaseVerdict verdict = gradeTestCase(testCase, options, verdictsBySubtaskId, skipping);
112+
if(verdict.verdict().code() != "OK" && verdict.verdict().code() != "AC") {
113+
// comment this code if you dont want to skip
114+
skipping = 1;
115+
}
112116
}
113117
}
114118
}
115119

116-
void gradeTestCase(
120+
TestCaseVerdict gradeTestCase(
117121
const TestCase& testCase,
118122
const GradingOptions& options,
119-
map<int, vector<TestCaseVerdict>>& verdictsBySubtaskId) {
120-
121-
TestCaseVerdict verdict = testCaseGrader_->grade(testCase, options);
123+
map<int, vector<TestCaseVerdict>>& verdictsBySubtaskId,
124+
bool skipTestCase = 0) {
125+
TestCaseVerdict verdict;
126+
if(skipTestCase) verdict = TestCaseVerdict(Verdict::skip());
127+
else verdict = testCaseGrader_->grade(testCase, options);
122128
for (int subtaskId : testCase.subtaskIds()) {
123129
verdictsBySubtaskId[subtaskId].push_back(verdict);
124130
}
131+
return verdict;
125132
}
126133
};
127134

include/tcframe/runner/os/OperatingSystem.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ class OperatingSystem {
100100

101101
private:
102102
static void runCommand(const string& command) {
103-
system(command.c_str());
103+
int val = system(command.c_str());
104+
std::cerr << "[tcframe] exit code: " << val << "\n";
104105
}
105106
};
106107

include/tcframe/runner/verdict/Verdict.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ struct Verdict {
4747
return {"ERR", "Internal Error", 99};
4848
}
4949

50+
static Verdict skip() {
51+
return {"SKIP", "Skipped", -1};
52+
}
53+
5054
const string& code() const {
5155
return code_;
5256
}

include/tcframe/spec/constraint/Subtask.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ struct Subtask {
3434

3535
Subtask(int id, double points, vector<Constraint> constraints)
3636
: id_(id)
37-
, points_(points)
38-
, constraints_(move(constraints)) {}
37+
, constraints_(move(constraints))
38+
, points_(points) {}
3939

4040
int id() const {
4141
return id_;

include/tcframe/spec/core/Magic.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace tcframe {
3636
struct VectorSize {
3737
function<int()> size;
3838

39-
explicit VectorSize(function<int()> size)
40-
: size(move(size)) {}
39+
explicit VectorSize(function<int()> _size)
40+
: size(move(_size)) {}
4141
};
4242

4343
template<typename T>
@@ -55,9 +55,9 @@ struct MatrixSize {
5555
function<int()> rows;
5656
function<int()> columns;
5757

58-
MatrixSize(function<int()> rows, function<int()> columns)
59-
: rows(move(rows))
60-
, columns(move(columns)) {}
58+
MatrixSize(function<int()> _rows, function<int()> _columns)
59+
: rows(move(_rows))
60+
, columns(move(_columns)) {}
6161
};
6262

6363
class VariableNamesExtractor {

include/tcframe/spec/io/IOFormat.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct IOFormat {
4949
if (a.size() != b.size()) {
5050
return false;
5151
}
52-
for (int i = 0; i < a.size(); i++) {
52+
for (unsigned i = 0; i < a.size(); i++) {
5353
if (!a[i]->equals(b[i])) {
5454
return false;
5555
}
@@ -61,7 +61,7 @@ struct IOFormat {
6161
if (a.size() != b.size()) {
6262
return false;
6363
}
64-
for (int i = 0; i < a.size(); i++) {
64+
for (unsigned i = 0; i < a.size(); i++) {
6565
if (!equals(a[i], b[i])) {
6666
return false;
6767
}

include/tcframe/spec/io/LinesIOSegment.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct LinesIOSegment : public IOSegment {
4646
if (variables_.size() != o.variables_.size()) {
4747
return false;
4848
}
49-
for (int i = 0; i < variables_.size(); i++) {
49+
for (unsigned i = 0; i < variables_.size(); i++) {
5050
if (!variables_[i]->equals(o.variables_[i])) {
5151
return false;
5252
}

include/tcframe/spec/io/LinesIOSegmentManipulator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class LinesIOSegmentManipulator {
6565

6666
int size = getSize(segment);
6767
for (int j = 0; j < size; j++) {
68-
for (int i = 0; i < segment->variables().size(); i++) {
68+
for (unsigned i = 0; i < segment->variables().size(); i++) {
6969
Variable *variable = segment->variables()[i];
7070
if (variable->type() == VariableType::VECTOR) {
7171
if (i > 0) {

0 commit comments

Comments
 (0)