public AssertTokenizer(Tests/*!*/ tests) { _log = new LoggingErrorSink(); _tests = tests; _context = tests.Context; DefaultEncoding = RubyEncoding.UTF8; Compatibility = tests.Context.RubyOptions.Compatibility; }
private int RunUnitTests(List<string>/*!*/ largs) { _tests = new Tests(this); if (_displayList) { for (int i = 0; i < _tests.TestMethods.Length; i++) { Console.WriteLine(_tests.TestMethods[i].Method.Name); } return -1; } // check whether there is a preselected case: IList<TestCase> selectedCases = new List<TestCase>(); foreach (var m in _tests.TestMethods) { if (m.Method.IsDefined(typeof(RunAttribute), false)) { AddTestCases(selectedCases, m); } } if (selectedCases.Count == 0 && largs.Count > 0) { foreach (var m in _tests.TestMethods) { bool caseIsSpecified = largs.Contains(m.Method.Name); if ((caseIsSpecified && !_excludeSelectedCases) || (!caseIsSpecified && _excludeSelectedCases)) { AddTestCases(selectedCases, m); } } } else if (selectedCases.Count > 0 && largs.Count > 0) { Console.WriteLine("Arguments overrided by Run attribute."); } else if (selectedCases.Count == 0 && largs.Count == 0) { foreach (var m in _tests.TestMethods) { AddTestCases(selectedCases, m); } } foreach (TestCase testCase in selectedCases) { RunTestCase(testCase); } var failedCases = new List<string>(); if (_failedAssertions.Count > 0) { for (int i = 0; i < _failedAssertions.Count; i++) { string test = _failedAssertions[i].Item000; StackFrame frame = _failedAssertions[i].Item001; string message = _failedAssertions[i].Item002; failedCases.Add(test); Console.Error.WriteLine(); if (_partialTrust) { WriteError("{0}) {1}", failedCases.Count, test); } else { WriteError("{0}) {1} {2} : {3}", failedCases.Count, test, frame.GetFileName(), frame.GetFileLineNumber()); } Console.Error.WriteLine(message); } } if (_unexpectedExceptions.Count > 0) { for (int i = 0; i < _unexpectedExceptions.Count; i++) { string test = _unexpectedExceptions[i].Item000; Exception exception = _unexpectedExceptions[i].Item001; Console.Error.WriteLine(); WriteError("{0}) {1} (unexpected exception)", failedCases.Count, test); Console.Error.WriteLine(exception); failedCases.Add(test); } } if (failedCases.Count == 0) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("PASSED"); Console.ForegroundColor = ConsoleColor.Gray; } else { Console.WriteLine(); // TODO: if (!_partialTrust) { Console.Write("Repro: {0}", Environment.CommandLine); } else { Console.Write("Repro: IronRuby.Tests.exe /partial"); } if (largs.Count == 0) { Console.Write(" {0}", String.Join(" ", failedCases.ToArray())); } Console.WriteLine(); } return failedCases.Count; }
private void RunManualTest() { Console.WriteLine("Running hardcoded test case"); if (Manual.ParseOnly) { _testRuntime = new TestRuntime(this, new TestCase { Name = "<manual>" }); Tests.GetRubyTokens(_testRuntime.Context, new LoggingErrorSink(false), Manual.TestCode, !Manual.DumpReductions, Manual.DumpReductions); } else { try { for (int i = 0; i < Manual.RequiredFiles.Length; i += 2) { File.CreateText(Manual.RequiredFiles[i]).WriteLine(Manual.RequiredFiles[i + 1]); } _tests = new Tests(this); RunTestCase(new TestCase() { Name = "$manual$", TestMethod = () => _tests.CompilerTest(Manual.TestCode), }); } finally { for (int i = 0; i < Manual.RequiredFiles.Length; i += 2) { try { File.Delete(Manual.RequiredFiles[i]); } catch { // nop } } } } }
private int RunUnitTests(List <string> /*!*/ largs) { _tests = new Tests(this); if (_displayList) { for (int i = 0; i < _tests.TestMethods.Length; i++) { Console.WriteLine(_tests.TestMethods[i].Method.Name); } return(-1); } // check whether there is a preselected case: IList <TestCase> selectedCases = new List <TestCase>(); foreach (var m in _tests.TestMethods) { if (m.Method.IsDefined(typeof(RunAttribute), false)) { AddTestCases(selectedCases, m); } } if (selectedCases.Count == 0 && largs.Count > 0) { foreach (var m in _tests.TestMethods) { bool caseIsSpecified = largs.Contains(m.Method.Name); if ((caseIsSpecified && !_excludeSelectedCases) || (!caseIsSpecified && _excludeSelectedCases)) { AddTestCases(selectedCases, m); } } } else if (selectedCases.Count > 0 && largs.Count > 0) { Console.WriteLine("Arguments overrided by Run attribute."); } else if (selectedCases.Count == 0 && largs.Count == 0) { foreach (var m in _tests.TestMethods) { AddTestCases(selectedCases, m); } } foreach (TestCase testCase in selectedCases) { RunTestCase(testCase); } var failedCases = new List <string>(); if (_failedAssertions.Count > 0) { for (int i = 0; i < _failedAssertions.Count; i++) { string test = _failedAssertions[i].Item000; StackFrame frame = _failedAssertions[i].Item001; string message = _failedAssertions[i].Item002; failedCases.Add(test); Console.Error.WriteLine(); if (_partialTrust) { ColorWrite(ConsoleColor.Red, "{0}) {1}", failedCases.Count, test); } else { ColorWrite(ConsoleColor.Red, "{0}) {1} {2} : {3}", failedCases.Count, test, frame.GetFileName(), frame.GetFileLineNumber()); } Console.Error.WriteLine(message); } } if (_unexpectedExceptions.Count > 0) { for (int i = 0; i < _unexpectedExceptions.Count; i++) { string test = _unexpectedExceptions[i].Item000; Exception exception = _unexpectedExceptions[i].Item001; Console.Error.WriteLine(); ColorWrite(ConsoleColor.Red, "{0}) {1} (unexpected exception)", failedCases.Count, test); Console.Error.WriteLine(exception); failedCases.Add(test); } } if (failedCases.Count == 0) { ColorWrite(ConsoleColor.Green, "PASSED"); } else { Console.WriteLine(); // TODO: if (!_partialTrust) { Console.Write("Repro: {0}", Environment.CommandLine); } else { Console.Write("Repro: IronRuby.Tests.exe /partial{0}{1}", _noAdaptiveCompilation ? " /noadaptive" : "", _isDebug ? " /debug" : ""); } if (largs.Count == 0) { Console.Write(" {0}", String.Join(" ", failedCases.ToArray())); } Console.WriteLine(); } return(failedCases.Count); }
public AssertTokenizer /*!*/ Read(Tokens token) { Next(); Tests.Assert(_actualToken == token); return(this); }
private int RunUnitTests(List<string>/*!*/ largs) { int failureCount = 0; _tests = new Tests(this); if (_displayList) { for (int i = 0; i < _tests.TestMethods.Length; i++) { Console.WriteLine(_tests.TestMethods[i].Method.Name); } return -1; } // check whether there is a preselected case: IList<TestCase> selectedCases = new List<TestCase>(); foreach (var m in _tests.TestMethods) { if (m.Method.IsDefined(typeof(RunAttribute), false)) { AddTestCases(selectedCases, m); } } if (selectedCases.Count == 0 && largs.Count > 0) { foreach (var m in _tests.TestMethods) { bool caseIsSpecified = largs.Contains(m.Method.Name); if ((caseIsSpecified && !_excludeSelectedCases) || (!caseIsSpecified && _excludeSelectedCases)) { AddTestCases(selectedCases, m); } } } else if (selectedCases.Count > 0 && largs.Count > 0) { Console.WriteLine("Arguments overrided by Run attribute."); } else if (selectedCases.Count == 0 && largs.Count == 0) { foreach (var m in _tests.TestMethods) { AddTestCases(selectedCases, m); } } foreach (TestCase testCase in selectedCases) { RunTestCase(testCase, ref failureCount); } return failureCount; }