Exemple #1
0
        Task PopulateTasksAsync()
        {
            // Missing:
            // api-diff

            testSelector.SelectTests();

            DeviceLoader.LoadAllAsync().DoNotAwait();

            var simTasksFactory = new RunSimulatorTasksFactory();
            var loadsim         = simTasksFactory.CreateAsync(this, processManager, testVariationsFactory)
                                  .ContinueWith((v) => {
                if (v.Status == TaskStatus.RanToCompletion)
                {
                    Console.WriteLine("Simulator tasks created");
                    Tasks.AddRange(v.Result);
                }
                else
                {
                    Console.WriteLine($"Failed to create simulator tasks: {v.Exception}");
                }
            });

            //Tasks.AddRange (await CreateRunSimulatorTasksAsync ());

            var crashReportSnapshotFactory = new CrashSnapshotReporterFactory(processManager);

            // all factories are enumerators \o/
            var testFactories = new IEnumerable <AppleTestTask> [] {
                new MacTestTasksEnumerable(this, processManager, crashReportSnapshotFactory, testVariationsFactory),
                new NUnitTestTasksEnumerable(this, processManager),
                new MakeTestTaskEnumerable(this, processManager)
            };

            // add all tests defined by the factory
            foreach (var f in testFactories)
            {
                Tasks.AddRange(f);
            }

            // individual special tasks
            var buildXtroTests = new MakeTask(jenkins: this, processManager: processManager)
            {
                Platform         = TestPlatform.All,
                TestName         = "Xtro",
                Target           = "wrench",
                WorkingDirectory = Path.Combine(HarnessConfiguration.RootDirectory, "xtro-sharpie"),
                Ignored          = !IncludeXtro,
                Timeout          = TimeSpan.FromMinutes(15),
            };

            var runXtroReporter = new RunXtroTask(this, buildXtroTests, processManager, crashReportSnapshotFactory)
            {
                Platform         = TestPlatform.Mac,
                TestName         = buildXtroTests.TestName,
                Ignored          = buildXtroTests.Ignored,
                WorkingDirectory = buildXtroTests.WorkingDirectory,
            };

            Tasks.Add(runXtroReporter);

            var buildDotNetGeneratorProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "bgen", "bgen-tests.csproj")));
            var buildDotNetGenerator        = new DotNetBuildTask(jenkins: this, testProject: buildDotNetGeneratorProject, processManager: processManager)
            {
                TestProject          = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "bgen", "bgen-tests.csproj"))),
                SpecifyPlatform      = false,
                SpecifyConfiguration = false,
                Platform             = TestPlatform.iOS,
            };
            var runDotNetGenerator = new DotNetTestTask(this, buildDotNetGenerator, processManager)
            {
                TestProject = buildDotNetGeneratorProject,
                Platform    = TestPlatform.iOS,
                TestName    = "Generator tests",
                Mode        = ".NET",
                Ignored     = !IncludeBtouch,
            };

            Tasks.Add(runDotNetGenerator);

            var buildDotNetTestsProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "dotnet", "UnitTests", "DotNetUnitTests.csproj")));
            var buildDotNetTests        = new DotNetBuildTask(this, testProject: buildDotNetTestsProject, processManager: processManager)
            {
                SpecifyPlatform      = false,
                Platform             = TestPlatform.All,
                ProjectConfiguration = "Debug",
                Ignored = !IncludeDotNet,
            };
            var runDotNetTests = new DotNetTestTask(this, buildDotNetTests, processManager)
            {
                TestProject = buildDotNetTestsProject,
                Platform    = TestPlatform.All,
                TestName    = "DotNet tests",
                Timeout     = TimeSpan.FromMinutes(5),
                Ignored     = !IncludeDotNet,
            };

            Tasks.Add(runDotNetTests);

            var deviceTestFactory = new RunDeviceTasksFactory();
            var loaddev           = deviceTestFactory.CreateAsync(this, processManager, testVariationsFactory).ContinueWith((v) => {
                Console.WriteLine("Got device tasks completed");
                Tasks.AddRange(v.Result);
            });

            return(Task.WhenAll(loadsim, loaddev));
        }
        public IEnumerator <NUnitExecuteTask> GetEnumerator()
        {
            var netstandard2Project = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "Xamarin.iOS.Tasks.Tests.csproj")));
            var buildiOSMSBuild     = new MSBuildTask(jenkins: jenkins, testProject: netstandard2Project, processManager: processManager)
            {
                SpecifyPlatform           = false,
                SpecifyConfiguration      = true,
                ProjectConfiguration      = "Debug",
                Platform                  = TestPlatform.iOS,
                SolutionPath              = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "msbuild", "Xamarin.MacDev.Tasks.sln")),
                SupportsParallelExecution = false,
            };
            var nunitExecutioniOSMSBuild = new NUnitExecuteTask(jenkins, buildiOSMSBuild, processManager)
            {
                TestLibrary          = Path.Combine(HarnessConfiguration.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "bin", "Debug", "net461", "Xamarin.iOS.Tasks.Tests.dll"),
                TestProject          = netstandard2Project,
                ProjectConfiguration = "Debug",
                Platform             = TestPlatform.iOS,
                TestName             = "MSBuild tests",
                Mode    = "iOS",
                Timeout = TimeSpan.FromMinutes(60),
                Ignored = !jenkins.IncludeiOSMSBuild,
                SupportsParallelExecution = false,
            };

            yield return(nunitExecutioniOSMSBuild);

            var installSourcesProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "tools", "install-source", "InstallSourcesTests", "InstallSourcesTests.csproj")));
            var buildInstallSources   = new MSBuildTask(jenkins: jenkins, testProject: installSourcesProject, processManager: processManager)
            {
                SpecifyPlatform      = false,
                SpecifyConfiguration = false,
                Platform             = TestPlatform.iOS,
            };

            buildInstallSources.SolutionPath = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "tools", "install-source", "install-source.sln"));               // this is required for nuget restore to be executed
            var nunitExecutionInstallSource = new NUnitExecuteTask(jenkins, buildInstallSources, processManager)
            {
                TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "..", "tools", "install-source", "InstallSourcesTests", "bin", "Release", "InstallSourcesTests.dll"),
                TestProject = installSourcesProject,
                Platform    = TestPlatform.iOS,
                TestName    = "Install Sources tests",
                Mode        = "iOS",
                Timeout     = TimeSpan.FromMinutes(60),
                Ignored     = !jenkins.IncludeMac && !jenkins.IncludeSimulator,
            };

            yield return(nunitExecutionInstallSource);

            var buildMTouch = new MakeTask(jenkins: jenkins, processManager: processManager)
            {
                TestProject          = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "mtouch", "mtouch.sln"))),
                SpecifyPlatform      = false,
                SpecifyConfiguration = false,
                Platform             = TestPlatform.iOS,
                Target           = "dependencies",
                WorkingDirectory = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "mtouch")),
            };
            var nunitExecutionMTouch = new NUnitExecuteTask(jenkins, buildMTouch, processManager)
            {
                TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "mtouch", "bin", "Debug", "mtouch.dll"),
                TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "mtouch", "mtouch.csproj"))),
                Platform    = TestPlatform.iOS,
                TestName    = "MTouch tests",
                Timeout     = TimeSpan.FromMinutes(180),
                Ignored     = !jenkins.IncludeMtouch,
                InProcess   = true,
            };

            yield return(nunitExecutionMTouch);

            var buildGenerator = new MakeTask(jenkins: jenkins, processManager: processManager)
            {
                TestProject          = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "src", "generator.sln"))),
                SpecifyPlatform      = false,
                SpecifyConfiguration = false,
                Platform             = TestPlatform.iOS,
                Target           = "build-unit-tests",
                WorkingDirectory = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "generator")),
            };
            var runGenerator = new NUnitExecuteTask(jenkins, buildGenerator, processManager)
            {
                TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "generator", "bin", "Debug", "generator-tests.dll"),
                TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "generator", "generator-tests.csproj"))),
                Platform    = TestPlatform.iOS,
                TestName    = "Generator tests",
                Mode        = "NUnit",
                Timeout     = TimeSpan.FromMinutes(10),
                Ignored     = !jenkins.IncludeBtouch,
            };

            yield return(runGenerator);

            var buildCecilTestsProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "cecil-tests", "cecil-tests.csproj")));

            buildCecilTestsProject.RestoreNugetsInProject = true;
            var buildCecilTests = new MSBuildTask(jenkins: jenkins, testProject: buildCecilTestsProject, processManager: processManager)
            {
                SpecifyPlatform      = false,
                Platform             = TestPlatform.All,
                ProjectConfiguration = "Debug",
                Ignored = !jenkins.IncludeCecil,
            };
            var runCecilTests = new NUnitExecuteTask(jenkins, buildCecilTests, processManager)
            {
                TestLibrary = Path.Combine(Path.GetDirectoryName(buildCecilTestsProject.Path), "bin", "Debug", "net472", "cecil-tests.dll"),
                TestProject = buildCecilTestsProject,
                Platform    = TestPlatform.iOS,
                TestName    = "Cecil-based tests",
                Timeout     = TimeSpan.FromMinutes(5),
                Ignored     = !jenkins.IncludeCecil,
                InProcess   = true,
            };

            yield return(runCecilTests);

            var buildSampleTestsProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "sampletester", "sampletester.csproj")));
            var buildSampleTests        = new MSBuildTask(jenkins: jenkins, testProject: buildSampleTestsProject, processManager: processManager)
            {
                SpecifyPlatform      = false,
                Platform             = TestPlatform.All,
                ProjectConfiguration = "Debug",
            };
            var runSampleTests = new NUnitExecuteTask(jenkins, buildSampleTests, processManager)
            {
                TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "sampletester", "bin", "Debug", "sampletester.dll"),
                TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "sampletester", "sampletester.csproj"))),
                Platform    = TestPlatform.All,
                TestName    = "Sample tests",
                Timeout     = TimeSpan.FromDays(1), // These can take quite a while to execute.
                InProcess   = true,
                Ignored     = true,                 // Ignored by default, can be run manually. On CI will execute if the label 'run-sample-tests' is present on a PR (but in Azure Devops on a different bot).
            };

            yield return(runSampleTests);
        }