Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4065 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
9 changed files with 164 additions and 7 deletions
@ -0,0 +1,18 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Python.Build.Tasks |
||||||
|
{ |
||||||
|
public class PythonCompilerException : ApplicationException |
||||||
|
{ |
||||||
|
public PythonCompilerException(string message) : base(message) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Python.Build.Tasks |
||||||
|
{ |
||||||
|
public class Resources |
||||||
|
{ |
||||||
|
Resources() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// No main file specified when trying to compile an application
|
||||||
|
/// </summary>
|
||||||
|
public static string NoMainFileSpecified { |
||||||
|
get { return "No main file specified."; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Reflection.Emit; |
||||||
|
using ICSharpCode.Python.Build.Tasks; |
||||||
|
using Microsoft.Build.Framework; |
||||||
|
using Microsoft.Build.Utilities; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace Python.Build.Tasks.Tests |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Tests that an error is reported when the mainFile is missing and we are trying to compile
|
||||||
|
/// an executable.
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture] |
||||||
|
public class MissingMainEntryPointTestFixture |
||||||
|
{ |
||||||
|
MockPythonCompiler mockCompiler; |
||||||
|
DummyPythonCompilerTask compiler; |
||||||
|
bool success; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
mockCompiler = new MockPythonCompiler(); |
||||||
|
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject"); |
||||||
|
compiler.TargetType = "Exe"; |
||||||
|
compiler.OutputAssembly = "test.exe"; |
||||||
|
|
||||||
|
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py"); |
||||||
|
compiler.Sources = new ITaskItem[] {sourceFile}; |
||||||
|
|
||||||
|
mockCompiler.ThrowExceptionAtCompile = new PythonCompilerException("Missing main file."); |
||||||
|
|
||||||
|
success = compiler.Execute(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ExecuteFailed() |
||||||
|
{ |
||||||
|
Assert.IsFalse(success); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IsExceptionMessageLogged() |
||||||
|
{ |
||||||
|
Assert.AreEqual("Missing main file.", compiler.LoggedErrorMessage); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Reflection.Emit; |
||||||
|
using ICSharpCode.Python.Build.Tasks; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace Python.Build.Tasks.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class PythonCompilerTests |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void NoMainFileSpecifiedForWindowsApplication() |
||||||
|
{ |
||||||
|
try { |
||||||
|
PythonCompiler compiler = new PythonCompiler(); |
||||||
|
compiler.TargetKind = PEFileKinds.WindowApplication; |
||||||
|
compiler.OutputAssembly = "test.exe"; |
||||||
|
compiler.SourceFiles = new string[0]; |
||||||
|
compiler.MainFile = null; |
||||||
|
compiler.Compile(); |
||||||
|
|
||||||
|
Assert.Fail("Expected PythonCompilerException."); |
||||||
|
} catch (PythonCompilerException ex) { |
||||||
|
Assert.AreEqual(Resources.NoMainFileSpecified, ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NoMainSpecifiedForLibraryThrowsNoError() |
||||||
|
{ |
||||||
|
PythonCompiler compiler = new PythonCompiler(); |
||||||
|
compiler.TargetKind = PEFileKinds.Dll; |
||||||
|
compiler.OutputAssembly = "test.dll"; |
||||||
|
compiler.SourceFiles = new string[0]; |
||||||
|
compiler.MainFile = null; |
||||||
|
compiler.VerifyParameters(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue