internal static ProtoCore.Core TestRunnerRunOnly(string code) { ProtoCore.Core core; ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner(); ProtoScript.Config.RunConfiguration runnerConfig; string testPath = @"..\..\..\Scripts\Debugger\"; // Specify some of the requirements of IDE. var options = new ProtoCore.Options(); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; options.SuppressBuildOutput = false; core = new ProtoCore.Core(options); core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core)); core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core)); runnerConfig = new ProtoScript.Config.RunConfiguration(); runnerConfig.IsParrallel = false; fsr = new ProtoScriptTestRunner(); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); CLRModuleType.ClearTypes(); //Run ProtoLanguage.CompileStateTracker compileState = null; fsr.Execute(code, core, out compileState); return(core); }
internal static ProtoCore.Core TestRunnerRunOnly(string code) { ProtoCore.Core core; ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner(); ProtoScript.Config.RunConfiguration runnerConfig; // Specify some of the requirements of IDE. var options = new ProtoCore.Options(); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; options.SuppressBuildOutput = false; string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; options.IncludeDirectories.Add(testPath); core = new ProtoCore.Core(options); core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core)); core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core)); runnerConfig = new ProtoScript.Config.RunConfiguration(); runnerConfig.IsParrallel = false; fsr = new ProtoScriptTestRunner(); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); CLRModuleType.ClearTypes(); //Run fsr.Execute(code, core); return(core); }
internal static ProtoCore.Core TestRunnerRunOnly(string includePath, string code, Dictionary <int, List <string> > map, string geometryFactory, string persistentManager, out ExecutionMirror mirror) { ProtoCore.Core core; ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner(); ProtoScript.Config.RunConfiguration runnerConfig; // Specify some of the requirements of IDE. var options = new ProtoCore.Options(); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; options.SuppressBuildOutput = false; options.WatchTestMode = true; // Cyclic dependency threshold is lowered from the default (2000) // as this causes the test framework to be painfully slow options.kDynamicCycleThreshold = 5; // Pass the absolute path so that imported filepaths can be resolved // in "FileUtils.GetDSFullPathName()" includePath = Path.GetDirectoryName(includePath); options.IncludeDirectories.Add(includePath); //StreamWriter sw = File.CreateText(executionLogFilePath); TextOutputStream fs = new TextOutputStream(map); core = new ProtoCore.Core(options); core.Configurations.Add(ConfigurationKeys.GeometryXmlProperties, true); //core.Configurations.Add(ConfigurationKeys.GeometryFactory, geometryFactory); //core.Configurations.Add(ConfigurationKeys.PersistentManager, persistentManager); // By specifying this option we inject a mock Executive ('InjectionExecutive') // that prints stackvalues at every assignment statement // by overriding the POP_handler instruction - pratapa //core.ExecutiveProvider = new InjectionExecutiveProvider(); core.BuildStatus.MessageHandler = fs; core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core)); runnerConfig = new ProtoScript.Config.RunConfiguration(); runnerConfig.IsParrallel = false; DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); //Run mirror = fsr.Execute(code, core); //sw.Close(); return(core); }
public void TestArrayCoreDump01() { string sourceCode = @" class A { c : int = 0; constructor B(v : int) { c = v; } } values = A.B(1..20..1);" ; ExecutionMirror mirror = coreRunner.Execute(sourceCode, core, out runtimeCore); List <string> globalVariables = null; mirror.GetCoreDump(out globalVariables, 7, 4); Assert.AreEqual(1, globalVariables.Count); Assert.AreEqual("values = { A(c = 1), A(c = 2), A(c = 3), ..., A(c = 18), A(c = 19), A(c = 20) }", globalVariables[0]); }
internal void TestRunnerRunOnly(string includePath, string code, Dictionary <int, List <string> > map /*, string executionLogFilePath*/) { ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner(); ProtoScript.Config.RunConfiguration runnerConfig; // Specify some of the requirements of IDE. core.Options.ExecutionMode = ProtoCore.ExecutionMode.Serial; core.Options.SuppressBuildOutput = false; core.Options.WatchTestMode = true; core.Options.GCTempVarsOnDebug = false; // Cyclic dependency threshold is lowered from the default (2000) // as this causes the test framework to be painfully slow core.Options.kDynamicCycleThreshold = 5; // Pass the absolute path so that imported filepaths can be resolved // in "FileUtils.GetDSFullPathName()" if (!String.IsNullOrEmpty(includePath)) { includePath = Path.GetDirectoryName(includePath); core.Options.IncludeDirectories.Add(includePath); } //StreamWriter sw = File.CreateText(executionLogFilePath); TextOutputStream fs = new TextOutputStream(map); // By specifying this option we inject a mock Executive ('InjectionExecutive') // that prints stackvalues at every assignment statement // by overriding the POP_handler instruction - pratapa core.ExecutiveProvider = new InjectionExecutiveProvider(); core.BuildStatus.MessageHandler = fs; core.RuntimeStatus.MessageHandler = fs; core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core)); core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core)); runnerConfig = new ProtoScript.Config.RunConfiguration(); runnerConfig.IsParrallel = false; DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); //Run Mirror = fsr.Execute(code, core); //sw.Close(); core.Cleanup(); }
private void RunWithoutDebuggerGuts(string scriptCode) // On background thread, no UI access. { var timer = new System.Diagnostics.Stopwatch(); timer.Start(); try { workerParams.RegularRunMirror = scriptRunner.Execute(scriptCode, core, out compileState); } catch (System.Exception exception) { workerParams.ExecException = exception; } finally { timer.Stop(); workerParams.ElapsedMilliseconds = timer.ElapsedMilliseconds; } }
/// <summary> /// Method to run an inline Ds script. /// </summary> /// <param name="sourceCode">The String contains the ds codes</param> /// <returns></returns> public virtual ExecutionMirror RunScriptSource(string sourceCode, string errorstring = "", string includePath = "") { if (testImport) { Guid g; g = Guid.NewGuid(); StackTrace trace = new StackTrace(); int caller = 2; string tempPath = System.IO.Path.GetTempPath(); string import = @"testImport\"; string importDir = Path.Combine(tempPath, import); if (!Directory.Exists(importDir)) { System.IO.Directory.CreateDirectory(importDir); } string importFileName = (g.ToString() + ".ds"); createDSFile(importFileName, importDir, sourceCode); return(testMirror = RunScriptFile(importDir, importFileName)); } else if (testDebug) { Dictionary <int, List <string> > map = new Dictionary <int, List <string> >(); if (!String.IsNullOrEmpty(includePath)) { if (System.IO.Directory.Exists(includePath)) { testCore.Options.IncludeDirectories.Add(includePath); } else { Console.WriteLine(String.Format("Path: {0} does not exist.", includePath)); } } StringReader file = new StringReader(sourceCode); WatchTestFx.GeneratePrintStatements(file, ref map); WatchTestFx fx = new WatchTestFx(); testCore = fx.TestCore; fx.CompareRunAndWatchResults("", sourceCode, map); testMirror = fx.Mirror; return(testMirror); } else { SetupTestCore(); if (!String.IsNullOrEmpty(includePath)) { if (System.IO.Directory.Exists(includePath)) { testCore.Options.IncludeDirectories.Add(includePath); } else { Console.WriteLine(String.Format("Path: {0} does not exist.", includePath)); } } testMirror = runner.Execute(sourceCode, testCore, out testRuntimeCore); if (dumpDS) { String fileName = TestContext.CurrentContext.Test.Name + ".ds"; String folderName = TestContext.CurrentContext.Test.FullName; string[] substrings = folderName.Split('.'); string path = "..\\..\\..\\test\\core\\dsevaluation\\DSFiles\\"; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } createDSFile(fileName, path, sourceCode); } SetErrorMessage(errorstring); return(testMirror); } }
/// <summary> /// Method to run an inline Ds script. /// </summary> /// <param name="sourceCode">The String contains the ds codes</param> /// <returns></returns> public ExecutionMirror RunScriptSource(string sourceCode, string errorstring = "", string includePath = "") { if (testImport) { Guid g; g = Guid.NewGuid(); StackTrace trace = new StackTrace(); int caller = 2; StackFrame frame = trace.GetFrame(caller); string callerName = frame.GetMethod().Name; string tempPath = System.IO.Path.GetTempPath(); string import = @"testImport\"; string importDir = Path.Combine(tempPath, import); if (!Directory.Exists(importDir)) { System.IO.Directory.CreateDirectory(importDir); } string importFileName = (g.ToString() + ".ds"); createDSFile(importFileName, importDir, sourceCode); return(testMirror = RunScriptFile(importDir, importFileName)); } else if (testDebug) { Dictionary <int, List <string> > map = new Dictionary <int, List <string> >(); if (!String.IsNullOrEmpty(includePath)) { if (System.IO.Directory.Exists(includePath)) { testCore.Options.IncludeDirectories.Add(includePath); } else { Console.WriteLine(String.Format("Path: {0} does not exist.", includePath)); } } StringReader file = new StringReader(sourceCode); WatchTestFx.GeneratePrintStatements(file, ref map); WatchTestFx fx = new WatchTestFx(); testCore = fx.TestCore; fx.CompareRunAndWatchResults("", sourceCode, map); testMirror = fx.Mirror; return(testMirror); } else { var testCore = SetupTestCore(); if (!String.IsNullOrEmpty(includePath)) { if (System.IO.Directory.Exists(includePath)) { testCore.Options.IncludeDirectories.Add(includePath); } else { Console.WriteLine(String.Format("Path: {0} does not exist.", includePath)); } } testMirror = runner.Execute(sourceCode, testCore, out compileState); SetErrorMessage(errorstring); return(testMirror); } }