Skip to content

Commit 94f7b74

Browse files
author
valentinas.kaminskas
committed
Absolute path for benchmark tests fixed
1 parent e8a2ca4 commit 94f7b74

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

benchmarks/BenchmarksBase.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5-
using System.Reflection;
6-
using System.Text;
75
using BenchmarkDotNet.Attributes;
86
using BenchmarkDotNet.Configs;
97
using BenchmarkDotNet.Jobs;
@@ -26,9 +24,8 @@ public ConfigWithCustomEnvVars()
2624

2725
public IEnumerable<object[]> TestData()
2826
{
29-
string rootDir = Directory.GetCurrentDirectory();
30-
string testDataDir = Path.Join(Directory.GetParent(rootDir).Parent.Parent.Parent.FullName, "jsonexamples");
31-
string[] files = Directory.GetFiles(testDataDir, "*.json", SearchOption.AllDirectories).ToArray();
27+
string jsonExamples = Environment.GetEnvironmentVariable("pathToJsonExamples");
28+
string[] files = Directory.GetFiles(jsonExamples, "*.json", SearchOption.AllDirectories).ToArray();
3229

3330
foreach (var file in files)
3431
{

benchmarks/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Reflection;
34
using BenchmarkDotNet.Running;
45

56
namespace Benchmarks
@@ -8,6 +9,13 @@ public class Program
89
{
910
public static void Main(string[] args)
1011
{
12+
const string envVariable = "pathToJsonExamples";
13+
if (Environment.GetEnvironmentVariable(envVariable) == null)
14+
{
15+
string root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
16+
string path = Path.Join(Directory.GetParent(root).Parent.Parent.Parent.FullName, "jsonexamples");
17+
Environment.SetEnvironmentVariable(envVariable, path);
18+
}
1119
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
1220
}
1321
}

0 commit comments

Comments
 (0)