private static void tryToStart(ISystem system)
        {
            try
            {
                var running = RunningSystem.Create(system);
                if (running.RecycledMessage.success)
                {
                    Console.WriteLine("Able to create the FixtureLibrary");
                }

                var json = JsonSerialization.ToCleanJson(running.RecycledMessage);

                Console.WriteLine("System ready as: " + json);

                Console.WriteLine("Trying the Warmup now...");

                var warmup = running.System.Warmup();

                warmup.Wait(1.Minutes());

                if (warmup.IsCompleted)
                {
                    ConsoleWriter.Write(ConsoleColor.Green, "StorytellerAgent started without any exceptions");
                }
            }
            catch (Exception e)
            {
                LogFailure(e);

                ConsoleWriter.Write(ConsoleColor.Red, "StorytellerAgent startup failed!");
                ConsoleWriter.Write(ConsoleColor.Yellow, e.ToString());
            }
        }
Esempio n. 2
0
        public override bool Execute(StorytellerInput input)
        {
            if (!Directory.Exists(input.FixturePath))
            {
                Console.WriteLine("Creating directory " + input.FixturePath);
                Directory.CreateDirectory(input.FixturePath);
            }

            var running = RunningSystem.Create(input.System);

            using (running.System)
            {
                var fixtures = input.BuildFixturesWithOverrides(running.RecycledMessage);

                foreach (var fixture in fixtures)
                {
                    var file = input.FixturePath.AppendPath(fixture.key + ".md");
                    try
                    {
                        FixtureWriter.Write(fixture, file);
                    }
                    catch (Exception e)
                    {
                        ConsoleWriter.Write(ConsoleColor.Red, $"Could not export fixture {fixture.key}");
                        ConsoleWriter.Write(ConsoleColor.Yellow, e.ToString());
                    }
                }
            }


            return(true);
        }
        public StorytellerRunner(ISystem system, string specDirectory = null)
        {
            Debug.WriteLine("StorytellerRunner is starting up for system " + system);

            SpecDirectory = specDirectory ?? GuessSpecDirectory(system);

            _running = RunningSystem.Create(system);

            Hierarchy = HierarchyLoader.ReadHierarchy(SpecDirectory).ToHierarchy();

            _warmup = _running.System.Warmup();
        }
Esempio n. 4
0
        private static void writeFixtures(RunningSystem running)
        {
            if (running.RecycledMessage.fixtures.Any())
            {
                Console.WriteLine("Found Fixtures:");
                var i = 0;

                foreach (var fixture in running.RecycledMessage.fixtures)
                {
                    Console.WriteLine($"{(++i).ToString().PadLeft(3)}). {fixture.key} ({fixture.title})");
                }
            }
            else
            {
                Console.WriteLine("No fixtures found.");
            }
        }
Esempio n. 5
0
        public override bool Execute(StorytellerInput input)
        {
            try
            {
                var running = RunningSystem.Create(input.System);
                if (running.RecycledMessage.success)
                {
                    Console.WriteLine("Able to create the FixtureLibrary");
                }


                Console.WriteLine("System ready.");


                writeFixtures(running);



                Console.WriteLine("Trying the Warmup now...");

                var warmup = running.System.Warmup();

                warmup.Wait(1.Minutes());

                if (warmup.IsCompleted)
                {
                    ConsoleWriter.Write(ConsoleColor.Green, "StorytellerAgent started without any exceptions");
                }

                return(true);
            }
            catch (Exception e)
            {
                StorytellerAgent.LogFailure(e);

                ConsoleWriter.Write(ConsoleColor.Red, "StorytellerAgent startup failed!");
                ConsoleWriter.Write(ConsoleColor.Yellow, e.ToString());

                return(false);
            }
        }
Esempio n. 6
0
        public override bool Execute(StorytellerInput input)
        {
            var running = RunningSystem.Create(input.System);

            using (running.System)
            {
                var library = input.BuildFixturesWithOverrides(running.RecycledMessage);



                var specs = HierarchyLoader.ReadHierarchy(input.SpecPath).GetAllSpecs().ToArray();

                SpecificationPostProcessor.PostProcessAll(specs, running.Fixtures);

                var errored = specs.Where(x => x.errors.Any()).ToArray();

                if (errored.Any())
                {
                    ConsoleWriter.Write(ConsoleColor.Red, "Errors Detected!");

                    foreach (var errorSpec in errored)
                    {
                        ConsoleWriter.Write(ConsoleColor.Yellow, errorSpec.Filename);
                        foreach (var error in errorSpec.errors)
                        {
                            Console.WriteLine($"{error.location.Join(" / ")} -> {error.message}");
                        }
                    }

                    return(false);
                }
                else
                {
                    ConsoleWriter.Write(ConsoleColor.Green, "No validation errors or missing data detected in this project");
                    return(true);
                }
            }
        }
Esempio n. 7
0
        private async Task <bool> execute(RunInput input)
        {
            var specFetching = input.ReadSpecs();
            var running      = RunningSystem.Create(input.System);

            using (running.System)
            {
                if (!running.RecycledMessage.success)
                {
                    throw new Exception("System startup failed.");
                }

                await running.System.Warmup();

                var specs = await specFetching;

                var runner = buildRunner(input, specs, running, out var executionObserver);

                buildExecutionQueue(runner, executionObserver);

                var requests = createExecutionPlans(specs, running);

                var finished = Task.WhenAll(requests.Select(x => x.Completion));
                var timeout  = Task.Delay(input.GlobalTimeoutFlag.Minutes());

                await Task.WhenAny(timeout, finished);

                if (timeout.IsCompleted)
                {
                    showTimeoutMessage(input, requests);
                }

                var records = requests.Select(x => new BatchRecord
                {
                    results       = x.Completion.Result,
                    specification = x.Specification
                }).ToArray();

                var results = new BatchRunResponse
                {
                    fixtures = running.Fixtures.Models.ToArray(),

                    suite   = "Interactive Execution",
                    system  = running.System.GetType().FullName,
                    records = records
                };

                var success = determineSuccess(input, results);

                writeResults(input, running.RecycledMessage, results);

                writeData(input, results);


                if (input.OpenFlag)
                {
                    ProcessLauncher.OpenFile(input.ResultsPathFlag);
                }

                writeSuccessOrFailure(success);

                return(success);
            }
        }
Esempio n. 8
0
        private static SpecRunner buildRunner(RunInput input, List <Specification> specs, RunningSystem running, out IExecutionObserver executionObserver)
        {
            IBatchObserver batchObserver = new NulloBatchObservor();

            executionObserver = new NulloObserver();
            switch (input.TracingFlag)
            {
            case TracingStyle.verbose:
                batchObserver = new ConsoleBatchObserver(specs.Count);
                // TODO -- awesome if you could get smarter w/ the console output here
                break;

            case TracingStyle.teamcity:
                batchObserver     = new TeamCityBatchObserver();
                executionObserver = new TeamCityExecutionObserver();
                break;

            case TracingStyle.appveyor:
                batchObserver = new AppVeyorBatchObserver();
                break;
            }

            return(new SpecRunner(new BatchExecutionMode(batchObserver), running.System, executionObserver));
        }
Esempio n. 9
0
        private SpecExecutionRequest[] createExecutionPlans(List <Specification> specs, RunningSystem running)
        {
            var nullo    = new NulloResultObserver();
            var requests = specs.Select(x => new SpecExecutionRequest(x, nullo)).ToArray();

            foreach (var request in requests)
            {
                request.CreatePlan(running.Fixtures);
                _queue.Enqueue(request);
            }
            return(requests);
        }