Putting in new release tests to make sure all sorts of things are good when we deploy.

Have a new command line argument of test that will run release tests.
Put in two tests to ensure that we don't have DEBUG defined when we ship release builds.
Wrote a exception dumper that will output data when we have an error.
This commit is contained in:
larsbrubaker 2014-02-26 11:05:58 -08:00
parent 491289f8d2
commit eb41dbc01f
4 changed files with 73 additions and 1 deletions

View file

@ -98,6 +98,8 @@
<Compile Include="SlicerConfiguration\SlicerMapping\EngineMappingSlic3r.cs" />
<Compile Include="SlicerConfiguration\SlicerMapping\MappingClasses.cs" />
<Compile Include="SlicerConfiguration\SlicerMapping\EngineMapingBase.cs" />
<Compile Include="Testing\ReleaseTests.cs" />
<Compile Include="Testing\TestingDispatch.cs" />
<Compile Include="ToolsPage\ToolsListControl.cs" />
<Compile Include="ToolsPage\ToolsListItem.cs" />
<Compile Include="ToolsPage\ToolsWidget.cs" />

View file

@ -71,9 +71,20 @@ namespace MatterHackers.MatterControl
public MatterControlApplication(double width, double height)
: base(width, height)
{
this.commandLineArgs = Environment.GetCommandLineArgs();;
this.commandLineArgs = Environment.GetCommandLineArgs();
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
if (commandLineArgs.Length > 1 && commandLineArgs[1].ToUpper() == "TEST")
{
Testing.TestingDispatch testDispatch = new Testing.TestingDispatch();
string[] testCommands = new string[commandLineArgs.Length-2];
if (commandLineArgs.Length > 2)
{
commandLineArgs.CopyTo(testCommands, 2);
}
testDispatch.RunTests(testCommands);
}
//WriteTestGCodeFile();
if (File.Exists("RunUnitTests.txt"))
{

17
Testing/ReleaseTests.cs Normal file
View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MatterHackers.MatterControl.Testing
{
public static class ReleaseTests
{
public static void AssertDebugNotDefined()
{
#if DEBUG
throw new Exception("DEBUG is defined and should not be!");
#endif
}
}
}

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
namespace MatterHackers.MatterControl.Testing
{
public class TestingDispatch
{
string errorLogFileName = null;
public TestingDispatch()
{
errorLogFileName = string.Format("ErrorLog - {0:yyyy-MM-dd hh-mmtt}.txt", DateTime.Now);
string firstLine = string.Format("MatterControl Errors: {0:yyyy-MM-dd hh:mm:ss tt}", DateTime.Now);
using (StreamWriter file = new StreamWriter(errorLogFileName))
{
file.WriteLine(errorLogFileName, firstLine);
}
}
public void RunTests(string[] testCommands)
{
try { ReleaseTests.AssertDebugNotDefined(); }
catch (Exception e) { DumpException(e); }
try { MatterHackers.GCodeVisualizer.GCodeFile.AssertDebugNotDefined(); }
catch (Exception e) { DumpException(e); }
}
void DumpException(Exception e)
{
using (StreamWriter w = File.AppendText(errorLogFileName))
{
w.WriteLine(e.Message);
w.Write(e.StackTrace);
w.WriteLine();
}
}
}
}