internal CompileTask EnqueueCompilation(string source) { var task = new CompileTask(source); compileTasks.Add(task); return(task); }
public void CompileTaskNullCompilerTest() { var sourceCodeFilePath = Helper.CreateFileForCompilation( CompileServiceLanguageSourceCode.CPPCorrectSourceCode, this.compiler.Extension); var compileTask = new CompileTask(null, sourceCodeFilePath); }
public void CompileTastConstructorTest() { var sourceCodeFilePath = Helper.CreateFileForCompilation( CompileServiceLanguageSourceCode.CPPCorrectSourceCode, this.compiler.Extension); var compileTask = new CompileTask(this.compiler, sourceCodeFilePath); File.Delete(sourceCodeFilePath); }
public void CompileTaskGetStandardStringTest() { // create default compile task var sourceCodeFilePath = Helper.CreateFileForCompilation("my incorrect code", this.compiler.Extension); var compileTask = new CompileTask(this.compiler, sourceCodeFilePath); var result = compileTask.Execute(); Assert.AreEqual(result, false); Assert.AreEqual(string.IsNullOrEmpty(compileTask.StandardError), false); Assert.AreEqual(string.IsNullOrEmpty(compileTask.StandardOutput), false); }
public string Compile(string source, IFile sourceFile) { Trace.Source.TraceInformation("Compiling {0}", sourceFile.FullPath); var workItem = new CompileTask(source); try { return workItem.QueueAndWaitForResult(); } catch (Exception ex) { var message = ex.Message + " in " + sourceFile.FullPath; Trace.Source.TraceEvent(TraceEventType.Critical, 0, message); throw new CoffeeScriptCompileException(message, sourceFile.FullPath, ex); } }
public void CompileTaskConstructorTest() { // create compiler var compiler = new Compiler { Name = "CPP", Location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Compilers\CPP8\Compiler\CL.EXE"), Extension = "cpp", Arguments = "/I\"$CompilerDirectory$\" $SourceFilePath$ /link /LIBPATH:\"$CompilerDirectory$\"", CompiledExtension = "exe", IsNeedShortPath = true }; var sourceCodeFilePath = Helper.CreateFileForCompilation( CompileServiceLanguageSourceCode.CPPCorrectSourceCode, compiler.Extension); try { var compileTask = new CompileTask(null, sourceCodeFilePath); Assert.AreEqual(true, false); } catch (Exception) { Assert.AreEqual(true, true); } try { var compileTask = new CompileTask(compiler, "BadFilePath"); Assert.AreEqual(true, false); } catch (Exception) { Assert.AreEqual(true, true); } try { var compileTask = new CompileTask(compiler, sourceCodeFilePath); Assert.AreEqual(true, true); } catch (Exception) { Assert.AreEqual(true, false); } File.Delete(sourceCodeFilePath); }
public string Compile(string source, IFile sourceFile) { Trace.Source.TraceInformation("Compiling {0}", sourceFile.FullPath); var workItem = new CompileTask(source); try { return(workItem.QueueAndWaitForResult()); } catch (Exception ex) { var message = ex.Message + " in " + sourceFile.FullPath; Trace.Source.TraceEvent(TraceEventType.Critical, 0, message); throw new CoffeeScriptCompileException(message, sourceFile.FullPath, ex); } }
public string Compile(string source, string language, string[] input, string[] output, int timelimit, int memorylimit) { // remove after testing const string CompilerDirectory = "Compilers"; var compilers = new Compilers(CompilerDirectory); compilers.Load(); //---- if (string.IsNullOrEmpty(language)) { throw new Exception("Bad language name"); } source = HttpUtility.UrlDecode(source); Compiler currentCompiler = compilers.GetCompiler(language); if (currentCompiler == null) { throw new Exception("Can't find compiler with such name"); } string compileFilePath = Classes.Helper.CreateFileForCompilation(source, currentCompiler.Extension); var compileTask = new CompileTask(currentCompiler, compileFilePath); if (!compileTask.Execute()) { return("CompilationError"); } var executeFilePath = Path.ChangeExtension(compileFilePath, currentCompiler.CompiledExtension); for (int i = 0; i < input.Length; i++) { var currentStatus = Tester.Test(executeFilePath, input[i], output[i], timelimit, memorylimit); if (currentStatus.TestResult != "Accepted") { currentStatus.TestResult = currentStatus.TestResult + " Test: " + i; return(currentStatus.TestResult); } } return("Accepted"); }
protected override void OnActivated() { base.OnActivated(); MainClass.MainWindow.ProcessOutput.Clear(); MainClass.MainWindow.ErrorOutput.Clear(); if (MainClass.Settings.ClearConsoleBeforRuning) { MainClass.MainWindow.OutputConsole.Clear(); } TaskList tl = new TaskList(); tl.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>(); CompileTask ct = new CompileTask(); tl.TasksList.Add(ct); MainClass.MainWindow.RunTaskList(tl, false); return; }
public void QueueWorkItem(CompileTask item) { lazyQueue.Value.Enqueue(item); }
internal CompileTask EnqueueCompilation(string source) { var task = new CompileTask(source); compileTasks.Add(task); return task; }
public CompileTask Compile([FromBody] CompileTask task) { var filename = Path + DateTime.Now.GetHashCode().ToString(); var filenameExt = filename + ".cpp"; System.IO.File.WriteAllText(filenameExt, task.Source); string compileRes = ""; string compileError = ""; string output = ""; string runtimeError = ""; var compile = new Process { StartInfo = new ProcessStartInfo { FileName = "make", Arguments = filename, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; compile.Start(); while (!compile.StandardOutput.EndOfStream) { compileRes += compile.StandardOutput.ReadLine() + "\n"; } while (!compile.StandardError.EndOfStream) { compileError += compile.StandardError.ReadLine() + "\n"; } task.CompileOutput = compileRes; task.CompileError = compileError; var run = new Process { StartInfo = new ProcessStartInfo { FileName = filename, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; run.Start(); if (!run.WaitForExit(2000)) { task.RuntimeError = "Timed out"; run.Kill(); return(task); } while (!run.StandardOutput.EndOfStream) { output += run.StandardOutput.ReadLine() + "\n"; } while (!run.StandardError.EndOfStream) { runtimeError += run.StandardError.ReadLine() + "\n"; } task.RuntimeError = runtimeError; task.Output = output; return(task); }
public void CompileTaskBadPathTest() { var compileTask = new CompileTask(this.compiler, "BadFilePath"); }