Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to copy User App Data .addin files. #30

Open
wants to merge 1 commit into
base: Revit2014
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions src/Framework/Runner/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class Runner : IRunner, IDisposable
private bool _gui = true;
private string _revitPath;
private bool _copyAddins = true;
private bool _copyUserAddins = true;
private int _timeout = 120000;
private bool _concat;
private List<string> _copiedAddins = new List<string>();
Expand Down Expand Up @@ -211,6 +212,16 @@ public bool CopyAddins
set { _copyAddins = value; }
}

/// <summary>
/// Specified whether to copy addins from the
/// User App Data Revit addin folder to the current working directory
/// </summary>
public bool CopyUserAddins
{
get { return _copyUserAddins; }
set { _copyUserAddins = value; }
}

/// <summary>
/// A timeout value in milliseconds, after which
/// any running test will be killed.
Expand Down Expand Up @@ -440,6 +451,19 @@ public void SetupTests()
}
}
}
if (CopyUserAddins)
{
var files = Directory.GetFiles(GetRevitUserAddinFolder());
foreach (var file in files)
{
if (file.EndsWith(".addin", StringComparison.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is duplicated from the part above where we copy the addins. In the spirit of leaving the code cleaner than you found it, can you refactor this copy logic into a separate method and replace it here and above?

{
var fileName = Path.GetFileName(file);
File.Copy(file, Path.Combine(WorkingDirectory, fileName), true);
CopiedAddins.Add(fileName);
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -1196,16 +1220,33 @@ private void SetupIndividualTest(ITestData td, bool continuous = false)
/// <summary>
/// This function returns the current Revit addin folder
/// </summary>
/// <returns></returns>
private string GetRevitAddinFolder()
{
var prod = GetRevitProduct();
return prod.AllUsersAddInFolder;
}

/// <summary>
/// This function returns the current user's Revit addin folder
/// </summary>
private string GetRevitUserAddinFolder()
{
var prod = GetRevitProduct();
return prod.CurrentUserAddInFolder;
}

/// <summary>
/// This function returns the Revit product
/// </summary>
private RevitProduct GetRevitProduct()
{
var prod =
Products.FirstOrDefault(
x =>
System.String.CompareOrdinal(
Path.GetDirectoryName(x.InstallLocation), Path.GetDirectoryName(RevitPath)) ==
0);
return prod.AllUsersAddInFolder;
return prod;
}

/// <summary>
Expand Down