@@ -15,138 +15,138 @@ namespace nanoFramework.Tools.MetadataProcessor.Tests.Core
15
15
[ TestClass ]
16
16
public class ClrIntegrationTests
17
17
{
18
- [ TestMethod ]
19
- public void RunBCLTest ( )
20
- {
21
- var workingDirectory = TestObjectHelper . TestNFAppLocation ;
22
- var mscorlibLocation = Path . Combine ( workingDirectory , "mscorlib.pe" ) ;
23
-
24
- // prepare the process start of the WIN32 nanoCLR
25
- Process nanoClr = new Process ( ) ;
26
-
27
- // load only mscorlib
28
- string parameter = $ "-load { mscorlibLocation } ";
29
-
30
- nanoClr . StartInfo = new ProcessStartInfo ( TestObjectHelper . NanoClrLocation , parameter )
31
- {
32
- WorkingDirectory = workingDirectory ,
33
- UseShellExecute = false ,
34
- RedirectStandardError = true ,
35
- RedirectStandardOutput = true
36
- } ;
37
-
38
- // launch nanoCLR
39
- if ( ! nanoClr . Start ( ) )
40
- {
41
- Assert . Fail ( "Failed to start nanoCLR Win32" ) ;
42
- }
43
-
44
- // wait 5 seconds for exit
45
- nanoClr . WaitForExit ( 5000 ) ;
46
-
47
- Assert . IsTrue ( nanoClr . HasExited , "nanoCLR hasn't completed execution" ) ;
48
-
49
- // read standard output
50
- var output = nanoClr . StandardOutput . ReadToEnd ( ) ;
51
-
52
- // look for the error message reporting that there is no entry point
53
- Assert . IsTrue ( output . Contains ( "Cannot find any entrypoint!" ) ) ;
54
- }
55
-
56
- [ TestMethod ]
57
- public void RunTestNFAppTest ( )
58
- {
59
- // 5 seconds
60
- int runTimeout = 5000 ;
61
-
62
- var workingDirectory = TestObjectHelper . TestNFAppLocation ;
63
- var mscorlibLocation = Path . Combine ( workingDirectory , "mscorlib.pe" ) ;
64
- var nfTestAppLocation = TestObjectHelper . TestNFAppFullPath . Replace ( "exe" , "pe" ) ;
65
- var nfTestClassLibLocation = TestObjectHelper . TestNFClassLibFullPath . Replace ( "dll" , "pe" ) ;
66
-
67
- // prepare the process start of the WIN32 nanoCLR
68
- Process nanoClr = new Process ( ) ;
69
-
70
- AutoResetEvent outputWaitHandle = new AutoResetEvent ( false ) ;
71
- AutoResetEvent errorWaitHandle = new AutoResetEvent ( false ) ;
72
-
73
- try
74
- {
75
- // load only mscorlib
76
- string parameter = $ "-load { nfTestAppLocation } -load { mscorlibLocation } -load { nfTestClassLibLocation } ";
77
-
78
- nanoClr . StartInfo = new ProcessStartInfo ( TestObjectHelper . NanoClrLocation , parameter )
79
- {
80
- WorkingDirectory = workingDirectory ,
81
- UseShellExecute = false ,
82
- RedirectStandardError = true ,
83
- RedirectStandardOutput = true
84
- } ;
85
-
86
- // launch nanoCLR
87
- if ( nanoClr . Start ( ) )
88
- {
89
- Console . WriteLine ( $ "Running nanoCLR Win32 @ '{ TestObjectHelper . NanoClrLocation } '") ;
90
- }
91
- else
92
- {
93
- Assert . Fail ( "Failed to start nanoCLR Win32" ) ;
94
- }
95
-
96
- StringBuilder output = new StringBuilder ( ) ;
97
- StringBuilder error = new StringBuilder ( ) ;
98
-
99
- nanoClr . OutputDataReceived += ( sender , e ) =>
100
- {
101
- if ( e . Data == null )
102
- {
103
- outputWaitHandle . Set ( ) ;
104
- }
105
- else
106
- {
107
- output . AppendLine ( e . Data ) ;
108
- }
109
- } ;
110
- nanoClr . ErrorDataReceived += ( sender , e ) =>
111
- {
112
- if ( e . Data == null )
113
- {
114
- errorWaitHandle . Set ( ) ;
115
- }
116
- else
117
- {
118
- error . AppendLine ( e . Data ) ;
119
- }
120
- } ;
121
-
122
- nanoClr . Start ( ) ;
123
-
124
- nanoClr . BeginOutputReadLine ( ) ;
125
- nanoClr . BeginErrorReadLine ( ) ;
126
-
127
- Console . WriteLine ( $ "nanoCLR started @ process ID: { nanoClr . Id } ") ;
128
-
129
- // wait for exit, no worries about the outcome
130
- nanoClr . WaitForExit ( runTimeout ) ;
131
-
132
- var outputOfTest = output . ToString ( ) ;
133
-
134
- // look for standard messages
135
- Assert . IsTrue ( outputOfTest . Contains ( "Ready." ) , $ "Failed to find READY message.{ Environment . NewLine } Output is:{ Environment . NewLine } { outputOfTest } ") ;
136
- Assert . IsTrue ( outputOfTest . Contains ( "Done." ) , $ "Failed to find DONE message.{ Environment . NewLine } Output is:{ Environment . NewLine } { outputOfTest } ") ;
137
- Assert . IsTrue ( outputOfTest . Contains ( "Exiting." ) , $ "Failed to find EXITING message.{ Environment . NewLine } Output is:{ Environment . NewLine } { outputOfTest } ") ;
138
-
139
- // look for any exceptions
140
- Assert . IsFalse ( outputOfTest . Contains ( "++++ Exception " ) , $ "Exception thrown by TestNFApp application.{ Environment . NewLine } Output is:{ Environment . NewLine } { outputOfTest } ") ;
141
- }
142
- finally
143
- {
144
- if ( ! nanoClr . HasExited )
145
- {
146
- nanoClr . Kill ( ) ;
147
- nanoClr . WaitForExit ( runTimeout ) ;
148
- }
149
- }
150
- }
18
+ // [TestMethod]
19
+ // public void RunBCLTest()
20
+ // {
21
+ // var workingDirectory = TestObjectHelper.TestNFAppLocation;
22
+ // var mscorlibLocation = Path.Combine(workingDirectory, "mscorlib.pe");
23
+
24
+ // // prepare the process start of the WIN32 nanoCLR
25
+ // Process nanoClr = new Process();
26
+
27
+ // // load only mscorlib
28
+ // string parameter = $"-load {mscorlibLocation}";
29
+
30
+ // nanoClr.StartInfo = new ProcessStartInfo(TestObjectHelper.NanoClrLocation, parameter)
31
+ // {
32
+ // WorkingDirectory = workingDirectory,
33
+ // UseShellExecute = false,
34
+ // RedirectStandardError = true,
35
+ // RedirectStandardOutput = true
36
+ // };
37
+
38
+ // // launch nanoCLR
39
+ // if (!nanoClr.Start())
40
+ // {
41
+ // Assert.Fail("Failed to start nanoCLR Win32");
42
+ // }
43
+
44
+ // // wait 5 seconds for exit
45
+ // nanoClr.WaitForExit(5000);
46
+
47
+ // Assert.IsTrue(nanoClr.HasExited, "nanoCLR hasn't completed execution");
48
+
49
+ // // read standard output
50
+ // var output = nanoClr.StandardOutput.ReadToEnd();
51
+
52
+ // // look for the error message reporting that there is no entry point
53
+ // Assert.IsTrue(output.Contains("Cannot find any entrypoint!"));
54
+ // }
55
+
56
+ // [TestMethod]
57
+ // public void RunTestNFAppTest()
58
+ // {
59
+ // // 5 seconds
60
+ // int runTimeout = 5000;
61
+
62
+ // var workingDirectory = TestObjectHelper.TestNFAppLocation;
63
+ // var mscorlibLocation = Path.Combine(workingDirectory, "mscorlib.pe");
64
+ // var nfTestAppLocation = TestObjectHelper.TestNFAppFullPath.Replace("exe", "pe");
65
+ // var nfTestClassLibLocation = TestObjectHelper.TestNFClassLibFullPath.Replace("dll", "pe");
66
+
67
+ // // prepare the process start of the WIN32 nanoCLR
68
+ // Process nanoClr = new Process();
69
+
70
+ // AutoResetEvent outputWaitHandle = new AutoResetEvent(false);
71
+ // AutoResetEvent errorWaitHandle = new AutoResetEvent(false);
72
+
73
+ // try
74
+ // {
75
+ // // load only mscorlib
76
+ // string parameter = $"-load {nfTestAppLocation} -load {mscorlibLocation} -load {nfTestClassLibLocation}";
77
+
78
+ // nanoClr.StartInfo = new ProcessStartInfo(TestObjectHelper.NanoClrLocation, parameter)
79
+ // {
80
+ // WorkingDirectory = workingDirectory,
81
+ // UseShellExecute = false,
82
+ // RedirectStandardError = true,
83
+ // RedirectStandardOutput = true
84
+ // };
85
+
86
+ // // launch nanoCLR
87
+ // if (nanoClr.Start())
88
+ // {
89
+ // Console.WriteLine($"Running nanoCLR Win32 @ '{TestObjectHelper.NanoClrLocation}'");
90
+ // }
91
+ // else
92
+ // {
93
+ // Assert.Fail("Failed to start nanoCLR Win32");
94
+ // }
95
+
96
+ // StringBuilder output = new StringBuilder();
97
+ // StringBuilder error = new StringBuilder();
98
+
99
+ // nanoClr.OutputDataReceived += (sender, e) =>
100
+ // {
101
+ // if (e.Data == null)
102
+ // {
103
+ // outputWaitHandle.Set();
104
+ // }
105
+ // else
106
+ // {
107
+ // output.AppendLine(e.Data);
108
+ // }
109
+ // };
110
+ // nanoClr.ErrorDataReceived += (sender, e) =>
111
+ // {
112
+ // if (e.Data == null)
113
+ // {
114
+ // errorWaitHandle.Set();
115
+ // }
116
+ // else
117
+ // {
118
+ // error.AppendLine(e.Data);
119
+ // }
120
+ // };
121
+
122
+ // nanoClr.Start();
123
+
124
+ // nanoClr.BeginOutputReadLine();
125
+ // nanoClr.BeginErrorReadLine();
126
+
127
+ // Console.WriteLine($"nanoCLR started @ process ID: {nanoClr.Id}");
128
+
129
+ // // wait for exit, no worries about the outcome
130
+ // nanoClr.WaitForExit(runTimeout);
131
+
132
+ // var outputOfTest = output.ToString();
133
+
134
+ // // look for standard messages
135
+ // Assert.IsTrue(outputOfTest.Contains("Ready."), $"Failed to find READY message.{Environment.NewLine}Output is:{Environment.NewLine}{outputOfTest}");
136
+ // Assert.IsTrue(outputOfTest.Contains("Done."), $"Failed to find DONE message.{Environment.NewLine}Output is:{Environment.NewLine}{outputOfTest}");
137
+ // Assert.IsTrue(outputOfTest.Contains("Exiting."), $"Failed to find EXITING message.{Environment.NewLine}Output is:{Environment.NewLine}{outputOfTest}");
138
+
139
+ // // look for any exceptions
140
+ // Assert.IsFalse(outputOfTest.Contains("++++ Exception "), $"Exception thrown by TestNFApp application.{Environment.NewLine}Output is:{Environment.NewLine}{outputOfTest}");
141
+ // }
142
+ // finally
143
+ // {
144
+ // if (!nanoClr.HasExited)
145
+ // {
146
+ // nanoClr.Kill();
147
+ // nanoClr.WaitForExit(runTimeout);
148
+ // }
149
+ // }
150
+ // }
151
151
}
152
152
}
0 commit comments