예제 #1
0
        /// <summary>
        /// Generates a list of variables to watch. Runs the code and verifies the results against the generated watch list
        /// Verifies the results against a list
        /// </summary>
        /// <param name="code"></param>
        /// <param name="verification"></param>
        private void RunDebugWatch(string code)
        {
            Dictionary <int, List <string> > map = new Dictionary <int, List <string> >();

            WatchTestFx.GeneratePrintStatements(code, ref map);
            WatchTestFx fx = new WatchTestFx();

            fx.CompareRunAndWatchResults(null, code, map);
        }
예제 #2
0
        public void T003_Defect_1467629_Debugging_InlineCondition_With_Multiple_Return_Types()
        {
            Dictionary <int, List <string> > map = new Dictionary <int, List <string> >();

            String filePath = @"..\..\..\Scripts\TD\DebugTests\T003_Defect_1467629_Debugging_InlineCondition_With_Multiple_Return_Types.ds";

            StreamReader file = new StreamReader(filePath);

            WatchTestFx.GeneratePrintStatements(file, ref map);

            file = new StreamReader(filePath);

            String src = file.ReadToEnd();

            file.Close();

            WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(Path.GetFullPath(filePath), src, map);
        }
예제 #3
0
        public ExecutionMirror RunScriptFile(string directory, string filename)
        {
            string currentFile = filename;
            string errorString = "";

            if (testImport)
            {
                currentFile = Path.GetFileName(filename);
                string fileToRun  = Path.GetFileNameWithoutExtension(currentFile) + "_Import.ds";
                string importCode = string.Format("import(\"{0}\");", currentFile);
                directory = Path.Combine(directory, filename);
                directory = Path.GetDirectoryName(directory) + @"\";
                createDSFile(fileToRun, directory, importCode);
                errorString = "tested as import file";
            }


            else if (testDebug)
            {
                Dictionary <int, List <string> > map = new Dictionary <int, List <string> >();
                string     fname = Path.Combine(directory, filename);
                TextReader file  = new StreamReader(fname);
                WatchTestFx.GeneratePrintStatements(file, ref map);
                file = new StreamReader(fname);
                String src = file.ReadToEnd();
                file.Close();

                WatchTestFx fx = new WatchTestFx();
                testCore = fx.TestCore;

                fx.CompareRunAndWatchResults(Path.GetFullPath(filename), src, map);
                testMirror = fx.Mirror;

                return(testMirror);
            }

            string dsFullPathName = directory + currentFile;

            return(RunScript(dsFullPathName, errorString));
        }
예제 #4
0
        /// <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 = "")
        {
            sourceCode = sourceCode.Insert(0, "import(\"Builtin.dll\");");

            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));
                    }
                }
                testRuntimeCore = runner.Execute(sourceCode, testCore);
                testMirror      = testRuntimeCore.Mirror;

                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);
            }
        }
예제 #5
0
        /// <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);
            }
        }