Skip to content

Commit d9ae3b5

Browse files
committed
Support for pluggable agents
1 parent 468118c commit d9ae3b5

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

recipe/chocolatey-package.cake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ public class ChocolateyPackage : PackageDefinition
4141
ArgumentCustomization = args => args.Append($"BIN_DIR={BuildSettings.OutputDirectory}")
4242
});
4343
}
44+
45+
protected override bool IsRemovableExtension(string id)
46+
{
47+
return
48+
id.StartsWith("nunit-extension-") &&
49+
!id.StartsWith(PackageId) &&
50+
!id.Contains("pluggable-agent");
51+
}
4452
}

recipe/nuget-package.cake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,12 @@ public class NuGetPackage : PackageDefinition
9999
else
100100
throw new Exception("Verification failed!");
101101
}
102+
103+
protected override bool IsRemovableExtension(string id)
104+
{
105+
return
106+
id.StartsWith("NUnit.Extension.") &&
107+
!id.StartsWith(PackageId) &&
108+
!id.Contains("PluggableAgent");
109+
}
102110
}

recipe/package-definition.cake

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,15 @@ public abstract class PackageDefinition
210210
// Ensure we start out each package with no extensions installed.
211211
// If any package test installs an extension, it remains available
212212
// for subsequent tests of the same package only.
213-
RemoveExtensions();
213+
foreach (DirectoryPath dirPath in _context.GetDirectories(ExtensionInstallDirectory + "*"))
214+
{
215+
string dirName = dirPath.Segments.Last();
216+
if (IsRemovableExtension(dirName))
217+
{
218+
_context.DeleteDirectory(dirPath, new DeleteDirectorySettings() { Recursive = true });
219+
_context.Information("Deleted directory " + dirPath.GetDirectoryName());
220+
}
221+
}
214222

215223
// Package was defined with one or more TestRunners. These
216224
// may or may not require installation.
@@ -297,20 +305,7 @@ public abstract class PackageDefinition
297305
extension.InstallExtension(this);
298306
}
299307

300-
// Remove all extensions prior to starting a run. Note that we avoid removing the the
301-
// package being developed, which may actually be an extension itself.
302-
protected void RemoveExtensions()
303-
{
304-
foreach (DirectoryPath dirPath in _context.GetDirectories(ExtensionInstallDirectory + "*"))
305-
{
306-
string dirName = dirPath.Segments.Last();
307-
if ((dirName.StartsWith("NUnit.Extension.") || dirName.StartsWith("nunit-extension-")) && !dirName.StartsWith(PackageId))
308-
{
309-
_context.DeleteDirectory(dirPath, new DeleteDirectorySettings() { Recursive = true });
310-
_context.Information("Deleted directory " + dirPath.GetDirectoryName());
311-
}
312-
}
313-
}
308+
protected abstract bool IsRemovableExtension(string dirName);
314309

315310
private void InstallRunners(IEnumerable<IPackageTestRunner> runners)
316311
{

recipe/zip-package.cake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,12 @@ public class ZipPackage : PackageDefinition
6565

6666
_context.CopyDirectory(BuildSettings.ExtensionsDirectory, BuildSettings.ZipImageDirectory);
6767
}
68+
69+
protected override bool IsRemovableExtension(string id)
70+
{
71+
return
72+
id.StartsWith("NUnit.Extension.") &&
73+
!id.StartsWith(PackageId) &&
74+
!id.Contains("PluggableAgent");
75+
}
6876
}

0 commit comments

Comments
 (0)