Skip to content

Commit

Permalink
Merge pull request #49 from ricaun-io/develop
Browse files Browse the repository at this point in the history
Version 1.3.5
  • Loading branch information
ricaun authored Aug 28, 2024
2 parents b706298 + 95fcf82 commit 1230bce
Show file tree
Hide file tree
Showing 31 changed files with 191 additions and 69 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.3.5] / 2024-07-22 - 2024-08-28
### Features
- Update `Application` images to support `light` and `dark` theme.
### Application
- Update project to build `net47` and `net48`.
- 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)
- Update to use `ricaun.Revit.UI.Tasks` library to run async tests.
- Update to use `ricaun.Revit.UI.Busy` library to check if revit is busy.
### 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.
- Update to use `ricaun.Revit.UI.Tasks` library to run async tests.
- Update `ApplicationUtils` check local file exists.
- Update `RevitTestConsole` with `SetCurrentDirectory` using the source test file.

## [1.3.4] / 2024-05-27
### Console
- Update `ricaun.Revit.Installation` to fix bundle not loading when Revit is open. (Fix: #46)
Expand Down Expand Up @@ -425,6 +447,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [x] TestsFail

[vNext]: ../../compare/1.0.0...HEAD
[1.3.5]: ../../compare/1.3.4...1.3.5
[1.3.4]: ../../compare/1.3.3...1.3.4
[1.3.3]: ../../compare/1.3.2...1.3.3
[1.3.2]: ../../compare/1.3.1...1.3.2
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.4</Version>
<Version>1.3.5</Version>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Nuke](https://img.shields.io/badge/Nuke-Build-blue)](https://nuke.build/)
[![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Build](https://github.com/ricaun-io/ricaun.RevitTest/actions/workflows/Build.yml/badge.svg)](https://github.com/ricaun-io/ricaun.RevitTest/actions)
[![Release](https://img.shields.io/nuget/v/ricaun.RevitTest.TestAdapter?logo=nuget&label=release&color=blue)](https://www.nuget.org/packages/ricaun.RevitTest.TestAdapter)
[![nuget](https://img.shields.io/nuget/v/ricaun.RevitTest.TestAdapter?logo=nuget&label=nuget&color=blue)](https://www.nuget.org/packages/ricaun.RevitTest.TestAdapter)

[![ricaun.RevitTest](https://raw.githubusercontent.com/ricaun/test-assets/main/assets/ricaun.RevitTest.png)](https://github.com/ricaun-io/ricaun.RevitTest)

Expand All @@ -23,7 +23,7 @@ For more information see [Wiki](https://github.com/ricaun-io/ricaun.RevitTest/wi

## License

This project is [licensed](LICENSE) under the [MIT Licence](https://en.wikipedia.org/wiki/MIT_License).
This project is [licensed](LICENSE) under the [MIT License](https://en.wikipedia.org/wiki/MIT_License).

---

Expand Down
4 changes: 2 additions & 2 deletions README.old.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ For more information see [Wiki](https://github.com/ricaun-io/ricaun.RevitTest/wi
#### Application
* [ricaun.NUnit](https://github.com/ricaun-io/ricaun.NUnit)
* [ricaun.Revit.UI](https://github.com/ricaun-io/ricaun.Revit.UI)
* [ricaun.Revit.Async](https://github.com/ricaun-io/ricaun.Revit.Async)
* [Revit.Busy](https://github.com/ricaun-io/Revit.Busy)
* [ricaun.Revit.UI.Tasks](https://github.com/ricaun-io/ricaun.Revit.UI.Tasks)
* [ricaun.Revit.UI.Busy](https://github.com/ricaun-io/ricaun.Revit.UI.Busy)
* [ricaun.RevitTest.Shared](ricaun.RevitTest.Shared)
#### Console
* [ricaun.Revit.Installation](https://github.com/ricaun-io/ricaun.Revit.Installation)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 4 additions & 5 deletions ricaun.RevitTest.Application/Revit/App.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Revit.Busy;
using ricaun.NUnit;
using ricaun.NUnit.Models;
using ricaun.Revit.Async.Services;
using ricaun.Revit.UI.Busy;
using ricaun.Revit.UI.Tasks;
using ricaun.Revit.UI;
using ricaun.RevitTest.Application.Revit.Utils;
using ricaun.RevitTest.Shared;
Expand Down Expand Up @@ -35,9 +35,8 @@ public Result OnStartup(UIControlledApplication application)
RevitBusyService = new RevitBusyService(application);
RevitBusyService.PropertyChanged += RevitBusyControlPropertyChanged;

RevitTask = new RevitTaskService();
RevitTask = new RevitTaskService(application);
RevitTask.Initialize();
ricaun.Revit.Async.RevitTask.Initialize();

Log.WriteLine();
Log.WriteLine($"{AppUtils.GetInfo()}");
Expand Down Expand Up @@ -150,7 +149,7 @@ private static void PipeTestServer_Initialize()
catch (Exception ex)
{
Log.WriteLine($"TestExecuteUtils: Exception {ex}");
var exceptionFail = new Exception("TestExecuteUtils.Execute Fails", ex);
var exceptionFail = new Exception($"TestExecuteUtils.Execute Fails ({ex.Message})", ex);
testAssemblyModel = TestEngine.Fail(message.TestPathFile, exceptionFail, testFilterNames);
}

Expand Down
10 changes: 5 additions & 5 deletions ricaun.RevitTest.Application/Revit/Utils/RibbonUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace ricaun.RevitTest.Application.Revit
{
public static class RibbonUtils
{
public static string RevitTest { get; } = GetComponentImage("test-pass");
public static string TestPass { get; } = GetComponentImage("test-pass");
public static string TestFail { get; } = GetComponentImage("test-fail");
public static string TestSkip { get; } = GetComponentImage("test-skip");
public static string TestWait { get; } = GetComponentImage("test-wait");
public static string RevitTest { get; } = GetComponentImage("test-pass-light");
public static string TestPass { get; } = GetComponentImage("test-pass-light");
public static string TestFail { get; } = GetComponentImage("test-fail-light");
public static string TestSkip { get; } = GetComponentImage("test-skip-light");
public static string TestWait { get; } = GetComponentImage("test-wait-light");
public static string GetComponentImage(string imageName)
{
return string.Format("Images/{0}.ico", imageName);
Expand Down
15 changes: 8 additions & 7 deletions ricaun.RevitTest.Application/Revit/Utils/TestExecuteUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ricaun.NUnit;
using ricaun.NUnit.Models;
using ricaun.Revit.Async.Services;
using ricaun.Revit.UI.Tasks;
using System;
using System.Diagnostics;
using System.IO;
Expand All @@ -12,24 +12,26 @@ 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}");
var zipFile = await revitTask.Run(() => CopyFilesUsingZipFolder(filePath));

if (zipFile is null)
{
Log.WriteLine($"TestExecuteUtils: Copy Zip Fail");
return null;
throw new Exception("Copy Zip Fail");
}

string zipDestination = null;
var extractToTempSucess = await revitTask.Run(() => ZipExtension.ExtractToTempFolder(zipFile, out zipDestination));

if (extractToTempSucess == false)
{
Log.WriteLine($"TestExecuteUtils: Extract Zip Fail");
return null;
throw new Exception("Extract Zip Fail");
}

//TestAssemblyModel tests = await revitTask.Run(() => TestDirectory(zipDestination, parameters));
Expand All @@ -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
42 changes: 30 additions & 12 deletions ricaun.RevitTest.Application/ricaun.RevitTest.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,24 @@

<!-- RevitVersion -->
<PropertyGroup>
<TargetFrameworks>net46;net8.0-windows</TargetFrameworks>
<TargetFrameworks>net46;net47;net48;net8.0-windows</TargetFrameworks>
</PropertyGroup>
<Choose>
<When Condition="$(TargetFramework.StartsWith('net4'))">
<When Condition="$(TargetFramework.StartsWith('net46'))">
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net47'))">
<PropertyGroup>
<RevitVersion>2019</RevitVersion>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net48'))">
<PropertyGroup>
<RevitVersion>2021</RevitVersion>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<RevitVersion>2025</RevitVersion>
Expand Down Expand Up @@ -90,16 +100,20 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Images\test-fail.ico" />
<None Remove="Images\test-pass.ico" />
<None Remove="Images\test-skip.ico" />
<None Remove="Images\test-wait.ico" />
<None Remove="Images\test-fail-dark.ico" />
<None Remove="Images\test-fail-light.ico" />
<None Remove="Images\test-pass-dark.ico" />
<None Remove="Images\test-pass-light.ico" />
<None Remove="Images\test-skip-dark.ico" />
<None Remove="Images\test-skip-light.ico" />
<None Remove="Images\test-wait-dark.ico" />
<None Remove="Images\test-wait-light.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Revit.Busy" Version="*" />
<PackageReference Include="ricaun.Revit.UI" Version="*" />
<PackageReference Include="ricaun.Revit.Async" Version="*" />
<PackageReference Include="ricaun.Revit.UI.Tasks" Version="*" />
<PackageReference Include="ricaun.Revit.UI.Busy" Version="*" />
<PackageReference Include="ricaun.NUnit" Version="*" />
</ItemGroup>

Expand Down Expand Up @@ -147,10 +161,14 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Images\test-fail.ico" />
<Resource Include="Images\test-pass.ico" />
<Resource Include="Images\test-skip.ico" />
<Resource Include="Images\test-wait.ico" />
<Resource Include="Images\test-fail-dark.ico" />
<Resource Include="Images\test-fail-light.ico" />
<Resource Include="Images\test-pass-dark.ico" />
<Resource Include="Images\test-pass-light.ico" />
<Resource Include="Images\test-skip-dark.ico" />
<Resource Include="Images\test-skip-light.ico" />
<Resource Include="Images\test-wait-dark.ico" />
<Resource Include="Images\test-wait-light.ico" />
</ItemGroup>

</Project>
Binary file not shown.
6 changes: 6 additions & 0 deletions ricaun.RevitTest.Console/Revit/Utils/RevitTestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ public static string[] GetTestFullNames(string filePath)
Log.WriteLine($"RevitTestUtils: {revitInstallation.InstallLocation}");
tests = TestEngine.GetTestFullNames(filePath, revitInstallation.InstallLocation);
}

if (tests.Length == 0)
{
throw new Exception($"Unable to read tests class using the Revit version {revitVersion}.");
}
}

#if DEBUG
LoggerTest($"Test °C");
LoggerTest($"Length {tests.Length}");
LoggerTest($"TestEngine {TestEngine.Version.ToString(3)}");
LoggerTest($"{AppUtils.GetInfo()}");
if (LoggerTests.Any())
{
LoggerTests.AddRange(tests);
Expand Down
Binary file not shown.
Binary file not shown.
22 changes: 17 additions & 5 deletions ricaun.RevitTest.TestAdapter/Services/ApplicationUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ public static async Task<bool> DownloadAsync(string applicationFolder, string ad
{
if (LocalFileExists(address, out string localFilePath))
{
File.Copy(localFilePath, zipPath, true);
if (Path.GetExtension(localFilePath) == ZIP_FILE_EXTENSION)
{
File.Copy(localFilePath, zipPath, true);
}
else
{
zipPath = Path.ChangeExtension(zipPath, ZIP_FILE_EXTENSION);
ZipFile.CreateFromDirectory(Path.GetDirectoryName(localFilePath), zipPath);
}
AdapterLogger.Logger.DebugOnlyLocal($"Download File CurrentDirectory: {Directory.GetCurrentDirectory()}");
AdapterLogger.Logger.DebugOnlyLocal($"Download File Exists: {localFilePath}");
}
Expand Down Expand Up @@ -139,14 +147,18 @@ public static async Task<bool> DownloadAsync(string applicationFolder, string ad
private static bool LocalFileExists(string filePath, out string localFilePath)
{
localFilePath = filePath;

if (File.Exists(localFilePath)) return true;

try
{
var assemblyDirectory = Path.GetDirectoryName(typeof(ApplicationUtils).Assembly.Location);
localFilePath = Path.Combine(assemblyDirectory, filePath);
var currentDirectory = Directory.GetCurrentDirectory();
localFilePath = Path.Combine(currentDirectory, filePath);
localFilePath = new FileInfo(localFilePath).FullName;
AdapterLogger.Logger.Debug($"Application LocalFileCheck: {localFilePath}");
if (File.Exists(localFilePath))
{
AdapterLogger.Logger.DebugOnlyLocal($"Download File AssemblyDirectory: {assemblyDirectory}");
AdapterLogger.Logger.DebugOnlyLocal($"Download LocalFileCheck: {localFilePath}");
return true;
}
}
Expand All @@ -161,7 +173,7 @@ private static bool LocalFileExists(string filePath, out string localFilePath)
/// <param name="address"></param>
/// <param name="downloadFileException"></param>
/// <returns></returns>
public static async Task<bool> DownloadAsyncWeb(string applicationFolder, string address, Action<Exception> downloadFileException = null)
private static async Task<bool> DownloadAsyncWeb(string applicationFolder, string address, Action<Exception> downloadFileException = null)
{
var fileName = Path.GetFileName(address);
var zipPath = Path.Combine(applicationFolder, fileName);
Expand Down
6 changes: 6 additions & 0 deletions ricaun.RevitTest.TestAdapter/Services/ProcessStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ public async Task Run(Action<string> consoleAction, Action<string> errorAction =
var arguments = CreateArguments();
Debug.WriteLine($"Run: {arguments}");

AdapterLogger.Logger.DebugOnlyLocal($"ProcessStart: {processPath}");
AdapterLogger.Logger.DebugOnlyLocal($"ProcessStart.Run: {arguments}");

foreach (var item in System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(processPath)))
{
AdapterLogger.Logger.DebugOnlyLocal($"ProcessStart.File: {item}");
}

await Run(arguments, consoleAction, errorAction);
}

Expand Down
19 changes: 14 additions & 5 deletions ricaun.RevitTest.TestAdapter/Services/RevitTestConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ private string ValidadeApplication(string applicationPath, bool showApplicationN
return null;
}

public RevitTestConsole(string application = null)
public RevitTestConsole(string application = null, string sourceFile = null)
{
if (!string.IsNullOrEmpty(sourceFile))
{
var directory = Path.GetDirectoryName(sourceFile);
if (Directory.Exists(directory))
Directory.SetCurrentDirectory(directory);
}

applicationPath = ValidadeApplication(application, true);
if (applicationPath is null)
{
Expand Down Expand Up @@ -103,6 +110,7 @@ public async Task RunTestAction(
bool revitOpen = false,
bool revitClose = false,
Action<string> consoleAction = null,
Action<string> errorAction = null,
params string[] filter)
{
await new RevitTestProcessStart(applicationPath)
Expand All @@ -115,10 +123,10 @@ public async Task RunTestAction(
.SetLog()
.SetTestFilter(filter)
.SetDebugger(System.Diagnostics.Debugger.IsAttached)
.Run(consoleAction);
.Run(consoleAction, errorAction);
}

public async Task<string[]> RunTestRead(string file)
private async Task<string[]> RunTestRead(string file)
{
var read = await new RevitTestProcessStart(applicationPath)
.SetFile(file)
Expand All @@ -132,14 +140,15 @@ public async Task<string[]> RunTestRead(string file)

public async Task RunTestReadWithLog(
string file,
Action<string> consoleAction)
Action<string> consoleAction,
Action<string> errorAction = null)
{
await new RevitTestProcessStart(applicationPath)
.SetFile(file)
.SetOutputConsole()
.SetRead()
.SetLog()
.Run(consoleAction);
.Run(consoleAction, errorAction);
}

public void Dispose()
Expand Down
Loading

0 comments on commit 1230bce

Please sign in to comment.