1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Reflection;
6
using System.Reflection.Emit;
7
using IronPython.Runtime;
8
using IronPython.Runtime.Operations;
9
using ICSharpCode.Python.Build.Tasks;
10
using Microsoft.Build.Framework;
11
using Microsoft.Build.Utilities;
12
using Microsoft.Scripting;
13
using Microsoft.Scripting.Hosting;
14
using Microsoft.Scripting.Runtime;
15
using NUnit.Framework;
17
namespace Python.Build.Tasks.Tests
20
/// Tests that an IOException is caught and logged.
23
public class IOErrorTestFixture
25
MockPythonCompiler mockCompiler;
26
DummyPythonCompilerTask compiler;
32
mockCompiler = new MockPythonCompiler();
33
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
34
compiler.TargetType = "Exe";
35
compiler.OutputAssembly = "test.exe";
37
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py");
38
compiler.Sources = new ITaskItem[] {sourceFile};
40
mockCompiler.ThrowExceptionAtCompile = PythonOps.IOError("Could not find main file test.py");
42
success = compiler.Execute();
46
public void ExecuteFailed()
48
Assert.IsFalse(success);
52
public void IsExceptionMessageLogged()
54
Assert.AreEqual("Could not find main file test.py", compiler.LoggedErrorMessage);