Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions src/stress.codegen/MergeAllProjectJsonsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class MergeAllProjectJsonsTask : Task
// we assume that anyos test project.jsons (AND ONLY THESE; any other ones will mess up the merge) are
// present in the directory or subdirectories of InPath
[Required]
public string InPath { get; set; }
public string InPath { get; set; }

// the path to the project.json we are spawning.
[Required]
Expand All @@ -38,32 +38,37 @@ public class MergeAllProjectJsonsTask : Task
// this method walks the directory tree of inPath and uses the Newtonsoft JObject::Merge to merge together
// our project jsons.
// we require there to be at least ONE project.json present somewhere in the directory tree of inPath
private JObject MergeProjectJsonsIn(string inPath)
{
var projectJsons = Directory.EnumerateFiles(InPath, "project.json", SearchOption.AllDirectories).Select(p => JObject.Parse(File.ReadAllText(p)));
JObject merged = new JObject(projectJsons.First());
//private JObject MergeProjectJsonsIn(string inPath, string targetFramework)
//{
// //var projectJsons = Directory.EnumerateFiles(InPath, "project.json", SearchOption.AllDirectories).Select(p => JObject.Parse(File.ReadAllText(p)));
// JObject merged = new JObject(projectJsons.First());

foreach (var file in projectJsons)
{
//
merged.Merge(file);
}
// foreach (var file in projectJsons)
// {
// // if (file["frameworks"].Contains(targetFramework))
// // {
// merged.Merge(file);
// //}
// }

return merged;
}
// return merged;
//}

// this method:
// strips out test-runtime object if it is present in the dependencies list.
// removes all frameworks except for the one that is to be targeted for the run
private void ProduceAnyOsProjectJson(string outPath, JObject merged, string targetFramework)
{
// remove test-runtime if it is present.
// Filter out unwanted JObjects.

(merged["dependencies"] as JObject)?.Property("test-runtime")?.Remove();
(merged["dependencies"] as JObject)?.Property("perf")?.Remove();

// remove all supports.
merged["supports"]?.Children<JProperty>().ToList().ForEach(x => x.Remove());

// remove all frameworks except the specified one


//// remove all frameworks except the specified one
merged["frameworks"]?.Children<JProperty>().ToList().ForEach(x => x.Remove());
merged["frameworks"][targetFramework] = new JObject();

Expand All @@ -88,8 +93,10 @@ public override bool Execute()
{
MessageBox.Show($"PID:{Process.GetCurrentProcess().Id} Attach debugger now.", "Debug GenerateStressSuiteTask", MessageBoxButton.OK);
}

ProduceAnyOsProjectJson(OutPath, MergeProjectJsonsIn(InPath), "netcoreapp1.0");

var x = Directory.EnumerateFiles(InPath, "project.json", SearchOption.AllDirectories).First();

ProduceAnyOsProjectJson(OutPath, JObject.Parse(File.ReadAllText(x)), "netstandard1.7");

return true;
}
Expand Down
22 changes: 18 additions & 4 deletions test/genstress.proj
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,33 @@
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Reflection.Emit.ILGeneration.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Reflection.Emit.Lightweight.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Reflection.Emit.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Configuration.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Net.Mail.Functional.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Net.Mail.Unit.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Transactions.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Security.Permissions.Tests.zip</ExcludedTestAssemblies>
<ExcludedTestAssemblies>$(ExcludedTestAssemblies);$(UnitTestDirectory)System.Net.WebProxy.Tests.zip</ExcludedTestAssemblies>
</PropertyGroup>

<ItemGroup>
<ZipFile Include="$(UnitTestDirectory)*.zip" Exclude="$(ExcludedTestAssemblies)"/>
</ItemGroup>

<Target Name="CleanUpUtExtracted"
DependsOnTargets="SelectTestZips">
<RemoveDir Directories="$(UnitTestExtractDir)" />
</Target>

<Target Name="UnzipAllTests"
Condition="!Exists('$(UnitTestExtractedSemaphore)')"
DependsOnTargets="UnzipTest">
<WriteLinesToFile File="$(UnitTestExtractedSemaphore)" Lines="" Overwrite="false" />
</Target>

<Target Name="UnzipTest"
Inputs="@(ZipFile)"
Outputs="@(ZipFile->Replace('$(UnitTestDirectory)','$(UnitTestExtractDir)'))"
DependsOnTargets="SelectTestZips">
DependsOnTargets="CleanUpUtExtracted">
<Message Text="Unzipping tests: @(ZipFile)" Importance="Low" />

<ZipFileExtractToDirectory Condition="Exists('%(RootDir)%(Directory)%(ZipFile.FileName)%(ZipFile.Extension)')"
Expand All @@ -133,8 +144,12 @@
<Message Text="Restoring test dependencies..." />

<RemoveDir Directories="$(UnitTestCLIProjDir)" />

<RemoveDir Directories="$(UnitTestDependsBin)" />


<Message Text="Removing " />


<!-- create a dummy project used to restore test binaries -->
<MakeDir Directories="$(UnitTestCLIProjDir)"/>
<Exec Command="$(DotnetToolCommand) new" StandardOutputImportance="Low" CustomErrorRegularExpression="^Unable to locate .*" WorkingDirectory="$(UnitTestCLIProjDir)"/>
Expand Down Expand Up @@ -170,7 +185,6 @@
</ItemGroup>

<Target Name="GenerateStressSuiteSource" DependsOnTargets="RestoreTestDependsBin">

<Error Condition="!Exists('$(SuiteConfigPath)')" Text="ERROR: File not found. Stress suite config path '$(SuiteConfigPath)' is invalid " />

<MakeDir Directories="$(StressGeneratedRoot)"/>
Expand Down