static void Main(string[] args) { FortranOptions opts = new FortranOptions(); MessageCollection messages = new MessageCollection(opts); opts.Messages = messages; if (opts.Parse(args)) { Compiler comp = new Compiler(opts); comp.Messages = messages; foreach (string srcfile in opts.SourceFiles) { if (!File.Exists(srcfile)) { messages.Error(MessageCode.SOURCEFILENOTFOUND, String.Format("File '{0}' not found", srcfile)); break; } comp.Compile(srcfile); } if (messages.ErrorCount == 0) { comp.Save(); if (opts.Run && messages.ErrorCount == 0) { comp.Execute(); } } } foreach (Message msg in messages) { if (msg.Level == MessageLevel.Error) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine(msg); Console.ResetColor(); } if (messages.ErrorCount > 0) { Console.WriteLine(String.Format("*** {0} errors found. Compilation stopped.", messages.ErrorCount)); } }
public void ValidateFilenameParsing() { FortranOptions opts = new FortranOptions(); string[] args = new [] { "-backslash", "testfile1.f", "-debug", "testfile2.f" }; Assert.IsTrue(opts.Parse(args)); Assert.IsTrue(opts.SourceFiles.Count == 2); Assert.AreEqual(opts.SourceFiles[0], "testfile1.f"); Assert.AreEqual(opts.SourceFiles[1], "testfile2.f"); Assert.IsTrue(opts.Backslash); Assert.IsTrue(opts.GenerateDebug); }
public void ValidateOptionParsing() { FortranOptions opts = new FortranOptions(); string[] args = new [] { "-backslash", "-invalidoption", "-debug" }; Assert.IsFalse(opts.Parse(args)); Assert.IsTrue(opts.Backslash); Assert.IsTrue(opts.GenerateDebug); Assert.IsTrue(opts.Messages.Count == 2); Assert.IsTrue(opts.Messages[0].Code == MessageCode.BADOPTION); Assert.IsTrue(opts.Messages[1].Code == MessageCode.MISSINGSOURCEFILE); }