Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4623 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 207 additions and 3 deletions
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// <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; |
||||
using System.Reflection.Emit; |
||||
using IronPython.Runtime; |
||||
using ICSharpCode.Python.Build.Tasks; |
||||
using Microsoft.Build.Framework; |
||||
using Microsoft.Build.Utilities; |
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Runtime; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Python.Build.Tasks.Tests |
||||
{ |
||||
/// <summary>
|
||||
/// If the project has a filename with a dot character in it (e.g. Resources.Designer.py) and this file
|
||||
/// has a syntax error then IronPython's ClrModule.CompileModules method will throw a syntax error exception but the
|
||||
/// filename will have a '\' replacing the dot character (i.e. Resources\Designer.py).
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class SyntaxErrorFileNameWithDotCharTestFixture |
||||
{ |
||||
MockPythonCompiler mockCompiler; |
||||
DummyPythonCompilerTask compiler; |
||||
bool success; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); |
||||
} |
||||
|
||||
[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\PythonApp.Program.py"); |
||||
compiler.Sources = new ITaskItem[] {sourceFile}; |
||||
|
||||
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"PythonApp\Program", SourceCodeKind.InteractiveCode); |
||||
|
||||
SourceLocation start = new SourceLocation(0, 1, 1); |
||||
SourceLocation end = new SourceLocation(0, 2, 3); |
||||
SourceSpan span = new SourceSpan(start, end); |
||||
SyntaxErrorException ex = new SyntaxErrorException("Error", source, span, 1000, Severity.FatalError); |
||||
mockCompiler.ThrowExceptionAtCompile = ex; |
||||
|
||||
success = compiler.Execute(); |
||||
} |
||||
|
||||
[Test] |
||||
public void SourceFile() |
||||
{ |
||||
Assert.AreEqual(@"D:\Projects\MyProject\PythonApp.Program.py", compiler.LoggedErrorFile); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// <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; |
||||
using System.Reflection.Emit; |
||||
using IronPython.Runtime; |
||||
using ICSharpCode.Python.Build.Tasks; |
||||
using Microsoft.Build.Framework; |
||||
using Microsoft.Build.Utilities; |
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Runtime; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Python.Build.Tasks.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class SyntaxErrorNullFileNameTestFixture |
||||
{ |
||||
MockPythonCompiler mockCompiler; |
||||
DummyPythonCompilerTask compiler; |
||||
bool success; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); |
||||
} |
||||
|
||||
[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}; |
||||
|
||||
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"test", SourceCodeKind.InteractiveCode); |
||||
|
||||
SyntaxErrorException ex = new SyntaxErrorException("Error", null, SourceSpan.None, 1000, Severity.FatalError); |
||||
mockCompiler.ThrowExceptionAtCompile = ex; |
||||
|
||||
success = compiler.Execute(); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsExceptionMessageLogged() |
||||
{ |
||||
Assert.AreEqual("Error", compiler.LoggedErrorMessage); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// <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; |
||||
using System.Reflection.Emit; |
||||
using IronPython.Runtime; |
||||
using ICSharpCode.Python.Build.Tasks; |
||||
using Microsoft.Build.Framework; |
||||
using Microsoft.Build.Utilities; |
||||
using Microsoft.Scripting; |
||||
using Microsoft.Scripting.Hosting; |
||||
using Microsoft.Scripting.Runtime; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Python.Build.Tasks.Tests |
||||
{ |
||||
/// <summary>
|
||||
/// If the filename returned from the SyntaxErrorException cannot be found in the project then
|
||||
/// just use the project's folder concatenated with the filename.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class SyntaxErrorUnknownFileNameTestFixture |
||||
{ |
||||
MockPythonCompiler mockCompiler; |
||||
DummyPythonCompilerTask compiler; |
||||
bool success; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); |
||||
} |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
mockCompiler = new MockPythonCompiler(); |
||||
compiler = new DummyPythonCompilerTask(mockCompiler, @"D:\Projects\MyProject"); |
||||
compiler.TargetType = "Exe"; |
||||
compiler.OutputAssembly = "test.exe"; |
||||
|
||||
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py"); |
||||
compiler.Sources = new ITaskItem[] {sourceFile}; |
||||
|
||||
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"test\unknown", SourceCodeKind.InteractiveCode); |
||||
|
||||
SourceLocation start = new SourceLocation(0, 1, 1); |
||||
SourceLocation end = new SourceLocation(0, 2, 3); |
||||
SourceSpan span = new SourceSpan(start, end); |
||||
SyntaxErrorException ex = new SyntaxErrorException("Error", source, span, 1000, Severity.FatalError); |
||||
mockCompiler.ThrowExceptionAtCompile = ex; |
||||
|
||||
success = compiler.Execute(); |
||||
} |
||||
|
||||
[Test] |
||||
public void SourceFile() |
||||
{ |
||||
Assert.AreEqual(@"D:\Projects\MyProject\test.unknown.py", compiler.LoggedErrorFile); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue