Test loaded from remote folder failed to run with exception System.IODirectory Not Found .

Bug #1029785 reported by Hitesh Bhagwat
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Fix Released
High
Charlie Poole
NUnit V2
Fix Released
Wishlist
Charlie Poole
NUnitLite
Fix Released
High
Charlie Poole

Bug Description

When we load test from remote machine folder as \\MachineName\TestFolderName project loads successfully.But when I tried to run same tests it throws exception as follow

System.IODirectory Not Found :Could Not Found Part of the Path 'D:\NUnitProject\bin\Debug\MachineName\TestFolderName'.

Above scenario was working fine in NUnit-2.5.10.11092. When I tried to find out cause of this issue ,I find that there are changes in
NUnit.Core.AssemblyHelper class.Differnces between these two versions are as follow

NUnit-2.5.10.11092

 public static string GetAssemblyPath(Type type)
{
     return GetAssemblyPath(type.Assembly);
}

public static string GetAssemblyPath(Assembly assembly)
{
 string path = assembly.CodeBase;
 Uri uri = new Uri(path);

 // If it wasn't loaded locally, use the Location
 if (!uri.IsFile)
 return assembly.Location;

 if (uri.IsUnc)
 return path.Substring(Uri.UriSchemeFile.Length + 1);

 return uri.LocalPath;
}

public static string GetDirectoryName( Assembly assembly )
{
   return System.IO.Path.GetDirectoryName(GetAssemblyPath(assembly));
}

Whereas the code in NUnit version 2.6 is as follow

#region GetAssemblyPath

        public static string GetAssemblyPath(Type type)
        {
            return GetAssemblyPath(type.Assembly);
        }

        public static string GetAssemblyPath(Assembly assembly)
        {
              string uri = assembly.CodeBase;

              if (IsFileUri(uri))
                 return GetAssemblyPathFromFileUri(uri);
              else
                 return assembly.Location;
         }

        #endregion

        #region

        // Public for testing purposes
        public static string GetAssemblyPathFromFileUri(string uri)
        {
            // Skip over the file://
            int start = Uri.UriSchemeFile.Length + Uri.SchemeDelimiter.Length;

            if (System.IO.Path.DirectorySeparatorChar == '\\')
            {
                // Handle Windows Drive specifications
                if (uri[start] == '/' && uri[start + 2] == ':')
                    ++start;
            }
            else
            {
                // Assume all Linux paths are absolute
                if (uri[start] != '/')
                    --start;
            }

            return uri.Substring(start);
        }

        #endregion

        #region GetDirectoryName
        public static string GetDirectoryName( Assembly assembly )
        {
            return System.IO.Path.GetDirectoryName(GetAssemblyPath(assembly));
        }
        #endregion

        #region Helper Methods

        private static bool IsFileUri(string uri)
        {
            return uri.ToLower().StartsWith(Uri.UriSchemeFile);
        }

        #endregion

Related branches

Revision history for this message
Hitesh Bhagwat (hiteshbhagwat) wrote :
description: updated
Revision history for this message
Jv (jv-ravichandran) wrote : Re: [Bug 1029785] Re: Test loaded from remote folder failed to run with exception System.IODirectory Not Found .
Download full text (10.2 KiB)

Looks like some test method got checked in?

The portion below

- // Public for testing purposes
- public static string GetAssemblyPathFromFileUri(string uri)
- {
- // Skip over the file://
- int start = Uri.UriSchemeFile.Length +
Uri.SchemeDelimiter.Length;
+ #endregion

- if (System.IO.Path.DirectorySeparatorChar == '\\')
- {
- // Handle Windows Drive specifications
- if (uri[start] == '/' && uri[start + 2] == ':')
- ++start;
- }

Regards,

Jv

On Fri, Jul 27, 2012 at 12:16 PM, hiteshbhagwat <email address hidden>wrote:

> ** Attachment added: "RunFailed.PNG"
>
> https://bugs.launchpad.net/bugs/1029785/+attachment/3238062/+files/RunFailed.PNG
>
> ** Description changed:
>
> When we load test from remote machine folder as
> - \\MachineName\TestFolderName load test project Successfully. But when I
> - tried to run same tests it throws exception as follow
> + \\MachineName\TestFolderName project loads successfully.But when I tried
> + to run same tests it throws exception as follow
>
> System.IODirectory Not Found :Could Not Found Part of the Path
> 'D:\NUnitProject\bin\Debug\MachineName\TestFolderName'.
>
> - Above scenario was working fine in NUnit-2.5.10.11092. When I tried to
> find out cause of this issue ,I find that there are changes in
> - NUnit.Core.AssemblyHelper class differnces are as follow
> + Above scenario was working fine in NUnit-2.5.10.11092. When I tried to
> find out cause of this issue ,I find that there are changes in
> + NUnit.Core.AssemblyHelper class.Differnces between these two versions
> are as follow
>
> NUnit-2.5.10.11092
>
> - public static string GetAssemblyPath(Type type)
> - {
> - return GetAssemblyPath(type.Assembly);
> - }
> -
> -
> - public static string GetAssemblyPath(Assembly assembly)
> + public static string GetAssemblyPath(Type type)
> {
> - string path = assembly.CodeBase;
> - Uri uri = new Uri(path);
> -
> - // If it wasn't loaded locally, use the Location
> - if (!uri.IsFile)
> - return assembly.Location;
> -
> - if (uri.IsUnc)
> - return path.Substring(Uri.UriSchemeFile.Length + 1);
> -
> - return uri.LocalPath;
> + return GetAssemblyPath(type.Assembly);
> }
>
> - #endregion
> + public static string GetAssemblyPath(Assembly assembly)
> + {
> + string path = assembly.CodeBase;
> + Uri uri = new Uri(path);
>
> - #region GetDirectoryName
> - public static string GetDirectoryName( Assembly assembly )
> - {
> - return
> System.IO.Path.GetDirectoryName(GetAssemblyPath(assembly));
> - }
> - #endregion
> + // If it wasn't loaded locally, use the Location
> + if (!uri.IsFile)
> + return assembly.Location;
> +
> + if (uri.IsUnc)
> + return path.Substring(Uri.UriSchemeFile.Length + 1);
> +
> + return uri.LocalPath;
> + }
> +
> + public static string GetDirectoryName( Assembly assembly )
> + {
> + return System.IO.Path.GetDirectoryName(GetAssemblyPath(assembly));
> + }
> +
>
>
> - Whereas the code...

Revision history for this message
Hitesh Bhagwat (hiteshbhagwat) wrote :

Hi JV,

Thant is not a Test Method code.That code belongs to NUnit.Core.AssemblyHelper class.It shows differnce between two versions.

Regards
Hitesh

Revision history for this message
Jv (jv-ravichandran) wrote :
Download full text (3.8 KiB)

Yes but the comment says for testing purposes.

Jv

On Fri, Jul 27, 2012 at 2:23 PM, Hitesh Bhagwat <email address hidden>wrote:

> Hi JV,
>
> Thant is not a Test Method code.That code belongs to
> NUnit.Core.AssemblyHelper class.It shows differnce between two versions.
>
> Regards
> Hitesh
>
> --
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
> https://bugs.launchpad.net/bugs/1029785
>
> Title:
> Test loaded from remote folder failed to run with exception
> System.IODirectory Not Found .
>
> Status in NUnit V2 Test Framework:
> New
>
> Bug description:
> When we load test from remote machine folder as
> \\MachineName\TestFolderName project loads successfully.But when I
> tried to run same tests it throws exception as follow
>
> System.IODirectory Not Found :Could Not Found Part of the Path
> 'D:\NUnitProject\bin\Debug\MachineName\TestFolderName'.
>
> Above scenario was working fine in NUnit-2.5.10.11092. When I tried to
> find out cause of this issue ,I find that there are changes in
> NUnit.Core.AssemblyHelper class.Differnces between these two versions
> are as follow
>
> NUnit-2.5.10.11092
>
> public static string GetAssemblyPath(Type type)
> {
> return GetAssemblyPath(type.Assembly);
> }
>
> public static string GetAssemblyPath(Assembly assembly)
> {
> string path = assembly.CodeBase;
> Uri uri = new Uri(path);
>
> // If it wasn't loaded locally, use the Location
> if (!uri.IsFile)
> return assembly.Location;
>
> if (uri.IsUnc)
> return path.Substring(Uri.UriSchemeFile.Length + 1);
>
> return uri.LocalPath;
> }
>
> public static string GetDirectoryName( Assembly assembly )
> {
> return System.IO.Path.GetDirectoryName(GetAssemblyPath(assembly));
> }
>
>
>
>
>
> Whereas the code in NUnit version 2.6 is as follow
>
>
> #region GetAssemblyPath
>
> public static string GetAssemblyPath(Type type)
> {
> return GetAssemblyPath(type.Assembly);
> }
>
> public static string GetAssemblyPath(Assembly assembly)
> {
> string uri = assembly.CodeBase;
>
> if (IsFileUri(uri))
> return GetAssemblyPathFromFileUri(uri);
> else
> return assembly.Location;
> }
>
> #endregion
>
> #region
>
> // Public for testing purposes
> public static string GetAssemblyPathFromFileUri(string uri)
> {
> // Skip over the file://
> int start = Uri.UriSchemeFile.Length +
> Uri.SchemeDelimiter.Length;
>
> if (System.IO.Path.DirectorySeparatorChar == '\\')
> {
> // Handle Windows Drive specifications
> if (uri[start] == '/' && uri[start + 2] == ':')
> ++start;
> }
> else
> {
> // Assume all Linux paths are absolute
> if (uri[start] != '/')
> --start;
> }
>
> return uri.Substring(star...

Read more...

Revision history for this message
Charlie Poole (charlie.poole) wrote :

@JV: The comment means what it says... the method is made public so it can be tested. This is a common practice and has nothing to do with the bug report.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

Running tests from a remote folder expressed as a UNC path has never actually been supported by NUnit - even if it seemed to be working in 2.5.10. The standard approach is to assign a file letter to the remote share and use that in the path to the test assembly.

However, I'll look at the change and see if we can put back the functionality that was working for you. For NUnit 3.0, we'll examine the possibility of officially supporting UNC paths.

Changed in nunitv2:
status: New → Triaged
importance: Undecided → Wishlist
Changed in nunitv2:
assignee: nobody → Simone Busoli (simone.busoli)
Changed in nunitv2:
status: Triaged → In Progress
Changed in nunitv2:
assignee: Simone Busoli (simone.busoli) → Charlie Poole (charlie.poole)
Changed in nunitv2:
status: In Progress → Fix Committed
milestone: none → 2.6.2
Revision history for this message
Charlie Poole (charlie.poole) wrote :

We are currently using two approaches, one for .NET 1.1 and a simpler approach for .NET 2.0 and higher.

For NUnitLite, we need to continue with both approaches but for NUnit 3.0, we can use the new approach exclusively.

Changed in nunitv2:
assignee: Charlie Poole (charlie.poole) → Simone Busoli (simone.busoli)
assignee: Simone Busoli (simone.busoli) → Charlie Poole (charlie.poole)
Changed in nunitlite:
status: New → Triaged
importance: Undecided → High
Changed in nunit-3.0:
status: New → Triaged
importance: Undecided → High
Changed in nunitv2:
status: Fix Committed → Fix Released
Changed in nunitlite:
milestone: none → 0.9
Changed in nunitlite:
status: Triaged → Fix Committed
Changed in nunitlite:
assignee: nobody → Charlie Poole (charlie.poole)
Changed in nunit-3.0:
milestone: none → 2.9.6
Changed in nunitlite:
status: Fix Committed → Fix Released
Changed in nunit-3.0:
assignee: nobody → Charlie Poole (charlie.poole)
status: Triaged → Fix Committed
Changed in nunit-3.0:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.