Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.

Commit 14aebeb

Browse files
authored
Remove using environment variables for specifying tests. (#1410)
1 parent d463b5e commit 14aebeb

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

test/Common.FunctionalTests/Inprocess/LogPipeTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System.IO;
54
using System.Net;
65
using System.Threading.Tasks;
76
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
@@ -41,27 +40,26 @@ public async Task CheckStdoutLoggingToPipe_DoesNotCrashProcess(string path)
4140
}
4241

4342
[ConditionalTheory]
44-
[InlineData("ConsoleErrorWrite")]
45-
[InlineData("ConsoleWrite")]
43+
[InlineData("ConsoleErrorWriteStartServer")]
44+
[InlineData("ConsoleWriteStartServer")]
4645
public async Task CheckStdoutLoggingToPipeWithFirstWrite(string path)
4746
{
4847
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
4948

50-
var firstWriteString = path + path;
49+
var firstWriteString = "TEST MESSAGE";
5150

52-
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_INITIAL_WRITE"] = firstWriteString;
51+
deploymentParameters.TransformArguments((a, _) => $"{a} {path}");
5352

5453
var deploymentResult = await DeployAsync(deploymentParameters);
5554

56-
await Helpers.AssertStarts(deploymentResult, path);
55+
await Helpers.AssertStarts(deploymentResult);
5756

5857
StopServer();
5958

6059
if (deploymentParameters.ServerType == ServerType.IISExpress)
6160
{
6261
// We can't read stdout logs from IIS as they aren't redirected.
6362
Assert.Contains(TestSink.Writes, context => context.Message.Contains(firstWriteString));
64-
Assert.Contains(TestSink.Writes, context => context.Message.Contains("TEST MESSAGE"));
6563
}
6664
}
6765

test/Common.FunctionalTests/LogFileTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.IO;
6-
using System.Net;
76
using System.Threading.Tasks;
87
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
98
using Microsoft.AspNetCore.Server.IntegrationTesting;

test/WebSites/InProcessWebSite/Program.cs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,31 +79,33 @@ public static int Main(string[] args)
7979
host.Run();
8080
}
8181
break;
82+
case "ConsoleErrorWriteStartServer":
83+
Console.Error.WriteLine("TEST MESSAGE");
84+
return StartServer();
85+
case "ConsoleWriteStartServer":
86+
Console.WriteLine("TEST MESSAGE");
87+
return StartServer();
8288
default:
83-
{
84-
85-
var envVariable = Environment.GetEnvironmentVariable("ASPNETCORE_INPROCESS_INITIAL_WRITE");
86-
if (!string.IsNullOrEmpty(envVariable))
87-
{
88-
Console.WriteLine(envVariable);
89-
Console.Error.WriteLine(envVariable);
90-
}
91-
92-
var host = new WebHostBuilder()
93-
.ConfigureLogging((_, factory) =>
94-
{
95-
factory.AddConsole();
96-
factory.AddFilter("Console", level => level >= LogLevel.Information);
97-
})
98-
.UseIIS()
99-
.UseStartup<Startup>()
100-
.Build();
89+
return StartServer();
10190

102-
host.Run();
103-
return 0;
104-
}
10591
}
10692
return 12;
10793
}
94+
95+
private static int StartServer()
96+
{
97+
var host = new WebHostBuilder()
98+
.ConfigureLogging((_, factory) =>
99+
{
100+
factory.AddConsole();
101+
factory.AddFilter("Console", level => level >= LogLevel.Information);
102+
})
103+
.UseIIS()
104+
.UseStartup<Startup>()
105+
.Build();
106+
107+
host.Run();
108+
return 0;
109+
}
108110
}
109111
}

0 commit comments

Comments
 (0)