Exemple #1
0
 private static void SaveP4Prefs()
 {
     settingValues = new string[settings.Length];
     envValues     = new string[settings.Length];
     for (int i = 0; i < settings.Length; i++)
     {
         settingValues[i] = P4Server.Get(settings[i]);
         // also clear the value
         P4Server.Set(settings[i], "");
     }
 }
        private void cmdThreadProc4()
        {
            try
            {
                P4Server server = serverMT.getServer();

                while (run)
                {
                    cmdCnt4++;

                    string val          = P4Server.Get("P4IGNORE");
                    bool   _p4IgnoreSet = !string.IsNullOrEmpty(val);

                    if (_p4IgnoreSet)
                    {
                        WriteLine(string.Format("P4Ignore is set, {0}", val));
                    }
                    else
                    {
                        WriteLine("P4Ignore is not set");
                    }

                    cmd4 = new P4Command(server, "fstat", false, "//depot/...");

                    DateTime StartedAt = DateTime.Now;

                    WriteLine(string.Format("Thread 4 starting command: {0:X8}, at {1}",
                                            cmd4.CommandId, StartedAt.ToLongTimeString()));

                    P4CommandResult result = cmd4.Run();

                    WriteLine(string.Format("Thread 4 Finished command: {0:X8}, at {1}, run time {2} Milliseconds",
                                            cmd4.CommandId, StartedAt.ToLongTimeString(), (DateTime.Now - StartedAt).TotalMilliseconds));

                    P4CommandResult lastResult = server.LastResults;
                    if (!result.Success)
                    {
                        string msg = string.Format("Thread 4, fstat failed:{0}", (result.ErrorList != null && result.ErrorList.Count > 0) ? result.ErrorList[0].ErrorMessage : "<unknown error>");
                        WriteLine(msg);
                        throw new Exception(msg);
                    }
                    else
                    {
                        WriteLine(string.Format("Thread 4, fstat Success:{0}", (result.InfoOutput != null && result.InfoOutput.Count > 0) ? result.InfoOutput[0].Message : "<no output>"));
                    }
                    //Assert.IsTrue(result.Success);
                    if (delay != TimeSpan.Zero)
                    {
                        Thread.Sleep(delay);
                    }
                }
                WriteLine(string.Format("Thread 4 cleanly exited after running {0} commands", cmdCnt4));
            }
            catch (ThreadAbortException)
            {
                Thread.ResetAbort();
                return;
            }
            catch (Exception ex)
            {
                WriteLine(string.Format("cmdThreadProc4 failed with exception: {0}\r\n{1}", ex.Message, ex.StackTrace));
                runThreadExeptions.Add(new RunThreadException(4, ex));
                //Assert.Fail("cmdThreadProc4 failed with exception", ex.Message);
            }
        }
Exemple #3
0
        private void cmdThreadProc4()
        {
            try
            {
                WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
                P4Server server = serverMT.getServer();
                while (run)
                {
                    using (P4Server _P4Server = new P4Server("localhost:6666", null, null, null))
                    {
                        string val          = P4Server.Get("P4IGNORE");
                        bool   _p4IgnoreSet = !string.IsNullOrEmpty(val);

                        if (_p4IgnoreSet)
                        {
                            WriteLine(string.Format("P4Ignore is set, {0}", val));
                        }
                        else
                        {
                            WriteLine("P4Ignore is not set");
                        }

                        Assert.IsTrue(_P4Server.ApiLevel > 0);
                    }
                    cmd4 = new P4Command(server, "fstat", false, "//depot/...");

                    DateTime StartedAt = DateTime.Now;

                    ReportCommandStart(cmd4, StartedAt);
                    P4CommandResult result = cmd4.Run();
                    ReportCommandStop(cmd4, StartedAt);

                    P4CommandResult lastResult = server.LastResults;

                    Assert.AreEqual(result.Success, lastResult.Success);
                    if (result.InfoOutput != null)
                    {
                        Assert.AreEqual(result.InfoOutput.Count, lastResult.InfoOutput.Count);
                    }
                    else
                    {
                        Assert.IsNull(lastResult.InfoOutput);
                    }
                    if (result.ErrorList != null)
                    {
                        Assert.AreEqual(result.ErrorList.Count, lastResult.ErrorList.Count);
                    }
                    else
                    {
                        Assert.IsNull(result.ErrorList);
                    }
                    if (result.TextOutput != null)
                    {
                        Assert.AreEqual(result.TextOutput, lastResult.TextOutput);
                    }
                    else
                    {
                        Assert.IsNull(lastResult.TextOutput);
                    }
                    if (result.TaggedOutput != null)
                    {
                        Assert.AreEqual(result.TaggedOutput.Count, lastResult.TaggedOutput.Count);
                    }
                    else
                    {
                        Assert.IsNull(lastResult.TaggedOutput);
                    }
                    Assert.AreEqual(result.Cmd, lastResult.Cmd);
                    if (result.CmdArgs != null)
                    {
                        Assert.AreEqual(result.CmdArgs.Length, lastResult.CmdArgs.Length);
                    }
                    else
                    {
                        Assert.IsNull(lastResult.CmdArgs);
                    }
                    if (!result.Success)
                    {
                        WriteLine(string.Format("Thread 4, fstat failed:{0}", (result.ErrorList != null && result.ErrorList.Count > 0)?result.ErrorList[0].ErrorMessage :"<unknown error>"));
                    }
                    else
                    {
                        WriteLine(string.Format("Thread 4, fstat Success:{0}", (result.InfoOutput != null && result.InfoOutput.Count > 0) ? result.InfoOutput[0].Message : "<no output>"));
                    }
                    if (delay != TimeSpan.Zero)
                    {
                        Thread.Sleep(delay);
                    }
                }
                WriteLine("Thread 4 cleanly exited");
            }
            catch (ThreadAbortException)
            {
                Thread.ResetAbort();
                return;
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }