public void WildCardInDir_missing()
    {
        var directory = SourceDirectory.Replace("Tests", "Test*.Foo");
        var path      = Path.Combine(directory, "WildcardFileFinderTests.cs");

        Assert.False(WildcardFileFinder.TryFind(path, out var result));
        Assert.Null(result);
    }
    public void WildCardInDir()
    {
        var directory = SourceDirectory.Replace("Tests", "Test*");
        var path      = Path.Combine(directory, "WildcardFileFinderTests.cs");

        Assert.True(WildcardFileFinder.TryFind(path, out var result));
        Assert.True(File.Exists(result), result);
    }
    public void MultiMatchDir_order1()
    {
        var dir1 = Path.Combine(SourceDirectory, "DirForSearch", "dir1");
        var dir2 = Path.Combine(SourceDirectory, "DirForSearch", "dir2");

        Directory.SetLastWriteTime(dir2, DateTime.Now.AddDays(-1));
        Directory.SetLastWriteTime(dir1, DateTime.Now);
        var path = Path.Combine(SourceDirectory, "DirForSearch", "*", "TextFile1.txt");

        Assert.True(WildcardFileFinder.TryFind(path, out var result));
        Assert.True(File.Exists(result), result);
    }
Example #4
0
    public static bool Resolve(
        OsSettings?windows,
        OsSettings?linux,
        OsSettings?osx,
        [NotNullWhen(true)] out string?path,
        [NotNullWhen(true)] out BuildArguments?targetLeftArguments,
        [NotNullWhen(true)] out BuildArguments?targetRightArguments)
    {
        if (windows != null &&
            RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
            var paths = ExpandProgramFiles(windows.ExePaths);

            if (WildcardFileFinder.TryFindExe(paths, out path))
            {
                targetLeftArguments  = windows.TargetLeftArguments;
                targetRightArguments = windows.TargetRightArguments;
                return(true);
            }
        }

        if (linux != null &&
            RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            if (WildcardFileFinder.TryFindExe(linux.ExePaths, out path))
            {
                targetLeftArguments  = linux.TargetLeftArguments;
                targetRightArguments = linux.TargetRightArguments;
                return(true);
            }
        }

        if (osx != null &&
            RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            if (WildcardFileFinder.TryFindExe(osx.ExePaths, out path))
            {
                targetLeftArguments  = osx.TargetLeftArguments;
                targetRightArguments = osx.TargetRightArguments;
                return(true);
            }
        }

        path = null;
        targetLeftArguments  = null;
        targetRightArguments = null;
        return(false);
    }
    public static bool Resolve(
        OsSettings?windows,
        OsSettings?linux,
        OsSettings?osx,
        [NotNullWhen(true)] out string?path,
        [NotNullWhen(true)] out BuildArguments?arguments)
    {
        if (windows != null &&
            RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
            if (WildcardFileFinder.TryFindExe(windows.ExePaths, out path))
            {
                arguments = windows.Arguments;
                return(true);
            }
        }

        if (linux != null &&
            RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            if (WildcardFileFinder.TryFindExe(linux.ExePaths, out path))
            {
                arguments = linux.Arguments;
                return(true);
            }
        }

        if (osx != null &&
            RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            if (WildcardFileFinder.TryFindExe(osx.ExePaths, out path))
            {
                arguments = osx.Arguments;
                return(true);
            }
        }

        path      = null;
        arguments = null;
        return(false);
    }
 public void FullFilePath_missing()
 {
     Assert.False(WildcardFileFinder.TryFind(SourceFile.Replace(".cs", ".foo"), out var result));
     Assert.Null(result);
 }
 public void FullFilePath()
 {
     Assert.True(WildcardFileFinder.TryFind(SourceFile, out var result));
     Assert.True(File.Exists(result), result);
 }