@@ -24,15 +24,26 @@ static void Main(string[] args)
2424 } ;
2525
2626 const string testFilesDir = "TestFiles" ;
27+ int totalTests = 0 ;
2728 foreach ( var category in categories )
2829 {
29- MakeTestCategory ( category , testFilesDir ) ;
30+ totalTests += MakeTestCategory ( category , testFilesDir ) ;
3031 }
32+
33+ Console . WriteLine ( ) ;
34+ Console . WriteLine ( $ "Created a total of { totalTests . ToString ( "N0" ) } tests.") ;
3135 }
3236
33- private static void MakeTestCategory ( TestCategory category , string baseTestFilesDir )
37+ private static int MakeTestCategory ( TestCategory category , string baseTestFilesDir )
3438 {
35- //Create folderto put test files into
39+ //Does folder with test files exist?
40+ if ( ! Directory . Exists ( category . testPath ) )
41+ {
42+ Console . WriteLine ( $ "Skipping { category . categoryName } category as its test folder doesn't exist.") ;
43+ return 0 ;
44+ }
45+
46+ //Create folder to put test files into
3647 string testFilesDir = Path . Combine ( baseTestFilesDir , category . categoryName ) ;
3748 Directory . CreateDirectory ( testFilesDir ) ;
3849
@@ -42,7 +53,10 @@ private static void MakeTestCategory(TestCategory category, string baseTestFiles
4253
4354 List < TestInfo > foundTests = FindTests ( category . testPath ) ;
4455 List < TestInfo > movedTests = CopyTestsIntoFolder ( foundTests , testFilesDir ) ;
45- MakeTestCode ( movedTests , category , testFilesDir , testFilesPath ) ;
56+ int testsMade = MakeTestCode ( movedTests , category , testFilesDir , testFilesPath ) ;
57+
58+ Console . WriteLine ( $ "Created { testsMade } tests for the category: { category . categoryName } ") ;
59+ return testsMade ;
4660 }
4761
4862 private static List < TestInfo > FindTests ( string testDir )
@@ -128,7 +142,7 @@ private static List<TestInfo> CopyTestsIntoFolder(List<TestInfo> foundTests, str
128142 return testsWithNewNames ;
129143 }
130144
131- private static void MakeTestCode ( List < TestInfo > tests , TestCategory category , string testDir , string testFilesPath )
145+ private static int MakeTestCode ( List < TestInfo > tests , TestCategory category , string testDir , string testFilesPath )
132146 {
133147 StringBuilder loadGraphTests = new StringBuilder ( ) ;
134148 StringBuilder inferTypeTests = new StringBuilder ( ) ;
@@ -173,18 +187,22 @@ private static void MakeTestCode(List<TestInfo> tests, TestCategory category, st
173187 File . WriteAllText ( Path . Combine ( testFilesPath , loadClassName + ".cs" ) , loadGraphTests . ToString ( ) ) ;
174188 File . WriteAllText ( Path . Combine ( testFilesPath , inferClassName + ".cs" ) , inferTypeTests . ToString ( ) ) ;
175189 File . WriteAllText ( Path . Combine ( testFilesPath , computeClassName + ".cs" ) , computeGraphTests . ToString ( ) ) ;
190+
191+ const int CSharpTestsPerScalaTest = 3 ;
192+ return tests . Count * CSharpTestsPerScalaTest ;
176193 }
177194
178195 private static void AddHeader ( StringBuilder sBuilder , string className , string testDir )
179196 {
197+ char dirSep = Path . DirectorySeparatorChar ;
180198 sBuilder . AppendLine ( "using Microsoft.VisualStudio.TestTools.UnitTesting;" ) ;
181199 sBuilder . AppendLine ( ) ;
182200 sBuilder . AppendLine ( "namespace ChiselDebugTests" ) ;
183201 sBuilder . AppendLine ( "{" ) ;
184202 sBuilder . AppendLine ( "\t [TestClass]" ) ;
185203 sBuilder . AppendLine ( $ "\t public class { className } ") ;
186204 sBuilder . AppendLine ( "\t {" ) ;
187- sBuilder . AppendLine ( $ "\t \t const string TestDir = @\" ..\\ .. \\ .. \\ .. \\ TestGenerator\\ { testDir } \" ;") ;
205+ sBuilder . AppendLine ( $ "\t \t const string TestDir = @\" ..{ dirSep } .. { dirSep } .. { dirSep } .. { dirSep } TestGenerator{ dirSep } { testDir } \" ;") ;
188206 sBuilder . AppendLine ( ) ;
189207 }
190208 }
0 commit comments