First set of licensing changes
[mono.git] / mono / tests / verifier / BatchCompiler.cs
1 //
2 // AssemblyRunner.cs
3 //
4 // Author:
5 //   Rodrigo Kumpera (rkumpera@novell.com)
6 //
7 // Copyright (C) 2008 Novell, Inc (http://www.novell.com)
8 //
9 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 using System;
11 using System.IO;
12 using System.Reflection;
13
14
15 namespace Verifier {
16         public class BatchCompiler : MarshalByRefObject {
17                 static AppDomain current;
18
19                 static BatchCompiler NewBatchCompiler () {
20                         if (current != null)
21                                 AppDomain.Unload (current);
22
23                         current = AppDomain.CreateDomain ("test");
24                         BatchCompiler compiler = (BatchCompiler) current.CreateInstanceAndUnwrap(
25                                 Assembly.GetExecutingAssembly().FullName,
26                                 "Verifier.BatchCompiler");
27                         return compiler;
28                 }
29
30                 public static void Main (String[] args) {
31                         int total = 0;
32                         BatchCompiler bc = NewBatchCompiler ();
33
34                         foreach (string src in Directory.GetFiles (".", "*.il")) {
35                                 if (bc.Compile (src)) 
36                                         ++total;
37                                 bc = NewBatchCompiler ();
38                         }
39                         Console.WriteLine ("Total compiled successfully {0}", total);
40                 }
41
42                 public bool Compile (String src) {
43                         try {
44                                 Mono.ILASM.Driver.Main (new string[] { src });
45                                 string binary = src.Substring (0, src.Length - 3) + ".exe";
46                                 return File.Exists (binary);
47                         } catch (Exception e) {
48                                 Console.WriteLine ("Error compiling {0}", e);
49                                 return false;
50                         }
51                 }
52         }
53 }
54