Skip to content

Commit

Permalink
Fix build path for debug launcher targets (#6605)
Browse files Browse the repository at this point in the history
* Fix build path for debug launcher targets

* Try fixing intermittent test case failure

* Add more logging

* Connection events were coming in AFTER process exit. Just wait for connection
  • Loading branch information
rchiodo authored Jul 14, 2021
1 parent 7cf41e1 commit 984cd41
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
10 changes: 9 additions & 1 deletion Build/Common.Build.Core.settings
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@
<VSTargetName Condition="'$(VSTarget)' == '12.0'">2013</VSTargetName>
<VSTargetName Condition="'$(VSTarget)' == '11.0'">2012</VSTargetName>
<VSTargetName Condition="'$(VSTarget)' == '10.0'">2010</VSTargetName>


<VCTargetVersion Condition="'$(VSTarget)' == '17.0'">v170</VCTargetVersion>
<VCTargetVersion Condition="'$(VSTarget)' == '16.0'">v160</VCTargetVersion>
<VCTargetVersion Condition="'$(VSTarget)' == '15.0'">v150</VCTargetVersion>
<VCTargetVersion Condition="'$(VSTarget)' == '14.0'">v140</VCTargetVersion>
<VCTargetVersion Condition="'$(VSTarget)' == '12.0'">v120</VCTargetVersion>
<VCTargetVersion Condition="'$(VSTarget)' == '11.0'">v110</VCTargetVersion>
<VCTargetVersion Condition="'$(VSTarget)' == '10.0'">v100</VCTargetVersion>

<BuildNumber Condition="'$(BuildNumber)' == ''">$(BUILD_BUILDNUMBER)</BuildNumber>
<BuildNumber Condition="'$(BuildNumber)' == ''">1000.00</BuildNumber>
<!--
Expand Down
2 changes: 1 addition & 1 deletion Python/Prerequisites/deploy_test_targets.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if not exist "%TARGET%" mkdir "%TARGET%"
copy /Y "*.targets" "%TARGET%"
popd

set TARGET=%VSINSTALLDIR%\MSBuild\Microsoft\VC\v160\Platforms
set TARGET=%VSINSTALLDIR%\MSBuild\Microsoft\VC\v170\Platforms
pushd "%D%..\Product\VCDebugLauncher\VCTargets"
echo.
echo Copying:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ sealed class TestRunner : IDisposable {
private readonly int _debugPort;
private readonly ManualResetEvent _cancelRequested;
private readonly ManualResetEvent _connected = new ManualResetEvent(false);
private bool _connectionActivated = false;
private readonly AutoResetEvent _done = new AutoResetEvent(false);
private Connection _connection;
private readonly Socket _socket;
Expand Down Expand Up @@ -294,6 +295,7 @@ private static string GetSearchPaths(IEnumerable<TestCase> tests, PythonProjectS
}

private void AcceptConnection(IAsyncResult iar) {
Info("Connected to socket");
Socket socket;
var socketSource = ((Socket)iar.AsyncState);
try {
Expand All @@ -306,7 +308,7 @@ private void AcceptConnection(IAsyncResult iar) {
Debug.WriteLine("DebugConnectionListener socket closed");
return;
}

_connectionActivated = true;
var stream = new NetworkStream(socket, ownsSocket: true);
_connection = new Connection(
new MemoryStream(),
Expand All @@ -319,6 +321,7 @@ private void AcceptConnection(IAsyncResult iar) {
);
_connection.EventReceived += ConnectionReceivedEvent;
Task.Run(_connection.ProcessMessages).DoNotWait();
Info("Connection event fired");
_connected.Set();
}

Expand Down Expand Up @@ -359,14 +362,13 @@ public void Run() {
Info("set " + pythonPath.Key + "=" + pythonPath.Value);
Info(proc.Arguments);

// If there's an error in the launcher script,
// it will terminate without connecting back.
WaitHandle.WaitAny(new WaitHandle[] { _connected, proc.WaitHandle });
bool processConnected = _connected.WaitOne(1);

if (!processConnected && proc.ExitCode.HasValue) {
// Process has already exited
proc.Wait();
// Wait for process exit or connected. Connection might fail if
// there's an error in the launch script. Process may also
// signal exited while we haven't connected yet, so really wait
// for the connection and then see if we connected or not.
_connected.WaitOne(3000);
if (!_connectionActivated && proc.ExitCode != null) {
// Process has already exited without connecting
Error(Strings.Test_FailedToStartExited);
if (proc.StandardErrorLines.Any()) {
foreach (var line in proc.StandardErrorLines) {
Expand Down
8 changes: 4 additions & 4 deletions Python/Product/VCDebugLauncher/VCDebugLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,27 @@
<VSIXSubPath>.</VSIXSubPath>
</Content>
<Content Include="VCTargets\Win32\ImportAfter\Microsoft.PythonTools.Debugger.VCDebugLauncher.targets">
<VSIXSubPath>Microsoft\VC\v160\Platforms\Win32\ImportAfter</VSIXSubPath>
<VSIXSubPath>Microsoft\VC\$(VCTargetVersion)\Platforms\Win32\ImportAfter</VSIXSubPath>
<InstallRoot>MSBuild</InstallRoot>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
<SubType>Designer</SubType>
</Content>
<Content Include="VCTargets\Win32\ImportBefore\Microsoft.PythonTools.Debugger.VCDebugLauncher.props">
<VSIXSubPath>Microsoft\VC\v160\Platforms\Win32\ImportBefore</VSIXSubPath>
<VSIXSubPath>Microsoft\VC\$(VCTargetVersion)\Platforms\Win32\ImportBefore</VSIXSubPath>
<InstallRoot>MSBuild</InstallRoot>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="VCTargets\x64\ImportAfter\Microsoft.PythonTools.Debugger.VCDebugLauncher.targets">
<VSIXSubPath>Microsoft\VC\v160\Platforms\x64\ImportAfter</VSIXSubPath>
<VSIXSubPath>Microsoft\VC\$(VCTargetVersion)\Platforms\x64\ImportAfter</VSIXSubPath>
<InstallRoot>MSBuild</InstallRoot>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
<SubType>Designer</SubType>
</Content>
<Content Include="VCTargets\x64\ImportBefore\Microsoft.PythonTools.Debugger.VCDebugLauncher.props">
<VSIXSubPath>Microsoft\VC\v160\Platforms\x64\ImportBefore</VSIXSubPath>
<VSIXSubPath>Microsoft\VC\$(VCTargetVersion)\Platforms\x64\ImportBefore</VSIXSubPath>
<InstallRoot>MSBuild</InstallRoot>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down

0 comments on commit 984cd41

Please sign in to comment.