-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify autograding configuration for plaintext diff (#1395)
* more c++ file types & start of compare script * prevent untrusted users from looking at other tmp folders * more print statements in compare * deal with exceptions in grading scheduler * change command name * small changes * revise myersdiff config.json interface * initial refactor * debug using test suite * refactor code * more refactor * update tests to use new diff syntax * update tests to use new diff syntax * more testing * cleanup code a bit
- Loading branch information
Showing
32 changed files
with
800 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#include <unistd.h> | ||
#include <cstdlib> | ||
#include <string> | ||
#include <iostream> | ||
#include <cassert> | ||
|
||
#include "TestCase.h" | ||
#include "execute.h" | ||
|
||
extern const char *GLOBAL_config_json_string; // defined in json_generated.cpp | ||
|
||
void AddAutogradingConfiguration(nlohmann::json &whole_config) { | ||
whole_config["autograding"]["submission_to_compilation"].push_back("**/*.cpp"); | ||
whole_config["autograding"]["submission_to_compilation"].push_back("**/*.cxx"); | ||
whole_config["autograding"]["submission_to_compilation"].push_back("**/*.c"); | ||
whole_config["autograding"]["submission_to_compilation"].push_back("**/*.h"); | ||
whole_config["autograding"]["submission_to_compilation"].push_back("**/*.hpp"); | ||
whole_config["autograding"]["submission_to_compilation"].push_back("**/*.hxx"); | ||
whole_config["autograding"]["submission_to_compilation"].push_back("**/*.java"); | ||
|
||
whole_config["autograding"]["submission_to_runner"].push_back("**/*.py"); | ||
whole_config["autograding"]["submission_to_runner"].push_back("**/*.pdf"); | ||
|
||
whole_config["autograding"]["compilation_to_runner"].push_back("**/*.out"); | ||
whole_config["autograding"]["compilation_to_runner"].push_back("**/*.class"); | ||
|
||
whole_config["autograding"]["compilation_to_validation"].push_back("test*.txt"); | ||
|
||
whole_config["autograding"]["submission_to_validation"].push_back("**/README.txt"); | ||
whole_config["autograding"]["submission_to_validation"].push_back("**/*.pdf"); | ||
|
||
whole_config["autograding"]["work_to_details"].push_back("test*.txt"); | ||
whole_config["autograding"]["work_to_details"].push_back("test*_diff.json"); | ||
whole_config["autograding"]["work_to_details"].push_back("**/README.txt"); | ||
} | ||
|
||
|
||
void RewriteDeprecatedMyersDiff(nlohmann::json &whole_config) { | ||
|
||
nlohmann::json::iterator tc = whole_config.find("testcases"); | ||
if (tc == whole_config.end()) { /* no testcases */ return; } | ||
|
||
// loop over testcases | ||
int which_testcase = 0; | ||
for (nlohmann::json::iterator my_testcase = tc->begin(); | ||
my_testcase != tc->end(); my_testcase++,which_testcase++) { | ||
nlohmann::json::iterator validators = my_testcase->find("validation"); | ||
if (validators == my_testcase->end()) { /* no autochecks */ continue; } | ||
|
||
// loop over autochecks | ||
for (int which_autocheck = 0; which_autocheck < validators->size(); which_autocheck++) { | ||
nlohmann::json& autocheck = (*validators)[which_autocheck]; | ||
std::string method = autocheck.value("method",""); | ||
|
||
// if autocheck is old myersdiff format... rewrite it! | ||
if (method == "myersDiffbyLinebyChar") { | ||
autocheck["method"] = "diff"; | ||
assert (autocheck.find("comparison") == autocheck.end()); | ||
autocheck["comparison"] = "byLinebyChar"; | ||
} else if (method == "myersDiffbyLinebyWord") { | ||
autocheck["method"] = "diff"; | ||
assert (autocheck.find("comparison") == autocheck.end()); | ||
autocheck["comparison"] = "byLinebyWord"; | ||
} else if (method == "myersDiffbyLine") { | ||
autocheck["method"] = "diff"; | ||
assert (autocheck.find("comparison") == autocheck.end()); | ||
autocheck["comparison"] = "byLine"; | ||
} else if (method == "myersDiffbyLineNoWhite") { | ||
autocheck["method"] = "diff"; | ||
assert (autocheck.find("comparison") == autocheck.end()); | ||
autocheck["comparison"] = "byLine"; | ||
assert (autocheck.find("ignoreWhitespace") == autocheck.end()); | ||
autocheck["ignoreWhitespace"] = true; | ||
} else if (method == "diffLineSwapOk") { | ||
autocheck["method"] = "diff"; | ||
assert (autocheck.find("comparison") == autocheck.end()); | ||
autocheck["comparison"] = "byLine"; | ||
assert (autocheck.find("lineSwapOk") == autocheck.end()); | ||
autocheck["lineSwapOk"] = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
// ===================================================================== | ||
// ===================================================================== | ||
|
||
nlohmann::json LoadAndProcessConfigJSON(const std::string &rcsid) { | ||
|
||
nlohmann::json answer; | ||
std::stringstream sstr(GLOBAL_config_json_string); | ||
sstr >> answer; | ||
|
||
AddSubmissionLimitTestCase(answer); | ||
AddAutogradingConfiguration(answer); | ||
if (rcsid != "") { | ||
CustomizeAutoGrading(rcsid,answer); | ||
} | ||
|
||
RewriteDeprecatedMyersDiff(answer); | ||
|
||
std::cout << "JSON PARSED" << std::endl; | ||
|
||
return answer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.