From: <dr...@us...> - 2003-11-26 05:33:55
|
Update of /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Tests/SharpCvsLib In directory sc8-pr-cvs1:/tmp/cvs-serv21188/src/ICSharpCode.Tests/SharpCvsLib Modified Files: MainTest.cs Tests.build Log Message: Updated unit tests, created task to upload unit test results to the nightly build page. Also added an AbstractTest class that can be overridden in subclasses and provides some useful methods such as create directories, checkout and cleanup. Finally added a build target for a sample set of unit tests that builds in 60-90 seconds on my box. Set this build sample to the default target. Index: MainTest.cs =================================================================== RCS file: /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Tests/SharpCvsLib/MainTest.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MainTest.cs 23 Nov 2003 20:52:04 -0000 1.4 --- MainTest.cs 26 Nov 2003 05:33:52 -0000 1.5 *************** *** 48,229 **** namespace ICSharpCode.SharpCvsLib.Console { - - /// <summary> - /// Test the command line args parameters for valid ones - /// and test invalid ones. - /// </summary> - [TestFixture] - public class MainTest { - private ILog LOGGER = LogManager.GetLogger (typeof (MainTest)); - private TestSettings settings = new TestSettings (); - - private String buildDir; /// <summary> ! /// Constructory for test case. /// </summary> ! public MainTest () { ! buildDir = System.AppDomain.CurrentDomain.BaseDirectory; ! } ! /// <summary> ! /// Ensure valid help parameter processing. ! /// ! /// </summary> ! [Test] ! public void GenericHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! LOGGER.Debug ("buildDir=[" + buildDir + "]"); ! LOGGER.Debug ("filename=[" + filename + "]"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.General + "\r\n", output); ! } ! /// <summary> ! /// Ensure valid option help parameter processing. ! /// ! /// </summary> ! [Test] ! public void OptionHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Add Help option parameter to executable name ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-options"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.Options + "\r\n", output); ! } /// <summary> ! /// Ensure valid commands help parameter processing. ! /// ! /// </summary> ! [Test] ! public void CommandsHelpTest () ! { ! // Test Commands help parameter ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-commands"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.Commands + "\r\n", output); ! } ! /// <summary> ! /// Ensure valid synonyms help parameter processing. ! /// ! /// </summary> ! [Test] ! public void SynonymsHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-synonyms"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.Synonyms + "\r\n", output); ! } ! /// <summary> ! /// Ensure invalid help parameter processing. ! /// ! /// </summary> ! [Test] ! public void BadHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-bad"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.General + "\r\n", output); ! } ! /// <summary> ! /// Ensure no parameters processing. ! /// ! /// </summary> ! [Test] ! public void NoParamTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.General + "\r\n", output); } - } } --- 48,234 ---- namespace ICSharpCode.SharpCvsLib.Console { /// <summary> ! /// Test the command line args parameters for valid ones ! /// and test invalid ones. /// </summary> ! [TestFixture] ! public class MainTest { ! private ILog LOGGER = LogManager.GetLogger (typeof (MainTest)); ! private TestSettings settings = new TestSettings (); ! private String buildDir; ! /// <summary> ! /// Constructory for test case. ! /// </summary> ! public MainTest () { ! buildDir = System.AppDomain.CurrentDomain.BaseDirectory; ! } ! /// <summary> ! /// Ensure valid help parameter processing. ! /// ! /// </summary> ! [Test] ! public void GenericHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! LOGGER.Debug ("buildDir=[" + buildDir + "]"); ! LOGGER.Debug ("filename=[" + filename + "]"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.WaitForInputIdle(10); ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.General + "\r\n", output); ! } ! /// <summary> ! /// Ensure valid option help parameter processing. ! /// ! /// </summary> ! [Test] ! public void OptionHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Add Help option parameter to executable name ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-options"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.WaitForInputIdle(10); ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.Options + "\r\n", output); ! } /// <summary> ! /// Ensure valid commands help parameter processing. ! /// ! /// </summary> ! [Test] ! public void CommandsHelpTest () ! { ! // Test Commands help parameter ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-commands"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.WaitForInputIdle(10); ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.Commands + "\r\n", output); ! } ! /// <summary> ! /// Ensure valid synonyms help parameter processing. ! /// ! /// </summary> ! [Test] ! public void SynonymsHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-synonyms"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.WaitForInputIdle(10); ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.Synonyms + "\r\n", output); ! } ! /// <summary> ! /// Ensure invalid help parameter processing. ! /// ! /// </summary> ! [Test] ! public void BadHelpTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename, "--help-bad"); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.WaitForInputIdle(10); ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! // Check the results of process output ! Assertion.AssertEquals (Usage.General + "\r\n", output); ! } ! /// <summary> ! /// Ensure no parameters processing. ! /// ! /// </summary> ! [Test] ! public void NoParamTest () ! { ! // Get Executable name ! String filename = Path.Combine (buildDir, "cvs.exe"); ! // Create new process ! ProcessStartInfo cvsProcessInfo = new ProcessStartInfo(filename); ! cvsProcessInfo.UseShellExecute = false; ! cvsProcessInfo.RedirectStandardOutput = true; ! cvsProcessInfo.CreateNoWindow = true; ! // Run the process ! Process cvsProcess = new Process(); ! cvsProcess.StartInfo = cvsProcessInfo; ! cvsProcess.WaitForInputIdle(10); ! cvsProcess.Start(); ! string output = cvsProcess.StandardOutput.ReadToEnd(); ! cvsProcess.WaitForExit(); ! ! // Check the results of process output ! Assertion.AssertEquals (Usage.General + "\r\n", output); ! } } } Index: Tests.build =================================================================== RCS file: /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode.Tests/SharpCvsLib/Tests.build,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Tests.build 17 Oct 2003 01:14:08 -0000 1.11 --- Tests.build 26 Nov 2003 05:33:52 -0000 1.12 *************** *** 31,39 **** </csc> </target> <target name="run-tests"> <nunit2> ! <test assemblyname="${dir.build}/${name.top-level}.${name.project}.${name.tests}.dll" appconfig="ICSharpCode.SharpCvsLib.Tests.dll.config"/> </nunit2> </target> ! </project> --- 31,87 ---- </csc> </target> + <target name="build-sample"> + <csc target="library" + warnaserror="${compile.warnaserror}" + output="${dir.build}/${name.top-level}.${name.project}.${name.tests}-sample.dll" + debug="${compile.debug}" + define="${compile.define}"> + + <arg value="${compile.unsafe}" /> + <arg value="${compile.checked}" /> + + <!-- // TODO: Change to internalize helpers (accessor) --> + <sources> + <includes name="**/*.cs" /> + <includes name="../../${name.top-level}/${name.project}/**.cs" /> + <includes name="../../${name.top-level}.${name.console}/${name.project}/**.cs" /> + <excludes name="../../${name.top-level}.${name.console}/${name.project}/AssemblyInfo.cs" /> + <excludes name="Commands/*.cs" /> + <excludes name="Console/Commands/CheckoutCommandTest.cs"/> + <excludes name="Console/Commands/UpdateCommandTest.cs"/> + <excludes name="Console/Commands/LoginCommandTest.cs"/> + </sources> + + <references> + <includes name="System.dll" /> + <includes name="${dir.lib}/${lib.zip}" /> + <includes name="${dir.lib.ext}/${lib.log4net}" /> + <includes name="${dir.lib.ext}/${lib.nunit}" /> + <!-- // TODO: Change to internalize helpers (lib.accessor) --> + <!-- <includes name="${dir.build}/${lib.name}.dll" />--> + </references> + </csc> + </target> <target name="run-tests"> + <echo message="Results output directory: ${dir.build}/results" /> <nunit2> ! <formatter type="Xml" usefile="true" extension=".xml" outputdir="${dir.build}/tests" /> ! <test assemblyname="${dir.build}/${name.top-level}.${name.project}.${name.tests}.dll" appconfig="ICSharpCode.SharpCvsLib.Tests.dll.config"/> </nunit2> </target> ! <target name="run-tests-sample" depends="build-sample"> ! <echo message="Results output directory: ${dir.build}/tests" /> ! <nunit2> ! <formatter type="Xml" usefile="true" extension=".xml" outputdir="${dir.build}/tests" /> ! <test assemblyname="${dir.build}/${name.top-level}.${name.project}.${name.tests}-sample.dll" ! appconfig="ICSharpCode.SharpCvsLib.Tests.dll.config"/> ! </nunit2> ! </target> ! <target name="tests-to-html" failonerror="false"> ! <nunit2report out="${dir.build}/tests/index.html" > ! <fileset> ! <includes name="${dir.build}/tests/${name.top-level}.${name.project}.${name.tests}-sample.dll-results.xml" /> ! </fileset> ! </nunit2report> ! </target> </project> |