Skip to content

Commit

Permalink
Better support for parallel execution via vstest.console.exe:
Browse files Browse the repository at this point in the history
- Non-lock source file copy
- Don't overwrite dependencies to avoid file locking errors when test assemblies are in the same folder and parallel execution is used.

Bump to Beta 2
  • Loading branch information
ivanz committed Mar 8, 2016
1 parent 2437131 commit 8da8385
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions Source/Machine.VSTestAdapter.VSIX/License.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2012, 2013, 2014, 2015 Jonathan Wilkins
Copyright (c) 2016 Ivan Zlatev

This license governs use of the accompanying software. If you use the software, you
accept this license. If you do not accept the license, do not use the software.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,27 @@ private static AppDomain CreateAppDomain(string assemblyPath, string appName)

private static void CopyRequiredRuntimeDependencies(IEnumerable<Assembly> assemblies, string destination)
{
foreach (Assembly assembly in assemblies)
{
foreach (Assembly assembly in assemblies) {
string assemblyLocation = assembly.Location;
string assemblyName = Path.GetFileName(assemblyLocation);
string assemblyFileDestination = Path.Combine(destination, assemblyName);
File.Copy(assemblyLocation, assemblyFileDestination, true);
if (!File.Exists(assemblyFileDestination))
CopyWithoutLockingSourceFile(assemblyLocation, assemblyFileDestination);
}
}

private static void CopyWithoutLockingSourceFile(string sourceFile, string destinationFile)
{
const int BUFFER_SIZE = 10 * 1024;

using (FileStream inputFile = new FileStream(sourceFile, FileMode.Open, FileAccess.Read, FileShare.Read, BUFFER_SIZE))
using (FileStream outputFile = new FileStream(destinationFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None, BUFFER_SIZE)) {
byte[] buffer = new byte[BUFFER_SIZE];
int bytes;

while ((bytes = inputFile.Read(buffer, 0, buffer.Length)) > 0) {
outputFile.Write(buffer, 0, bytes);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
nuget_version: '2.0.0-beta1'
nuget_version: '2.0.0-beta2'
vsix_version: '2.0.0'
assembly_version: '2.0.0'

Expand Down

0 comments on commit 8da8385

Please sign in to comment.