<!--
  The xunit tests in Debugger.Tests aren't truly unit tests - they depend on other stuff that may
  not be in the same directory. This file configures the tests to find what they need. At the moment
  this file is generated in a hard coded way to support running from the bin directory on our git 
  based build, but once we understand the different environments the tests will need to run in we
  can figure out the right build and deployment strategy for each. Hopefully this configuration offers
  enough flexibility that the tests themselves don't need to change.
-->

<Configuration>
  <RepoRootDir>../../../../..</RepoRootDir>
  <DotNetRoot>$(RepoRootDir)/.dotnet</DotNetRoot>

  <Import ConfigFile="Debugger.Tests.Common.txt" />
  <Import ConfigFile="$(DotNetRoot)/Debugger.Tests.Versions.txt" />

  <TestProduct>ProjectK</TestProduct>
  <ScriptRootDir>$(RepoRootDir)/src/SOS/SOS.UnitTests/Scripts</ScriptRootDir>
  <RootBinDir>$(RepoRootDir)/artifacts</RootBinDir>
  <InstallDir>$(RootBinDir)/bin/$(OS).$(TargetArchitecture).$(TargetConfiguration)</InstallDir>
  <LogDir>$(RootBinDir)/TestResults/$(TargetConfiguration)/sos.unittests_$(Timestamp)</LogDir>
  <DumpDir>$(RootBinDir)/tmp/$(TargetConfiguration)\dumps</DumpDir>
  
  <TestLatestOnly>false</TestLatestOnly>
  <TestLatestOnly Condition="'$(PrivateBuildTesting)' == 'true'">true</TestLatestOnly>
  <TestLatestOnly Condition="'$(InternalReleaseTesting)' == 'true'">true</TestLatestOnly>

  <TestWebApp3>true</TestWebApp3>
  <TestWebApp3 Condition="'$(InternalReleaseTesting)' == 'true'">false</TestWebApp3>

  <!-- Build the debuggee for this framework version but run it on latest -->
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">netcoreapp3.1</BuildProjectFrameworkLatest>
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest>
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '2.1')">netcoreapp2.1</BuildProjectFrameworkLatest>

  <DebuggeeSourceRoot>$(RepoRootDir)/src/SOS/SOS.UnitTests/Debuggees</DebuggeeSourceRoot>
  <DebuggeeBuildProcess>sdk.prebuilt</DebuggeeBuildProcess>
  <DebuggeeBuildRoot>$(RootBinDir)</DebuggeeBuildRoot>
  <CliPath>$(DotNetRoot)/dotnet</CliPath>

  <NuGetPackageFeeds>
      myget.org dotnet-core=https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
      nuget.org=https://www.nuget.org/api/v2/
  </NuGetPackageFeeds>

  <Options>
    <!--
        Default (prebuilt)
      -->
    <Option>
      <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
    </Option>
    <Option Condition="'$(TestLatestOnly)' != 'true'">
      <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
    </Option>
    <Option Condition="'$(TestLatestOnly)' != 'true'">
      <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
    </Option>
    <!--
        SOS.StackAndOtherTests (cli because tested with embedded and portable PDBs)
      -->
    <Option>
      <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
      <DebuggeeBuildRoot>$(RootBinDir)/Debuggees</DebuggeeBuildRoot>
      <TestName>SOS.StackAndOtherTests</TestName>
      <Options>
        <Option>
          <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
        </Option>
        <Option Condition="'$(TestLatestOnly)' != 'true'">
          <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
        </Option>
        <Option Condition="'$(TestLatestOnly)' != 'true'">
          <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
        </Option>
      </Options>
    </Option>
    <!--
        SOS.WebApp3 (runs on 3.1 and latest aspnetcore)
      -->
    <Option Condition="'$(TestWebApp3)' == 'true'">
      <TestName>SOS.WebApp3</TestName>
      <Options>
        <Option>
          <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
          <FrameworkVersion>$(AspNetCoreVersionLatest)</FrameworkVersion>
        </Option>
        <Option Condition="'$(TestLatestOnly)' != 'true'">
          <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
          <FrameworkVersion>$(AspNetCoreVersion31)</FrameworkVersion>
        </Option>
      </Options>
    </Option>
  </Options>

  <FrameworkVersion Condition="'$(FrameworkVersion)' == ''">$(RuntimeFrameworkVersion)</FrameworkVersion>
  <RuntimeSymbolsPath>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</RuntimeSymbolsPath>
  <SOSHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SOSHostRuntime>
  <LLDBHelperScript>$(ScriptRootDir)/lldbhelper.py</LLDBHelperScript>
  <HostExe>$(DotNetRoot)/dotnet</HostExe>
  <HostArgs>--fx-version $(FrameworkVersion)</HostArgs>

  <Options>
    <Option Condition="$(OS) == Linux">
      <SOSPath>$(InstallDir)/libsosplugin.so</SOSPath>
      <DotNetDumpHost>$(DotNetRoot)/dotnet</DotNetDumpHost>
      <DotNetDumpPath>$(RootBinDir)/bin/dotnet-dump/$(TargetConfiguration)/netcoreapp2.1/publish/dotnet-dump.dll</DotNetDumpPath>
      <DebuggeeDumpOutputRootDir>$(DumpDir)/$(TestProduct)/$(RuntimeFrameworkVersion)/$(BuildProjectFramework)</DebuggeeDumpOutputRootDir>
      <DebuggeeDumpInputRootDir>$(DebuggeeDumpOutputRootDir)</DebuggeeDumpInputRootDir>
    </Option>
    <Option Condition="$(OS) == OSX">
      <SOSPath>$(InstallDir)/libsosplugin.dylib</SOSPath>
      <!-- Dump testing is disabled on macOS. gdb can't run processes because it needs to be code signed and lldb on macOS's "process save-core" is too slow -->
    </Option>
  </Options>

</Configuration>
