diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs index 7842a23c5a..1dbe4dcd25 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs @@ -11,6 +11,7 @@ using System.IO; using System.Text; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; namespace ICSharpCode.RubyBinding @@ -69,13 +70,19 @@ namespace ICSharpCode.RubyBinding public ProcessStartInfo CreateProcessStartInfo(SelectedTests selectedTests) { consoleApplication.RubyScriptFileName = GetSharpDevelopTestRubyScriptFileName(); - AddLoadPaths(); + AddLoadPaths(selectedTests.Project); consoleApplication.RubyScriptCommandLineArguments = GetCommandLineArguments(selectedTests); consoleApplication.WorkingDirectory = selectedTests.Project.Directory; return consoleApplication.GetProcessStartInfo(); } - void AddLoadPaths() + void AddLoadPaths(IProject project) + { + AddLoadPathForRubyStandardLibrary(); + AddLoadPathForReferencedProjects(project); + } + + void AddLoadPathForRubyStandardLibrary() { if (options.HasRubyLibraryPath) { consoleApplication.AddLoadPath(options.RubyLibraryPath); @@ -84,6 +91,17 @@ namespace ICSharpCode.RubyBinding consoleApplication.AddLoadPath(testRunnerLoadPath); } + void AddLoadPathForReferencedProjects(IProject project) + { + foreach (ProjectItem item in project.Items) { + ProjectReferenceProjectItem projectRef = item as ProjectReferenceProjectItem; + if (projectRef != null) { + string directory = Path.GetDirectoryName(projectRef.FileName); + consoleApplication.AddLoadPath(directory); + } + } + } + string GetSharpDevelopTestRubyScriptFileName() { string fileName = StringParser.Parse(@"${addinpath:ICSharpCode.RubyBinding}\TestRunner\sdtest.rb"); diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs index 725e58c7de..3e7dcd245f 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs @@ -11,6 +11,7 @@ using System.Diagnostics; using ICSharpCode.Core; using ICSharpCode.RubyBinding; using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using NUnit.Framework; using RubyBinding.Tests.Testing; @@ -125,5 +126,36 @@ namespace RubyBinding.Tests.Testing Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments); } + + [Test] + public void CreateProcessInfoReturnsCommandLineWithDirectoriesForReferencedProjects() + { + MockCSharpProject referencedProject = new MockCSharpProject(); + referencedProject.FileName = @"c:\projects\rbproject\rbproject.rbproj"; + + MockCSharpProject unitTestProject = new MockCSharpProject(); + ProjectReferenceProjectItem projectRef = new ProjectReferenceProjectItem(unitTestProject, referencedProject); + projectRef.FileName = @"c:\projects\rbproject\pyproject.rbproj"; + ProjectService.AddProjectItem(unitTestProject, projectRef); + + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.CompilationUnit.FileName = @"d:\mytest.rb"; + FileProjectItem fileItem = new FileProjectItem(unitTestProject, ItemType.Compile); + fileItem.FileName = @"d:\mytest.rb"; + ProjectService.AddProjectItem(unitTestProject, fileItem); + + SelectedTests tests = RubySelectedTestsHelper.CreateSelectedTests(unitTestProject); + ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(tests); + + string expectedCommandLine = + "\"-Ic:\\rubybinding\\TestRunner\" " + + "\"-Ic:\\projects\\rbproject\" " + + "\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " + + "-- " + + "\"results.txt\" " + + "\"temp.tmp\""; + + Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments); + } } }