Skip to content

Commit c4ac43e

Browse files
committed
Use absolute paths, including IntermediateOutputPath.
Enable previously flaky test in all environments.
1 parent b9fba45 commit c4ac43e

File tree

7 files changed

+24
-8
lines changed

7 files changed

+24
-8
lines changed

src/BenchmarkDotNet/Toolchains/ArtifactsPaths.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ namespace BenchmarkDotNet.Toolchains
44
{
55
public class ArtifactsPaths
66
{
7-
public static readonly ArtifactsPaths Empty = new ArtifactsPaths("", "", "", "", "", "", "", "", "", "", "");
7+
public static readonly ArtifactsPaths Empty = new ArtifactsPaths("", "", "", "", "", "", "", "", "", "", "", "");
88

99
[PublicAPI] public string RootArtifactsFolderPath { get; }
1010
[PublicAPI] public string BuildArtifactsDirectoryPath { get; }
1111
[PublicAPI] public string BinariesDirectoryPath { get; }
12+
[PublicAPI] public string IntermediateDirectoryPath { get; }
1213
[PublicAPI] public string ProgramCodePath { get; }
1314
[PublicAPI] public string AppConfigPath { get; }
1415
[PublicAPI] public string NuGetConfigPath { get; }
@@ -22,6 +23,7 @@ public ArtifactsPaths(
2223
string rootArtifactsFolderPath,
2324
string buildArtifactsDirectoryPath,
2425
string binariesDirectoryPath,
26+
string intermediateDirectoryPath,
2527
string programCodePath,
2628
string appConfigPath,
2729
string nuGetConfigPath,
@@ -34,6 +36,7 @@ public ArtifactsPaths(
3436
RootArtifactsFolderPath = rootArtifactsFolderPath;
3537
BuildArtifactsDirectoryPath = buildArtifactsDirectoryPath;
3638
BinariesDirectoryPath = binariesDirectoryPath;
39+
IntermediateDirectoryPath = intermediateDirectoryPath;
3740
ProgramCodePath = programCodePath;
3841
AppConfigPath = appConfigPath;
3942
NuGetConfigPath = nuGetConfigPath;

src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ protected override string GetBinariesDirectoryPath(string buildArtifactsDirector
6565
? Path.Combine(buildArtifactsDirectoryPath, "bin", buildPartition.BuildConfiguration, TargetFrameworkMoniker)
6666
: Path.Combine(buildArtifactsDirectoryPath, "bin", $"bdn_partition_{buildPartition.Id}");
6767

68+
protected override string GetIntermediateDirectoryPath(string buildArtifactsDirectoryPath, BuildPartition buildPartition)
69+
=> Path.Combine(buildArtifactsDirectoryPath, "obj", $"bdn_partition_{buildPartition.Id}");
70+
6871
[SuppressMessage("ReSharper", "StringLiteralTypo")] // R# complains about $variables$
6972
protected override void GenerateProject(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger)
7073
{

src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ internal static string GetBuildCommand(ArtifactsPaths artifactsPaths, BuildParti
175175
.AppendArgument(GetMsBuildBinLogArgument(buildPartition, binLogSuffix))
176176
// Fix #1377 (see comments in #1773).
177177
// We force the project to output binaries to a new directory.
178-
// Specifying --output and --no-dependencies breaks the build for some reason,
178+
// Specifying --output and --no-dependencies breaks the build (because the previous build was not done using the custom output path),
179179
// so we don't include it if we're building no-deps (only supported for integration tests).
180180
.AppendArgument(excludeOutput ? string.Empty : $"--output \"{artifactsPaths.BinariesDirectoryPath}\"")
181-
.AppendArgument(excludeOutput ? string.Empty : $"/p:OutputPath={Path.Combine(".", "bin", $"bdn_partition_{buildPartition.Id}")}")
182-
.AppendArgument(excludeOutput ? string.Empty : $"/p:IntermediateOutputPath={Path.Combine(".", "obj", $"bdn_partition_{buildPartition.Id}")}\\")
181+
.AppendArgument(excludeOutput ? string.Empty : $"/p:OutputPath=\"{artifactsPaths.BinariesDirectoryPath}\"")
182+
.AppendArgument(excludeOutput ? string.Empty : $"/p:IntermediateOutputPath=\"{artifactsPaths.IntermediateDirectoryPath}\"\\")
183183
.ToString();
184184

185185
internal static string GetPublishCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string extraArguments = null, string binLogSuffix = null)
@@ -191,8 +191,8 @@ internal static string GetPublishCommand(ArtifactsPaths artifactsPaths, BuildPar
191191
.AppendArgument(string.IsNullOrEmpty(artifactsPaths.PackagesDirectoryName) ? string.Empty : $"/p:NuGetPackageRoot=\"{artifactsPaths.PackagesDirectoryName}\"")
192192
.AppendArgument(GetMsBuildBinLogArgument(buildPartition, binLogSuffix))
193193
.AppendArgument($"--output \"{artifactsPaths.BinariesDirectoryPath}\"")
194-
.AppendArgument($"/p:OutputPath={Path.Combine(".", "bin", $"bdn_partition_{buildPartition.Id}")}")
195-
.AppendArgument($"/p:IntermediateOutputPath={Path.Combine(".", "obj", $"bdn_partition_{buildPartition.Id}")}\\")
194+
.AppendArgument($"/p:OutputPath=\"{artifactsPaths.BinariesDirectoryPath}\"")
195+
.AppendArgument($"/p:IntermediateOutputPath=\"{artifactsPaths.IntermediateDirectoryPath}\"\\")
196196
.ToString();
197197

198198
private static string GetMsBuildBinLogArgument(BuildPartition buildPartition, string suffix)

src/BenchmarkDotNet/Toolchains/GeneratorBase.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ public GenerateResult GenerateProject(BuildPartition buildPartition, ILogger log
4343
[PublicAPI] protected abstract string GetBuildArtifactsDirectoryPath(BuildPartition assemblyLocation, string programName);
4444

4545
/// <summary>
46-
/// returns a path where executable should be found after the build
46+
/// returns a path where executable should be found after the build (usually \bin)
4747
/// </summary>
4848
[PublicAPI] protected virtual string GetBinariesDirectoryPath(string buildArtifactsDirectoryPath, BuildPartition buildPartition)
4949
=> buildArtifactsDirectoryPath;
5050

51+
/// <summary>
52+
/// returns a path where intermediate files should be found after the build (usually \obj)
53+
/// </summary>
54+
[PublicAPI]
55+
protected virtual string GetIntermediateDirectoryPath(string buildArtifactsDirectoryPath, BuildPartition buildPartition)
56+
=> string.Empty;
57+
5158
/// <summary>
5259
/// returns OS-specific executable extension
5360
/// </summary>
@@ -128,6 +135,7 @@ private ArtifactsPaths GetArtifactsPaths(BuildPartition buildPartition, string r
128135
rootArtifactsFolderPath: rootArtifactsFolderPath,
129136
buildArtifactsDirectoryPath: buildArtifactsDirectoryPath,
130137
binariesDirectoryPath: binariesDirectoryPath,
138+
intermediateDirectoryPath: GetIntermediateDirectoryPath(buildArtifactsDirectoryPath, buildPartition),
131139
programCodePath: Path.Combine(buildArtifactsDirectoryPath, $"{programName}{codeFileExtension}"),
132140
appConfigPath: $"{executablePath}.config",
133141
nuGetConfigPath: Path.Combine(buildArtifactsDirectoryPath, "NuGet.config"),

src/BenchmarkDotNet/Toolchains/InProcess/Emit/InProcessEmitArtifactsPath.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public InProcessEmitArtifactsPath(
1212
baseArtifacts.RootArtifactsFolderPath,
1313
baseArtifacts.BuildArtifactsDirectoryPath,
1414
baseArtifacts.BinariesDirectoryPath,
15+
baseArtifacts.IntermediateDirectoryPath,
1516
baseArtifacts.ProgramCodePath,
1617
baseArtifacts.AppConfigPath,
1718
baseArtifacts.NuGetConfigPath,

src/BenchmarkDotNet/Toolchains/InProcess/Emit/InProcessEmitGenerator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ private ArtifactsPaths GetArtifactsPaths(BuildPartition buildPartition, string r
4747
rootArtifactsFolderPath: rootArtifactsFolderPath,
4848
buildArtifactsDirectoryPath: buildArtifactsDirectoryPath,
4949
binariesDirectoryPath: binariesDirectoryPath,
50+
intermediateDirectoryPath: null,
5051
programCodePath: null,
5152
appConfigPath: null,
5253
nuGetConfigPath: null,

tests/BenchmarkDotNet.IntegrationTests/NugetReferenceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public NuGetReferenceTests(ITestOutputHelper output) : base(output)
1818
{
1919
}
2020

21-
[FactEnvSpecific("For some reason this test is unstable on Ubuntu for both AzureDevOps and Travis CI", EnvRequirement.NonLinux)]
21+
[Fact]
2222
public void UserCanSpecifyCustomNuGetPackageDependency()
2323
{
2424
var toolchain = RuntimeInformation.GetCurrentRuntime().GetToolchain(preferMsBuildToolchains: true);

0 commit comments

Comments
 (0)