Skip to content

Commit

Permalink
Add test projects (optional) to net_4_x.sln (mono#5633)
Browse files Browse the repository at this point in the history
* add tests to net_4_x.sln

* remove redundant string.Format
  • Loading branch information
EgorBo authored and akoeplinger committed Sep 25, 2017
1 parent 878b260 commit be99d5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
5 changes: 4 additions & 1 deletion Makefile.am
Expand Up @@ -145,4 +145,7 @@ update-llvm-version:
update-solution-files:
make update-csproj
make package-inputs
(cd msvc/scripts; make genproj.exe; mono genproj.exe)
(cd msvc/scripts; make genproj.exe; mono genproj.exe $(GENPROJ_ARGS))

update-solution-files-with-tests:
make "GENPROJ_ARGS=2012 true true" update-solution-files
36 changes: 14 additions & 22 deletions msvc/scripts/genproj.cs
Expand Up @@ -794,12 +794,8 @@ public VsCsproj Generate (string library_output, Dictionary<string,MsbuildGenera

var refs = new StringBuilder ();

bool is_test = response.Contains ("_test_");
if (is_test) {
// F:\src\mono\mcs\class\lib\net_2_0\nunit.framework.dll
// F:\src\mono\mcs\class\SomeProject\SomeProject_test_-net_2_0.csproj
var nunitLibPath = string.Format (@"..\lib\{0}\nunit.framework.dll", profile);
refs.Append (string.Format (" <Reference Include=\"{0}\" />" + NewLine, nunitLibPath));
if (response.Contains ("_test")) {
refs.Append ($@" <Reference Include=""..\lib\{profile}\nunitlite.dll"" />{NewLine}");
}

//
Expand Down Expand Up @@ -1049,7 +1045,7 @@ MsbuildGenerator GetMatchingCsproj (string library_output, string dllReferenceNa

public class Driver {

static IEnumerable<XElement> GetProjects (bool full = false)
static IEnumerable<XElement> GetProjects (bool withTests = false)
{
XDocument doc = XDocument.Load ("order.xml");
foreach (XElement project in doc.Root.Elements ()) {
Expand All @@ -1071,12 +1067,6 @@ static IEnumerable<XElement> GetProjects (bool full = false)
//
if (!(dir.StartsWith ("class") || dir.StartsWith ("mcs") || dir.StartsWith ("basic")))
continue;

if (full){
if (!library.Contains ("tests"))
yield return project;
continue;
}
#endif
//
// Do not do 2.1, it is not working yet
Expand All @@ -1094,11 +1084,12 @@ static IEnumerable<XElement> GetProjects (bool full = false)
if (dir.Contains ("nunit20"))
continue;

#if true
if (profile != "net_4_x" || library.Contains ("tests"))
if (library.Contains ("tests") && !withTests)
continue;
#endif
//Console.WriteLine ("Going to handle {0}", library);

if (profile != "net_4_x")
continue;

yield return project;
}
}
Expand All @@ -1112,19 +1103,20 @@ static void Main (string [] args)

if (args.Length == 1 && args [0].ToLower ().Contains ("-h")) {
Console.WriteLine ("Usage:");
Console.WriteLine ("genproj.exe [visual_studio_release] [output_full_solutions]");
Console.WriteLine ("genproj.exe [visual_studio_release] [output_full_solutions] [with_tests]");
Console.WriteLine ("If output_full_solutions is false, only the main System*.dll");
Console.WriteLine (" assemblies (and dependencies) is included in the solution.");
Console.WriteLine ("Example:");
Console.WriteLine ("genproj.exe 2012 false");
Console.WriteLine ("genproj.exe with no arguments is equivalent to 'genproj.exe 2012 true'\n\n");
Console.WriteLine ("genproj.exe 2012 false false");
Console.WriteLine ("genproj.exe with no arguments is equivalent to 'genproj.exe 2012 true false'\n\n");
Console.WriteLine ("genproj.exe deps");
Console.WriteLine ("Generates a Makefile dependency file from the projects input");
Environment.Exit (0);
}

var slnVersion = (args.Length > 0) ? args [0] : "2012";
bool fullSolutions = (args.Length > 1) ? bool.Parse (args [1]) : true;
bool withTests = (args.Length > 2) ? bool.Parse (args [2]) : false;

// To generate makefile depenedencies
var makefileDeps = (args.Length > 0 && args [0] == "deps");
Expand All @@ -1134,11 +1126,11 @@ static void Main (string [] args)
var projects = new Dictionary<string,MsbuildGenerator> ();

var duplicates = new List<string> ();
foreach (var project in GetProjects (makefileDeps)) {
foreach (var project in GetProjects (withTests)) {
var library_output = project.Element ("library_output").Value;
projects [library_output] = new MsbuildGenerator (project);
}
foreach (var project in GetProjects (makefileDeps)){
foreach (var project in GetProjects (withTests)){
var library_output = project.Element ("library_output").Value;
//Console.WriteLine ("=== {0} ===", library_output);
var gen = projects [library_output];
Expand Down

0 comments on commit be99d5f

Please sign in to comment.