Exemplo n.º 1
0
        /// <summary>
        /// Creates the coverage report from the xml coverage files spécified.
        /// </summary>
        /// <param name="sources">The sources XML files.</param>
        /// <param name="destination">The destination directory.</param>
        /// <param name="logger">The logger.</param>
        public static void CreateReport(IList <string> sources, string destination, ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            if (sources == null || sources.Count == 0)
            {
                return;
            }

            if (String.IsNullOrEmpty(destination))
            {
                throw new ArgumentException("Destination must be a valid path.", "destination");
            }

            if (Directory.Exists(destination))
            {
                Directory.Delete(destination, true);
            }

            ProcessTask mergeTask = CreateMergeTask(sources, destination);

            logger.Log(LogSeverity.Info, string.Format("Genrating {0} coverage report to '{1}': \"{2}\" {3}", Name, destination, mergeTask.ExecutablePath, mergeTask.Arguments));

            mergeTask.CaptureConsoleOutput       = true;
            mergeTask.ConsoleOutputDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    logger.Log(LogSeverity.Info, e.Data);
                }
            };

            mergeTask.CaptureConsoleError       = true;
            mergeTask.ConsoleErrorDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    logger.Log(LogSeverity.Error, e.Data);
                }
            };

            if (!mergeTask.Run(null))
            {
                throw new PartCoverToolException(string.Format("Failed to generate {0} coverage report.  The report command failed with exit code {1}.", Name, mergeTask.ExitCode));
            }

            int i = 0;

            foreach (string source in sources)
            {
                if (!string.IsNullOrEmpty(source) && File.Exists(source))
                {
                    i++;
                    File.Move(source, Path.Combine(destination, String.Format("coverage_{0:D4}.xml", i)));
                }
            }
        }
 public void EchoDoesNotTerminateAbruptlyOnUnhandledExceptions()
 {
     ProcessTask task = RunEcho("/ignore-annotations /filter:Type:UnhandledExceptionTest");
     Assert.Contains(task.ConsoleOutput, "2 run, 2 passed, 0 failed, 0 inconclusive, 0 skipped");
     Assert.Contains(task.ConsoleOutput, "Unhandled!");
     Assert.AreEqual(0, task.ExitCode,  "Exit code should be zero because the unhandled exception test still passes.");
 }
        public void CacheProvider_NoPipeline()
        {
            var pt1 = new ProcessTask(CatalogueRepository, _lmd, LoadStage.GetFiles);

            pt1.Path            = typeof(TestCachedFileRetriever).FullName;
            pt1.ProcessTaskType = ProcessTaskType.DataProvider;
            pt1.Name            = "Cache1";
            pt1.SaveToDatabase();

            _cp.CacheFillProgress = new DateTime(1999, 1, 1);
            _cp.Name = "MyTestCp";
            _cp.SaveToDatabase();

            pt1.CreateArgumentsForClassIfNotExists <TestCachedFileRetriever>();

            var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", true);

            _lmd.LocationOfFlatFiles = projDir.RootPath.FullName;
            _lmd.SaveToDatabase();
            try
            {
                var ex = Assert.Throws <Exception>(() => _factory.Create(_lp, new ThrowImmediatelyDataLoadEventListener()));
                Assert.AreEqual("CacheProgress MyTestCp does not have a Pipeline configured on it", ex.Message);
            }
            finally
            {
                projDir.RootPath.Delete(true);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Run the application.
        /// </summary>
        public void Run()
        {
            Privilege.IsAdmin();
            if (Privilege.IsAdmin() == false)
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    try
                    {
                        Privilege.RelaunchAsAdmin("");
                    } catch (Exception ex)
                    {
                        ConsoleStyle.ErrorMessage(ex.Message);
                        Environment.Exit(5);
                    }
                }
                else
                {
                    ConsoleStyle.ErrorMessage("Administrator privileges are required!");
                    Environment.Exit(403);
                }
            }

            // display program header.
            ConsoleStyle.ProgramHeader();

            // start to kill php processes.
            var processTask = new ProcessTask();

            processTask.killPHP();

            // success message and exit.
            ConsoleStyle.SuccessExit();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Starts a new process and begins watching it.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The output of the process will be logged and included as part of the test results.  It
        /// may also be examined using the <see cref="ProcessTask.ConsoleOutput" /> and
        /// <see cref="ProcessTask.ConsoleError" /> properties while the process executes and
        /// after it terminates.
        /// </para>
        /// <para>
        /// There is no need to call <see cref="WatchTask" /> on the returned task.
        /// </para>
        /// </remarks>
        /// <param name="executablePath">The path of the executable executable.</param>
        /// <param name="arguments">The arguments for the executable.</param>
        /// <param name="workingDirectory">The working directory.</param>
        /// <returns>The new thread task.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="executablePath"/>,
        /// <paramref name="arguments"/> or <paramref name="workingDirectory"/> is null.</exception>
        public static ProcessTask StartProcessTask(string executablePath, string arguments, string workingDirectory)
        {
            ProcessTask task = CreateProcessTask(executablePath, arguments, workingDirectory);

            task.Start();
            return(task);
        }
Exemplo n.º 6
0
        private static ProcessTask RunMSTest(string options)
        {
            string value = (string)RegistryUtils.GetValueWithBitness(
                ProcessorArchitecture.X86, RegistryHive.LocalMachine,
                @"Software\Microsoft\VisualStudio\9.0",
                "InstallDir", null);

            if (value == null)
            {
                Assert.Inconclusive("Visual Studio 2008 does not appear to be installed.");
            }

            string executablePath = Path.Combine(value, "MSTest.exe");

            if (!File.Exists(executablePath))
            {
                Assert.Inconclusive("Visual Studio 2008 appears to be installed but MSTest.exe was not found.");
            }

            string testAssemblyPath = AssemblyUtils.GetAssemblyLocalPath(typeof(SimpleTest).Assembly);
            string workingDirectory = Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(GallioTipIntegrationTest).Assembly));

            ProcessTask task = Tasks.StartProcessTask(executablePath,
                                                      "\"/testcontainer:" + testAssemblyPath + "\" " + options,
                                                      workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return(task);
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        public IVisualStudio LaunchVisualStudio(VisualStudioVersion version, ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            Pair <string, VisualStudioVersion>?installDirAndVersion = GetVisualStudioInstallDirAndVersion(version);

            if (!installDirAndVersion.HasValue)
            {
                logger.Log(LogSeverity.Debug, string.Format("Could not find Visual Studio version '{0}'.", version));
                return(null);
            }

            string      devenvPath        = Path.Combine(installDirAndVersion.Value.First, "devenv.exe");
            ProcessTask devenvProcessTask = new ProcessTask(devenvPath, "", Environment.CurrentDirectory);

            logger.Log(LogSeverity.Debug, string.Format("Launching Visual Studio using path: '{0}'.", devenvProcessTask.ExecutablePath));
            devenvProcessTask.Start();

            System.Diagnostics.Process devenvProcess = devenvProcessTask.Process;
            if (devenvProcess != null)
            {
                int processId = devenvProcess.Id;

                Stopwatch stopwatch = Stopwatch.StartNew();
                for (;;)
                {
                    IVisualStudio visualStudio = GetVisualStudioFromProcess(processId, installDirAndVersion.Value.Second, true, logger);
                    if (visualStudio != null)
                    {
                        return(visualStudio);
                    }

                    if (stopwatch.ElapsedMilliseconds > VisualStudioAttachTimeoutMilliseconds)
                    {
                        logger.Log(LogSeverity.Debug, string.Format("Stopped waiting for Visual Studio to launch after {0} milliseconds.", VisualStudioAttachTimeoutMilliseconds));
                        break;
                    }

                    if (!devenvProcessTask.IsRunning)
                    {
                        break;
                    }

                    Thread.Sleep(500);
                }
            }

            if (devenvProcessTask.IsTerminated && devenvProcessTask.Result != null)
            {
                if (!devenvProcessTask.Result.HasValue)
                {
                    logger.Log(LogSeverity.Debug, "Failed to launch Visual Studio.", devenvProcessTask.Result.Exception);
                }
            }

            return(null);
        }
        public void EchoPrintsCorrectOutputForPassingAndFailingTestsAndReturnsAnExitCodeOfOne()
        {
            ProcessTask task = RunEcho("/ignore-annotations /filter:Type:SimpleTest");

            Assert.Contains(task.ConsoleOutput, "2 run, 1 passed, 1 failed, 0 inconclusive, 0 skipped");
            Assert.AreEqual(1, task.ExitCode, "Exit code for failing tests should be one.");
        }
Exemplo n.º 9
0
        public GitInstallationState ValidateGitLfsVersion(GitInstallationState state)
        {
            // default installation doesn't have a standalone "git-lfs" exe
            if (state.GitInstallationPath == installDetails.GitInstallationPath)
            {
                state.GitLfsIsValid = true;
                state.GitLfsVersion = state.GitVersion;
                return(state);
            }

            if (!state.GitLfsExecutablePath.IsInitialized || !state.GitLfsExecutablePath.FileExists())
            {
                state.GitLfsIsValid = false;
                return(state);
            }

            var version = new ProcessTask <TheVersion>(Token, state.GitLfsExecutablePath, "version", new LfsVersionOutputProcessor())
                          .Configure(processManager)
                          .Progress(progressReporter.UpdateProgress)
                          .Catch(e => true)
                          .RunSynchronously();

            state.GitLfsIsValid = version >= Constants.MinimumGitLfsVersion;
            state.GitLfsVersion = version;
            return(state);
        }
Exemplo n.º 10
0
        public void CreateTask()
        {
            _lmd = new LoadMetadata(CatalogueRepository);

            _dir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "ProcessTaskCheckingTests"));
            _dir.Create();

            var hicdir = LoadDirectory.CreateDirectoryStructure(_dir, "ProjDir", true);

            _lmd.LocationOfFlatFiles = hicdir.RootPath.FullName;
            _lmd.SaveToDatabase();

            Catalogue     c  = new Catalogue(CatalogueRepository, "c");
            CatalogueItem ci = new CatalogueItem(CatalogueRepository, c, "ci");
            TableInfo     t  = new TableInfo(CatalogueRepository, "t");

            t.Server   = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name;
            t.Database = "mydb";
            t.SaveToDatabase();
            ColumnInfo col = new ColumnInfo(CatalogueRepository, "col", "bit", t);

            ci.SetColumnInfo(col);
            c.LoadMetadata_ID = _lmd.ID;
            c.SaveToDatabase();

            _task    = new ProcessTask(CatalogueRepository, _lmd, LoadStage.GetFiles);
            _checker = new ProcessTaskChecks(_lmd);
        }
Exemplo n.º 11
0
        public void StartLongRunningProcess(string id, int PaypalApi, string RangeDate)
        {
            longRunningClass.Add(id);
            ProcessTask processTask = new ProcessTask(longRunningClass.ProcessLongRunningAction);

            processTask.BeginInvoke(id, PaypalApi, RangeDate, new AsyncCallback(EndLongRunningProcess), processTask);
        }
        public void CmdletPrintsCorrectOutputForPassingAndFailingTestsAndReturnsAResultCodeOfOne()
        {
            ProcessTask task = RunPowerShell("-verbose -filter Type:SimpleTest -ignore-annotations");

            Assert.Contains(task.ConsoleOutput, "2 run, 1 passed, 1 failed, 0 inconclusive, 0 skipped");
            Assert.Like(task.ConsoleOutput, "ResultCode *: 1");
        }
Exemplo n.º 13
0
        public void OneTimeSetup()
        {
            Logging.LogAdapter = new ConsoleLogAdapter();
            //Logging.TracingEnabled = true;
            TaskManager = new TaskManager();
            var syncContext = new ThreadSynchronizationContext(Token);

            TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext);

            var env = new DefaultEnvironment();

            TestBasePath = NPath.CreateTempDirectory("integration-tests");
            env.FileSystem.SetCurrentDirectory(TestBasePath);

            var repo = Substitute.For <IRepository>();

            repo.LocalPath.Returns(TestBasePath);
            env.Repository = repo;

            var platform = new Platform(env);

            ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token);
            var processEnv = platform.GitEnvironment;
            var path       = new ProcessTask <NPath>(TaskManager.Token, new FirstLineIsPathOutputProcessor())
                             .Configure(ProcessManager, env.IsWindows ? "where" : "which", "git")
                             .Start().Result;

            env.GitExecutablePath = path ?? "git".ToNPath();
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates a <see cref="AnySeparatorFileAttacher"/> parcelled into a <see cref="ProcessTask"/> that reads CSV files in ForLoading
        /// in the mounting stage of the load
        /// </summary>
        /// <param name="lmd">The load to create the <see cref="ProcessTask"/> in</param>
        /// <param name="pattern">File pattern to load e.g. *.csv</param>
        /// <param name="ti">The table to load (must be part of the <paramref name="lmd"/></param>
        /// <param name="separator">The separator of the files e.g. ','</param>
        /// <param name="ignoreColumns">Columns to ignore in the load</param>
        /// <returns></returns>
        protected ProcessTask CreateFlatFileAttacher(LoadMetadata lmd, string pattern, ITableInfo ti, string separator = ",", string ignoreColumns = "hic_dataLoadRunID")
        {
            var csvProcessTask = new ProcessTask(CatalogueRepository, lmd, LoadStage.Mounting);
            var args           = csvProcessTask.CreateArgumentsForClassIfNotExists <AnySeparatorFileAttacher>();

            csvProcessTask.Path            = typeof(AnySeparatorFileAttacher).FullName;
            csvProcessTask.ProcessTaskType = ProcessTaskType.Attacher;
            csvProcessTask.SaveToDatabase();

            var filePattern = args.Single(a => a.Name == "FilePattern");

            filePattern.SetValue(pattern);
            filePattern.SaveToDatabase();

            var tableToLoad = args.Single(a => a.Name == "TableToLoad");

            tableToLoad.SetValue(ti);
            tableToLoad.SaveToDatabase();

            var separatorArg = args.Single(a => a.Name == "Separator");

            separatorArg.SetValue(separator);
            separatorArg.SaveToDatabase();

            var ignoreDataLoadRunIDCol = args.Single(a => a.Name == "IgnoreColumns");

            ignoreDataLoadRunIDCol.SetValue(ignoreColumns);
            ignoreDataLoadRunIDCol.SaveToDatabase();

            return(csvProcessTask);
        }
Exemplo n.º 15
0
        public async Task RunAsync_RaisesOutputEvent()
        {
            //Arrange
            using (var tempFile = new TemporaryFile("bat"))
            {
                var batchScript = @"
                    @echo off
                    ECHO TestOutput
                    EXIT /B 0
                ";

                File.WriteAllText(tempFile.FileName, batchScript);

                var processTask = new ProcessTask(tempFile.FileName, cancellationToken);
                processTask.OutputReceived += (sender, args) => {
                    var e = args as DataReceivedEventArgs;
                    Assert.IsNotNull(e);

                    if (e.Data != null)
                    {
                        Assert.AreEqual("TestOutput", e.Data);
                    }
                };

                //Act
                var result = await processTask.RunAsync();

                //Assert
                Assert.AreEqual(0, result);
            }
        }
        public void EchoPrintsCorrectOutputForPassingTestsAndReturnsAnExitCodeOfZero()
        {
            ProcessTask task = RunEcho("/ignore-annotations /filter:Type:PassingTests");

            Assert.Contains(task.ConsoleOutput, "2 run, 2 passed, 0 failed, 0 inconclusive, 0 skipped");
            Assert.AreEqual(0, task.ExitCode, "Exit code for passing tests should be zero.");
        }
Exemplo n.º 17
0
        public async Task RunAsync_CallsGlobalApplication()
        {
            //Arrange
            var outputWritten = false;
            var startInfo     = new ProcessStartInfo()
            {
                FileName               = "dir",
                WindowStyle            = ProcessWindowStyle.Hidden,
                UseShellExecute        = false,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                CreateNoWindow         = false,
            };
            var processTask = new ProcessTask(startInfo, cancellationToken);

            processTask.OutputReceived += (sender, args) => {
                var e = args as DataReceivedEventArgs;
                Assert.IsNotNull(e);

                if (e.Data != null)
                {
                    outputWritten = true;
                }
                Console.WriteLine(e.Data);
            };

            //Act
            var result = await processTask.RunAsync();

            //Assert
            Assert.AreEqual(0, result);
            Assert.IsTrue(outputWritten);
        }
        public void TaskSupportsCustomExtensions()
        {
            ProcessTask task = RunNAnt("Extensions");

            Assert.Contains(task.ConsoleOutput, "TestStepStarted"); // text appears in the debug output
            Assert.AreEqual(0, task.ExitCode);
        }
Exemplo n.º 19
0
        private void AddMenu <T>(string menuName, Func <Type, bool> filterTypes)
        {
            var types = _mef.GetTypes <T>().Where(filterTypes).ToArray();
            var menu  = new ToolStripMenuItem(menuName);

            ProcessTaskType taskType;

            if (typeof(T) == typeof(IDataProvider))
            {
                taskType = ProcessTaskType.DataProvider;
            }
            else
            if (typeof(T) == typeof(IAttacher))
            {
                taskType = ProcessTaskType.Attacher;
            }
            else if (typeof(T) == typeof(IMutilateDataTables))
            {
                taskType = ProcessTaskType.MutilateDataTable;
            }
            else
            {
                throw new ArgumentException("Type '" + typeof(T) + "' was not expected", "T");
            }

            foreach (Type type in types)
            {
                Type toAdd = type;
                menu.DropDownItems.Add(type.Name, null, (s, e) => AddTypeIntoStage(toAdd, taskType));
            }

            menu.Enabled = ProcessTask.IsCompatibleStage(taskType, _loadStageNode.LoadStage) && types.Any();

            Items.Add(menu);
        }
Exemplo n.º 20
0
        public override void Execute()
        {
            if (_type == null)
            {
                if (BasicActivator.SelectType("Process Type", GetProcessTaskTypes(), out Type chosen))
                {
                    SetType(chosen);
                }
                else
                {
                    return;
                }
            }

            ProcessTask newTask = new ProcessTask(BasicActivator.RepositoryLocator.CatalogueRepository, _loadMetadata, _loadStage);

            newTask.Path            = _type.FullName;
            newTask.ProcessTaskType = _processTaskType;
            newTask.Name            = _type.Name;
            newTask.SaveToDatabase();

            newTask.CreateArgumentsForClassIfNotExists(_type);

            Publish(_loadMetadata);
            Activate(newTask);
        }
        public void AmbienceServerRunsWithSpecifiedOptions()
        {
            File.Delete("IntegrationTest.db");

            ProcessTask task = StartAmbienceServer("/db:IntegrationTest.db /p:" + PortNumber + " /u:Test /pw:LetMeIn");

            var config = new AmbienceClientConfiguration()
            {
                Port       = PortNumber,
                Credential = new NetworkCredential("Test", "LetMeIn")
            };

            AmbienceClient        client    = AmbienceClient.Connect(config);
            IAmbientDataContainer container = client.Container;

            container.DeleteAll();

            container.Store(new Item()
            {
                Name = "foo", Value = 42
            });
            container.Store(new Item()
            {
                Name = "bar", Value = 40
            });

            Assert.AreEqual("foo", (from Item x in container where x.Value == 42 select x.Name).Single());
            Assert.AreEqual(0, (from Item x in container where x.Value == 0 select x).Count());

            task.Abort();
        }
Exemplo n.º 22
0
        protected override void SetBindings(BinderWithErrorProviderFactory rules, ProcessTask databaseObject)
        {
            base.SetBindings(rules, databaseObject);

            Bind(tbName, "Text", "Name", d => d.Name);
            Bind(tbID, "Text", "ID", d => d.ID);
        }
        /// <summary>
        /// Ends the long running process.
        /// </summary>
        /// <param name="result">The result.</param>
        public void EndLongRunningProcess(IAsyncResult result)
        {
            ProcessTask processTask = (ProcessTask)result.AsyncState;
            string      id          = processTask.EndInvoke(result);

            longRunningClass.Remove(id);
        }
        public void CacheProvider_NoCacheProgress()
        {
            var pt1 = new ProcessTask(CatalogueRepository, _lmd, LoadStage.GetFiles);

            pt1.Path            = typeof(BasicCacheDataProvider).FullName;
            pt1.ProcessTaskType = ProcessTaskType.DataProvider;
            pt1.Name            = "Cache1";
            pt1.SaveToDatabase();

            var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", true);

            _lmd.LocationOfFlatFiles = projDir.RootPath.FullName;
            _lmd.SaveToDatabase();

            var pipeAssembler = new TestDataPipelineAssembler("CacheProvider_Normal", CatalogueRepository);

            pipeAssembler.ConfigureCacheProgressToUseThePipeline(_cp);

            try
            {
                var ex = Assert.Throws <InvalidOperationException>(() => _factory.Create(_lp, new ThrowImmediatelyDataLoadEventListener()));
                Assert.AreEqual("Caching has not begun for this CacheProgress (" + _cp.ID + "), so there is nothing to load and this strategy should not be used.", ex.Message);
            }
            finally
            {
                _cp.Pipeline_ID = null;
                pipeAssembler.Destroy();
                projDir.RootPath.Delete(true);
            }
        }
Exemplo n.º 25
0
        private static void tryDispatch(string tag)
        {
            lock (endequeueCS)
            {
                if (!queues.ContainsKey(tag) || queues[tag].Count == 0)
                {
                    return;
                }

                if (runningTask.ContainsKey(tag) && !runningTask[tag].task.IsCompleted)
                {
                    return;
                }

                var taskInfo = queues[tag].First.Value;
                queues[tag].RemoveFirst();

                var cts = new CancellationTokenSource();

                var newTask = new ProcessTask
                {
                    queueid    = taskInfo.queueid,
                    cancelable = taskInfo.cancelable,
                    task       = Task.Run(() => { taskInfo.task(); tryDispatch(tag); }, cts.Token),
                    cts        = cts
                };

                runningTask[tag] = newTask;
            }
        }
Exemplo n.º 26
0
        public int InitializeProcess(int id)
        {
            Guid processGuid = _context.Processes.Where(p => p.Id == id).FirstOrDefault().ProcessGuid;

            ProcessTask ptStarter = new ProcessTask();

            ptStarter.ProcessTaskGuid = Guid.NewGuid();
            ptStarter.ProcessGuid     = processGuid;
            ptStarter.TaskName        = "Process Start";
            ptStarter.TaskTypeId      = 5;
            ptStarter.CreatedDate     = DateTime.Now;
            ptStarter.CompletionTask  = 1;
            ptStarter.DeletedDate     = null;

            ProcessTask ptEnder = new ProcessTask();

            ptEnder.ProcessTaskGuid = Guid.NewGuid();
            ptEnder.ProcessGuid     = processGuid;
            ptEnder.TaskName        = "Process End";
            ptEnder.TaskTypeId      = 6;
            ptEnder.CreatedDate     = DateTime.Now;
            ptEnder.CompletionTask  = 1;
            ptEnder.DeletedDate     = null;

            _context.ProcessTasks.Add(ptStarter);
            _context.ProcessTasks.Add(ptEnder);

            _context.SaveChanges();

            return(id);
        }
Exemplo n.º 27
0
        public ExecuteCommandCreateNewProcessTask(IActivateItems activator, ProcessTaskType taskType, LoadMetadata loadMetadata, LoadStage loadStage, FileInfo file = null) : base(activator)
        {
            _taskType     = taskType;
            _loadMetadata = loadMetadata;
            _loadStage    = loadStage;

            try
            {
                _LoadDirectory = new LoadDirectory(_loadMetadata.LocationOfFlatFiles);
            }
            catch (Exception)
            {
                SetImpossible("Could not construct LoadDirectory");
            }

            if (taskType == ProcessTaskType.SQLFile)
            {
                _image = activator.CoreIconProvider.GetImage(RDMPConcept.SQL, OverlayKind.Add);
            }
            else if (taskType == ProcessTaskType.Executable)
            {
                _image = new IconOverlayProvider().GetOverlayNoCache(CatalogueIcons.Exe, OverlayKind.Add);
            }
            else
            {
                SetImpossible("Only SQLFile and Executable task types are supported by this command");
            }

            if (!ProcessTask.IsCompatibleStage(taskType, loadStage))
            {
                SetImpossible("You cannot run " + taskType + " in " + loadStage);
            }

            _file = file;
        }
Exemplo n.º 28
0
        public void OneTimeSetup()
        {
            GitHub.Unity.Guard.InUnitTestRunner = true;
            LogHelper.LogAdapter = new MultipleLogAdapter(new FileLogAdapter($"..\\{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}-tasksystem-tests.log"));
            //LogHelper.TracingEnabled = true;
            TaskManager = new TaskManager();
            var syncContext = new ThreadSynchronizationContext(Token);

            TaskManager.UIScheduler = new SynchronizationContextTaskScheduler(syncContext);

            var env = new DefaultEnvironment();

            TestBasePath = NPath.CreateTempDirectory("integration-tests");
            env.FileSystem.SetCurrentDirectory(TestBasePath);

            var repo = Substitute.For <IRepository>();

            repo.LocalPath.Returns(TestBasePath);
            env.Repository = repo;

            var platform = new Platform(env);

            ProcessManager = new ProcessManager(env, platform.GitEnvironment, Token);
            var processEnv = platform.GitEnvironment;
            var path       = new ProcessTask <NPath>(TaskManager.Token, new FirstLineIsPathOutputProcessor())
                             .Configure(ProcessManager, env.IsWindows ? "where" : "which", "git")
                             .Start().Result;

            env.GitExecutablePath = path.IsInitialized ? path : "git".ToNPath();
        }
Exemplo n.º 29
0
        private void CreateAttacher(ITableInfo t, QueryBuilder qb, LoadMetadata lmd, LoadProgress loadProgressIfAny)
        {
            var pt = new ProcessTask(Activator.RepositoryLocator.CatalogueRepository, lmd, LoadStage.Mounting);

            pt.ProcessTaskType = ProcessTaskType.Attacher;
            pt.Name            = "Read from " + t;
            pt.Path            = typeof(RemoteTableAttacher).FullName;
            pt.SaveToDatabase();

            pt.CreateArgumentsForClassIfNotExists <RemoteTableAttacher>();


            pt.SetArgumentValue("RemoteServer", t.Server);
            pt.SetArgumentValue("RemoteDatabaseName", t.GetDatabaseRuntimeName(LoadStage.PostLoad));
            pt.SetArgumentValue("RemoteTableName", t.GetRuntimeName());
            pt.SetArgumentValue("DatabaseType", DatabaseType.MicrosoftSQLServer);
            pt.SetArgumentValue("RemoteSelectSQL", qb.SQL);

            pt.SetArgumentValue("RAWTableName", t.GetRuntimeName(LoadBubble.Raw));

            if (loadProgressIfAny != null)
            {
                pt.SetArgumentValue("Progress", loadProgressIfAny);
//              pt.SetArgumentValue("ProgressUpdateStrategy", DataLoadProgressUpdateStrategy.UseMaxRequestedDay);
                pt.SetArgumentValue("LoadNotRequiredIfNoRowsRead", true);
            }

            /*
             *
             *  public DataLoadProgressUpdateInfo { get; set; }
             */
        }
 public void EchoDoesNotShowLogoAndReturnsAnExitCodeOfZero()
 {
     ProcessTask task = RunEcho("/no-logo");
     Assert.DoesNotContain(task.ConsoleOutput,"Gallio Echo - Version ");
     Assert.DoesNotContain(task.ConsoleOutput, "Get the latest version at http://www.gallio.org");
     Assert.AreEqual(1, task.ExitCode, "Exit code with no tests should be one.");
 }
Exemplo n.º 31
0
 public void StartProcessing(string id)
 {
     this.Add(id);
     ProcessTask processTask = new ProcessTask(this.ProcessLongRunningAction);
     processTask.BeginInvoke(id, new AsyncCallback(this.EndLongRunningProcess), processTask);
 }