public void Evaluate(SubmissionJson submission) { Console.WriteLine("Evaluation Started"); ICompiler compiler = CompilerFactory.GetCompiler(submission.Language); string executablePath = String.Empty; string testsFolder = String.Empty; if (compiler != null) { if (compiler.Compile(submissionsPaths[submission.Id], out executablePath)) { Console.WriteLine("Source successfully compiled"); testsFolder = @"b:\tests\"; File.Copy(executablePath, @"b:\tests\a.exe", true); foreach (var test in repository.Tests) { ProblemTest problemTest = new ProblemTest() { Id = test.Id, Name = test.Name, Data = test.Data }; Execution execution = worker.Execute2(@"b:\tests\adunare", problemTest, null); } } else { Console.WriteLine("Source has compiled with errors"); } } }
public void EventLoop() { while (events.Count > 0) { LoadTests loader = new LoadTests(); List <Test> tests = new List <Test>(); List <Test> tests1 = new List <Test>(); tests = loader.Get("B:\\tests\\adunare", "adunare"); tests1 = loader.Get("B:\\tests\\ciurul", "ciurul"); GCC gcc = new GCC(@"C:\MinGW\bin\g++.exe"); CompilerFactory.RegisterCompiler("C++", gcc); CompilerFactory.RegisterCompiler("C++11", gcc); CompilerFactory.RegisterCompiler("C+11", gcc); CompilerFactory.RegisterCompiler("C++14", gcc); CompilerFactory.RegisterCompiler("C", gcc); tests.AddRange(tests1); Repository repository = new Repository(); repository.Tests = tests; Judge judge = new Judge("B:\\evaluare", "C++", repository); SubmissionJson submission = events.Dequeue().Submission; submission.Code = submission.Code.Replace("@", System.Environment.NewLine); SaveSolution saveSolution = new SaveSolution(submission.Code, @"B:\solutions", submission.ProblemName + submission.SubmissionAccountId, "cpp"); saveSolution.SaveFile(); Dictionary <int, string> submissionsPaths = new Dictionary <int, string>(); submissionsPaths[submission.Id] = saveSolution.GetCodePath(); judge.SetSubmissionPath(submissionsPaths); judge.Evaluate(submission); } }
public void Evaluate(SubmissionJson submission) { Console.WriteLine("Evaluation Started"); ICompiler compiler = CompilerFactory.GetCompiler(submission.Language); string executablePath = String.Empty; string testsFolder = String.Empty; if (compiler != null) { if (compiler.Compile(submissionsPaths[submission.Id], out executablePath)) { testsFolder = TestsDirectory.FullName + "\\" + submission.SubmissionProblemId + "\\"; File.Copy(executablePath, WorkAreaDirectory.FullName + "\\" + submission.SubmissionProblemId + Constants.exe, true); foreach (var test in repository.Tests) { } } } }
static void Main(string[] args) { //EventQueue events = new EventQueue(); //TcpServer.Queue = events; //TcpServer.Start(); LoadTests loader = new LoadTests(); List <Test> tests = new List <Test>(); List <Test> tests1 = new List <Test>(); tests = loader.Get("B:\\tests\\adunare", "adunare"); tests1 = loader.Get("B:\\tests\\ciurul", "ciurul"); for (int i = 0; i < tests1.Count; ++i) { tests.Add(tests1[i]); } Repository repository = new Repository(); repository.Tests = tests; Judge judge = new Judge("B:\\evaluare", "GCCCompiler", repository); SubmissionJson submission = new SubmissionJson { Code = "#include <iostream> using namespace std; int main() { cout << 1 ; return 0; }", Language = "C++", SubmissionAccountId = "1", SubmissionProblemId = 1 }; judge.Evaluate(submission); Console.Read(); }