Пример #1
0
 public ControlInfo(ControlScript script,
                    NetcoreDbgTestCore.Environment env)
 {
     Breakpoints        = script.Breakpoints;
     TestName           = env.TestName;
     SourceFilesPath    = env.SourceFilesPath;
     TargetAssemblyPath = env.TargetAssemblyPath;
     CorerunPath        = env.CorerunPath;
 }
Пример #2
0
        public void Run(string testCaseName, string testCourceList)
        {
            // Explicit encoding setup, since system console encoding could be not utf8 (Windows OS).
            // Note, netcoredbg aimed to interact with utf8 encoding usage only for all protocols.
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Console.InputEncoding  = System.Text.Encoding.UTF8;

            string testSuiteRoot = Path.GetFullPath(
                Path.Combine(Directory.GetCurrentDirectory(), "../../../..")
                );

            var Env = new NetcoreDbgTestCore.Environment();

            Env.TestName = testCaseName;

            string[] testFileArray = testCourceList.Split(";");
            foreach (var FileName in testFileArray)
            {
                Env.SourceFilesPath += Path.Combine(testSuiteRoot, testCaseName, FileName + ";");
            }
            Env.SourceFilesPath = Env.SourceFilesPath.Remove(Env.SourceFilesPath.Length - 1);

            Env.TargetAssemblyPath = Path.Combine(testSuiteRoot,
                                                  testCaseName + "/bin/Debug/netcoreapp3.1/",
                                                  testCaseName + ".dll");
            string fullDebuggerPath = Path.GetFullPath(Path.Combine(testSuiteRoot, DebuggerPath));

            if (testCaseName.StartsWith("MI"))
            {
                LocalDebugger = new LocalDebuggerProcess(fullDebuggerPath, @" --interpreter=mi");
                LocalDebugger.Start();
                DebuggerClient = new MILocalDebuggerClient(LocalDebugger.Input,
                                                           LocalDebugger.Output);
            }
            else if (testCaseName.StartsWith("VSCode"))
            {
                LocalDebugger = new LocalDebuggerProcess(fullDebuggerPath, @" --interpreter=vscode");
                LocalDebugger.Start();
                DebuggerClient = new VSCodeLocalDebuggerClient(LocalDebugger.Input,
                                                               LocalDebugger.Output);
            }
            else
            {
                throw new System.Exception();
            }

            Xunit.Assert.True(DebuggerClient.DoHandshake(5000));

            var Script = new ControlScript(Env.SourceFilesPath, DebuggerClient.Protocol);

            new ControlPart().Run(Script, DebuggerClient, Env);
        }
Пример #3
0
        public void Run(string testCaseName, string testCourceList)
        {
            string testSuiteRoot = Path.GetFullPath(
                Path.Combine(Directory.GetCurrentDirectory(), "../../../..")
                );

            var Env = new NetcoreDbgTestCore.Environment();

            Env.TestName = testCaseName;

            string[] testFileArray = testCourceList.Split(";");
            foreach (var FileName in testFileArray)
            {
                Env.SourceFilesPath += Path.Combine(testSuiteRoot, testCaseName, FileName + ";");
            }
            Env.SourceFilesPath = Env.SourceFilesPath.Remove(Env.SourceFilesPath.Length - 1);

            Env.TargetAssemblyPath = Path.Combine(testSuiteRoot,
                                                  testCaseName + "/bin/Debug/netcoreapp3.1/",
                                                  testCaseName + ".dll");
            string fullDebuggerPath = Path.GetFullPath(Path.Combine(testSuiteRoot, DebuggerPath));

            if (testCaseName.StartsWith("MI"))
            {
                LocalDebugger = new LocalDebuggerProcess(fullDebuggerPath, @" --interpreter=mi");
                LocalDebugger.Start();
                DebuggerClient = new MILocalDebuggerClient(LocalDebugger.Input,
                                                           LocalDebugger.Output);
            }
            else if (testCaseName.StartsWith("VSCode"))
            {
                LocalDebugger = new LocalDebuggerProcess(fullDebuggerPath, @" --interpreter=vscode");
                LocalDebugger.Start();
                DebuggerClient = new VSCodeLocalDebuggerClient(LocalDebugger.Input,
                                                               LocalDebugger.Output);
            }
            else
            {
                throw new System.Exception();
            }

            Xunit.Assert.True(DebuggerClient.DoHandshake(200));

            var Script = new DebuggeeScript(Env.SourceFilesPath, DebuggerClient.Protocol);

            Debuggee.Run(Script, DebuggerClient, Env);
        }
Пример #4
0
        public CLInterface(string[] args)
        {
            Environment = new NetcoreDbgTestCore.Environment();

            if (args.Length == 0)
            {
                NeedHelp = true;
                return;
            }

            if (args.Length == 1 && (args[0] == "-h" || args[0] == "--help"))
            {
                NeedHelp = true;
                return;
            }

            int i = 0;

            while (i < args.Length && !NeedHelp)
            {
                switch (args[i])
                {
                case "--tcp":
                    if (i + 2 >= args.Length)
                    {
                        NeedHelp = true;
                        break;
                    }

                    try {
                        ClientInfo = new TcpClientInfo(args[i + 1],
                                                       args[i + 2]);
                    }
                    catch {
                        NeedHelp = true;
                        break;
                    }
                    i += 3;

                    break;

                case "--local":
                    if (i + 1 >= args.Length)
                    {
                        NeedHelp = true;
                        break;
                    }

                    try {
                        string debuggerPath = Path.GetFullPath(args[i + 1]);
                        ClientInfo = new LocalClientInfo(debuggerPath);
                    }
                    catch {
                        NeedHelp = true;
                        break;
                    }
                    i += 2;

                    break;

                case "--proto":
                    if (i + 1 >= args.Length)
                    {
                        NeedHelp = true;
                        break;
                    }

                    switch (args[i + 1])
                    {
                    case "mi":
                        Protocol = ProtocolType.MI;
                        break;

                    case "vscode":
                        Protocol = ProtocolType.VSCode;
                        break;

                    default:
                        Protocol = ProtocolType.None;
                        break;
                    }
                    i += 2;

                    break;

                case "--test":
                    if (i + 2 >= args.Length)
                    {
                        NeedHelp = true;
                        break;
                    }

                    try {
                        Environment.TestName = args[i + 1];
                    }
                    catch {
                        NeedHelp = true;
                        break;
                    }

                    i += 2;

                    break;

                case "--sources":
                    if (i + 1 >= args.Length)
                    {
                        NeedHelp = true;
                        break;
                    }

                    try {
                        Environment.SourceFilesPath = Path.GetFullPath(args[i + 1]);
                        if (Environment.SourceFilesPath[Environment.SourceFilesPath.Length - 1] == ';')
                        {
                            Environment.SourceFilesPath =
                                Environment.SourceFilesPath.Remove(Environment.SourceFilesPath.Length - 1);
                        }
                    }
                    catch {
                        NeedHelp = true;
                        break;
                    }

                    i += 2;

                    break;

                case "--assembly":
                    if (i + 1 >= args.Length)
                    {
                        NeedHelp = true;
                        break;
                    }

                    Environment.TargetAssemblyPath = args[i + 1];

                    i += 2;

                    break;

                case "--dotnet":
                    if (i + 1 >= args.Length)
                    {
                        NeedHelp = true;
                    }

                    try {
                        Path.GetFullPath(args[i + 1]);
                    }
                    catch {
                        NeedHelp = true;
                        break;
                    }

                    Environment.CorerunPath = args[i + 1];

                    i += 2;

                    break;

                default:
                    NeedHelp = true;
                    break;
                }
            }

            if (ClientInfo != null &&
                ClientInfo.Type == ClientType.Local &&
                !File.Exists(Environment.TargetAssemblyPath))
            {
                Console.Error.WriteLine("Provided assembly path is invalid");
                throw new System.Exception();
            }

            if (NeedHelp)
            {
                return;
            }
        }