private async Task ExecuteAsync(CommandLineOptions options)
        {
            try
            {
                var results = await InternalExecuteAsync(options).ConfigureAwait(false);

                WriteResultsFile(options.ResultsFilePath, ExecutionContent.CreateSuccess(results));
            }
            catch (Exception ex)
            {
                WriteResultsFile(options.ResultsFilePath, ExecutionContent.CreateFromException(ex));
            }
        }
        private async Task ExecuteAsync(TestInputData testInputData)
        {
            try
            {
                CommonCacheTestUtils.EnsureCacheFileDirectoryExists();

                var results = await InternalExecuteAsync(testInputData).ConfigureAwait(false);

                WriteResultsFile(testInputData.ResultsFilePath, ExecutionContent.CreateSuccess(results));
            }
            catch (Exception ex)
            {
                WriteResultsFile(testInputData.ResultsFilePath, ExecutionContent.CreateFromException(ex));
            }
        }
 private void WriteResultsFile(string resultsFilePath, ExecutionContent results)
 {
     File.WriteAllText(resultsFilePath, JsonConvert.SerializeObject(results));
 }
Beispiel #4
0
        public static void Execute(string[] args, Func <CommandLineOptions, Task> runFunc)
        {
            void SyncRunAction(CommandLineOptions options)
            {
                Console.WriteLine(Assembly.GetEntryAssembly().Location);
                try
                {
                    runFunc.Invoke(options).ConfigureAwait(false).GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    File.WriteAllText(options.ResultsFilePath, JsonConvert.SerializeObject(ExecutionContent.CreateFromException(ex)));
                }
            }

            Parser.Default.ParseArguments <CommandLineOptions>(args).WithParsed(SyncRunAction).WithNotParsed(HandleParseError);
        }
        private async Task ExecuteAsync(TestInputData testInputData)
        {
            try
            {
                CommonCacheTestUtils.EnsureCacheFileDirectoryExists();

                // The default behavior for the external language execution is for them to write the results file.
                await InternalExecuteAsync(testInputData).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                File.WriteAllText(testInputData.ResultsFilePath, JsonConvert.SerializeObject(ExecutionContent.CreateFromException(ex)));
            }
        }