Initialize() public method

public Initialize ( ) : void
return void
Ejemplo n.º 1
0
		static int Main(string[] args)
		{
			string temp;

			if (GetOption ("help", args, false, out temp)) {
				Usage ();
				return 0;
			}

			string compiler;
			if (!GetOption ("compiler", args, true, out compiler)) {
				Usage ();
				return 1;
			}

			ITester tester;
			try {
				Console.WriteLine ("Loading " + compiler + " ...");
				tester = new ReflectionTester (Assembly.LoadFile (compiler));
			} catch (Exception) {
				Console.Error.WriteLine ("Switching to command line mode (compiler entry point was not found)");
				if (!File.Exists (compiler)) {
					Console.Error.WriteLine ("ERROR: Tested compiler was not found");
					return 1;
				}
				tester = new ProcessTester (compiler);
			}

			string mode;
			if (!GetOption ("mode", args, true, out mode)) {
				Usage ();
				return 1;
			}

			Checker checker;
			bool positive;
			switch (mode) {
				case "neg":
					checker = new NegativeChecker (tester, true);
					positive = false;
					break;
				case "pos":
					string iltest;
					GetOption ("il", args, false, out iltest);
					checker = new PositiveChecker (tester, iltest);
					positive = true;

					if (iltest != null && GetOption ("update-il", args, false, out temp)) {
						((PositiveChecker) checker).UpdateVerificationDataFile = true;
					}

					break;
				default:
					Console.Error.WriteLine ("Invalid -mode argument");
					return 1;
			}


			if (GetOption ("issues", args, true, out temp))
				checker.IssueFile = temp;
			if (GetOption ("log", args, true, out temp))
				checker.LogFile = temp;
			if (GetOption ("verbose", args, false, out temp))
				checker.Verbose = true;
			if (GetOption ("safe-execution", args, false, out temp))
				checker.SafeExecution = true;
			if (GetOption ("compiler-options", args, true, out temp)) {
				string[] extra = temp.Split (' ');
				checker.ExtraCompilerOptions = extra;
			}

			string test_pattern;
			if (!GetOption ("files", args, true, out test_pattern)) {
				Usage ();
				return 1;
			}

			var files = new List<string> ();
			switch (test_pattern) {
			case "v1":
				files.AddRange (Directory.GetFiles (".", positive ? "test*.cs" : "cs*.cs"));
				break;
			case "v2":
				files.AddRange (Directory.GetFiles (".", positive ? "gtest*.cs" : "gcs*.cs"));
				goto case "v1";
			case "v4":
				files.AddRange (Directory.GetFiles (".", positive ? "dtest*.cs" : "dcs*.cs"));
				goto case "v2";
			default:
				files.AddRange (Directory.GetFiles (".", test_pattern));
				break;
			}

			if (files.Count == 0) {
				Console.Error.WriteLine ("No files matching `{0}' found", test_pattern);
				return 2;
			}

			checker.Initialize ();
/*
			files.Sort ((a, b) => {
				if (a.EndsWith ("-lib.cs", StringComparison.Ordinal)) {
					if (!b.EndsWith ("-lib.cs", StringComparison.Ordinal))
						return -1;
				} else if (b.EndsWith ("-lib.cs", StringComparison.Ordinal)) {
					if (!a.EndsWith ("-lib.cs", StringComparison.Ordinal))
						return 1;
				}

				return a.CompareTo (b);
			});
*/
			foreach (string s in files) {
				string filename = Path.GetFileName (s);
				if (Char.IsUpper (filename, 0)) { // Windows hack
					continue;
				}

				if (filename.EndsWith ("-p2.cs"))
					continue;
			    
				checker.Do (filename);
			}

			checker.CleanUp ();

			checker.Dispose ();

			return checker.ResultCode;
		}