Skip to content

Commit

Permalink
[Harness] Remove the BCLTestProjectInfo class.
Browse files Browse the repository at this point in the history
The class is not really needed. Move to a tuple, make the definition of
the group test project nicer since the dictionary initiallization makes
it cleaner.
  • Loading branch information
mandel-macaque committed Mar 28, 2020
1 parent a150c95 commit ab95d46
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 158 deletions.
324 changes: 196 additions & 128 deletions tests/xharness/BCLTestImporter/BCLTestProjectGenerator.cs

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions tests/xharness/BCLTestImporter/BclTestProjectInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public interface ITemplatedProject {
/// has its own details.</param>
/// <param name="generatedDir">The dir where the projects will be saved.</param>
/// <returns></returns>
Task<GeneratedProjects> GenerateTestProjectsAsync (IEnumerable<BclTestProjectInfo> projects, Platform platform);
Task<GeneratedProjects> GenerateTestProjectsAsync (IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)> projects, Platform platform);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ string GenerateIncludeFilesNode (string projectName, (string FailureMessage, Lis
return contentFiles.ToString ();
}

public async Task<GeneratedProjects> GenerateTestProjectsAsync (IEnumerable<BclTestProjectInfo> projects, Platform platform)
public async Task<GeneratedProjects> GenerateTestProjectsAsync (IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)> projects, Platform platform)
{
// generate the template c# code before we create the diff projects
await GenerateSource (Path.Combine (OutputDirectoryPath, "templates"));
Expand Down Expand Up @@ -382,7 +382,7 @@ async Task<string> GenerateWatchExtensionAsync (string projectName, Stream templ
}

// internal implementations that generate each of the diff projects
async Task<GeneratedProjects> GenerateWatchOSTestProjectsAsync (IEnumerable<BclTestProjectInfo> projects)
async Task<GeneratedProjects> GenerateWatchOSTestProjectsAsync (IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)> projects)
{
var projectPaths = new GeneratedProjects ();
foreach (var def in projects) {
Expand All @@ -391,7 +391,7 @@ async Task<GeneratedProjects> GenerateWatchOSTestProjectsAsync (IEnumerable<BclT
// 2. The container
// 3. The extensions
// TODO: The following is very similar to what is done in the iOS generation. Must be grouped
var projectDefinition = new BCLTestProjectDefinition (def.Name, AssemblyLocator, AssemblyDefinitionFactory, def.assemblies, def.ExtraArgs);
var projectDefinition = new BCLTestProjectDefinition (def.Name, AssemblyLocator, AssemblyDefinitionFactory, def.Assemblies, def.ExtraArgs);
if (ProjectFilter != null && ProjectFilter.ExludeProject (projectDefinition, Platform.WatchOS)) // if it is ignored, continue
continue;

Expand Down Expand Up @@ -507,17 +507,17 @@ async Task<string> GenerateAsync (string projectName, string registerPath, (stri
}
}

async Task<GeneratedProjects> GenerateiOSTestProjectsAsync (IEnumerable<BclTestProjectInfo> projects, Platform platform)
async Task<GeneratedProjects> GenerateiOSTestProjectsAsync (IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)> projects, Platform platform)
{
if (platform == Platform.WatchOS)
throw new ArgumentException (nameof (platform));
if (!projects.Any ()) // return an empty list
return new GeneratedProjects ();
var projectPaths = new GeneratedProjects ();
foreach (var def in projects) {
if (def.assemblies.Length == 0)
if (def.Assemblies.Length == 0)
continue;
var projectDefinition = new BCLTestProjectDefinition (def.Name, AssemblyLocator, AssemblyDefinitionFactory, def.assemblies, def.ExtraArgs);
var projectDefinition = new BCLTestProjectDefinition (def.Name, AssemblyLocator, AssemblyDefinitionFactory, def.Assemblies, def.ExtraArgs);
if (ProjectFilter != null && ProjectFilter.ExludeProject (projectDefinition, Platform.WatchOS)) // if it is ignored, continue
continue;

Expand Down Expand Up @@ -608,13 +608,13 @@ async Task<string> GenerateMacAsync (string projectName, string registerPath, (s
}
}

async Task<GeneratedProjects> GenerateMacTestProjectsAsync (IEnumerable<BclTestProjectInfo> projects, Platform platform)
async Task<GeneratedProjects> GenerateMacTestProjectsAsync (IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)> projects, Platform platform)
{
var projectPaths = new GeneratedProjects ();
foreach (var def in projects) {
if (!def.assemblies.Any ())
if (!def.Assemblies.Any ())
continue;
var projectDefinition = new BCLTestProjectDefinition (def.Name, AssemblyLocator, AssemblyDefinitionFactory, def.assemblies, def.ExtraArgs);
var projectDefinition = new BCLTestProjectDefinition (def.Name, AssemblyLocator, AssemblyDefinitionFactory, def.Assemblies, def.ExtraArgs);
if (ProjectFilter != null && ProjectFilter.ExludeProject (projectDefinition, platform))
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,16 @@ public async Task GenerateTestProjectsAsyncTest ()
( Name: "First project", Path: "", XUnit: false, ExtraArgs: "", Failure: "", TimeoutMultiplier: 1),
( Name: "Second project", Path: "", XUnit: true, ExtraArgs: "", Failure: "", TimeoutMultiplier: 1),
};
var infos = new List<BclTestProjectInfo> {
new BclTestProjectInfo {
Name = "First project",
},
new BclTestProjectInfo {
Name = "Second project",
}
var infos = new List<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)> {
( Name: "First project", Assemblies: new string [] { }, ExtraArgs: "", TimeoutMultiplier: 1),
( Name: "Second project", Assemblies: new string [] { }, ExtraArgs: "", TimeoutMultiplier: 1),
};
template.Setup (t => t.GenerateTestProjectsAsync (It.IsAny<IEnumerable<BclTestProjectInfo>> (), It.IsAny<Platform> ())).Returns (() => {
template.Setup (t => t.GenerateTestProjectsAsync (It.IsAny<IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)>> (), It.IsAny<Platform> ())).Returns (() => {
return Task.FromResult (projects);
});
var result = await generator.GenerateTestProjectsAsync (infos, Platform.iOS);
Assert.AreEqual (projects.Count, result.Count);
template.Verify (t => t.GenerateTestProjectsAsync (It.IsAny<IEnumerable<BclTestProjectInfo>> (), It.IsAny<Platform> ()));
template.Verify (t => t.GenerateTestProjectsAsync (It.IsAny<IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)>> (), It.IsAny<Platform> ()));
}
}
}
1 change: 0 additions & 1 deletion tests/xharness/xharness.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
<Compile Include="XmlResultParser.cs" />
<Compile Include="BCLTestImporter\Templates\ITemplatedProject.cs" />
<Compile Include="BCLTestImporter\Templates\Managed\XamariniOSTemplate.cs" />
<Compile Include="BCLTestImporter\BclTestProjectInfo.cs" />
<Compile Include="BCLTestImporter\IAssemblyLocator.cs" />
<Compile Include="BCLTestImporter\Templates\IProjectFilter.cs" />
<Compile Include="BCLTestImporter\Xamarin\AssemblyLocator.cs" />
Expand Down

0 comments on commit ab95d46

Please sign in to comment.