Skip to content

Commit

Permalink
Improve: Path too long for the tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Aug 14, 2024
1 parent be17137 commit 9aa8e21
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Update `Images` with light and dark theme.
- Update `ricaun.Revit.UI` with the image auto theme based in the `light` and `dark` in the file name.
- Update `Exception` when null.
- Update timestamp in temp folder to hexadecimal.
- Update test folder to temporarty the folder `RevitTest` to reduce the `PathTooLongException`. (Fix #48)
### Console
- Throw exception when `RevitTestUtils` is empty.
### TestAdapter
- Show Warning when Console fails.
- Fix local file copy to temporary by zip folder.
- Add `TestsFilePathTooLong` to similate long path inside test.

## [1.3.4] / 2024-05-27
### Console
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.3.5-alpha</Version>
<Version>1.3.5-beta</Version>
</PropertyGroup>
</Project>
5 changes: 3 additions & 2 deletions ricaun.RevitTest.Application/Revit/Utils/TestExecuteUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace ricaun.RevitTest.Application.Revit
{
public static class TestExecuteUtils
{
private const string FOLDER_NAME_TEMP = "RevitTest";

public static async Task<TestAssemblyModel> ExecuteAsync(IRevitTask revitTask, string filePath, params object[] parameters)
{
Log.WriteLine($"TestExecuteUtils: {filePath}");
Expand Down Expand Up @@ -44,8 +46,7 @@ private static string CopyFilesUsingZipFolder(string filePath)
if (filePath is null)
return null;

var location = Assembly.GetExecutingAssembly().Location;
var directory = Path.GetDirectoryName(location);
var directory = Path.Combine(Path.GetTempPath(), FOLDER_NAME_TEMP);

if (Path.GetExtension(filePath).EndsWith("dll") == false)
return null;
Expand Down
2 changes: 1 addition & 1 deletion ricaun.RevitTest.Application/Revit/Utils/ZipExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static bool ExtractToTempFolder(string zipFile, out string zipDestination

if (Directory.Exists(zipDestination))
{
zipDestination += $"_{DateTime.Now.Ticks}";
zipDestination += $"_{DateTime.Now.Ticks:X}";
}

Directory.CreateDirectory(zipDestination);
Expand Down
15 changes: 15 additions & 0 deletions ricaun.RevitTest.Tests/TestsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,19 @@ public void Test3FileDelete()
}

}

public class TestsFilePathTooLong
{
const string FILE_NAME = "file-path-too-long.txt";
private string GetBigPathFileName() => Path.Combine(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), FILE_NAME);
[Test]
public void TestFileInfo()
{
// if path too long the `PathTooLongException` happens. Only in .NET Framework, not in .NET Core.
var path = GetBigPathFileName();
var fileInfo = new FileInfo(path);
var lenght = fileInfo.FullName.Length;
Console.WriteLine($"FullLenght: {lenght} TestLenght:{path.Length}");
}
}
}

0 comments on commit 9aa8e21

Please sign in to comment.