Skip to content

Commit 820b0b2

Browse files
Remove SPA project template tests (#20863)
1 parent 5b5784d commit 820b0b2

File tree

5 files changed

+0
-593
lines changed

5 files changed

+0
-593
lines changed

src/ProjectTemplates/test/Helpers/Project.cs

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.IO;
88
using System.Linq;
99
using System.Reflection;
10-
using System.Runtime.InteropServices;
1110
using System.Threading;
1211
using System.Threading.Tasks;
1312
using Microsoft.AspNetCore.Internal;
@@ -24,9 +23,6 @@ public class Project
2423
{
2524
private const string _urls = "http://127.0.0.1:0;https://127.0.0.1:0";
2625

27-
public static bool IsCIEnvironment => typeof(Project).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
28-
.Any(a => a.Key == "ContinuousIntegrationBuild");
29-
3026
public static string ArtifactsLogDir => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT")))
3127
? GetAssemblyMetadata("ArtifactsLogDir")
3228
: Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
@@ -48,12 +44,6 @@ public class Project
4844
public string TemplateBuildDir => Path.Combine(TemplateOutputDir, "bin", "Debug", TargetFramework);
4945
public string TemplatePublishDir => Path.Combine(TemplateOutputDir, "bin", "Release", TargetFramework, "publish");
5046

51-
private string TemplateServerDir => Path.Combine(TemplateOutputDir, $"{ProjectName}.Server");
52-
private string TemplateClientDir => Path.Combine(TemplateOutputDir, $"{ProjectName}.Client");
53-
public string TemplateClientDebugDir => Path.Combine(TemplateClientDir, "bin", "Debug", TargetFramework);
54-
public string TemplateClientReleaseDir => Path.Combine(TemplateClientDir, "bin", "Release", TargetFramework, "publish");
55-
public string TemplateServerReleaseDir => Path.Combine(TemplateServerDir, "bin", "Release", TargetFramework, "publish");
56-
5747
public ITestOutputHelper Output { get; set; }
5848
public IMessageSink DiagnosticsMessageSink { get; set; }
5949

@@ -164,50 +154,6 @@ internal async Task<ProcessEx> RunDotNetBuildAsync(bool takeNodeLock = false, ID
164154
}
165155
}
166156

167-
internal AspNetProcess StartBuiltServerAsync()
168-
{
169-
var environment = new Dictionary<string, string>
170-
{
171-
["ASPNETCORE_ENVIRONMENT"] = "Development"
172-
};
173-
174-
var projectDll = Path.Combine(TemplateServerDir, $"{ProjectName}.Server.dll");
175-
return new AspNetProcess(Output, TemplateServerDir, projectDll, environment, published: false);
176-
}
177-
178-
internal AspNetProcess StartBuiltClientAsync(AspNetProcess serverProcess)
179-
{
180-
var environment = new Dictionary<string, string>
181-
{
182-
["ASPNETCORE_ENVIRONMENT"] = "Development"
183-
};
184-
185-
var projectDll = Path.Combine(TemplateClientDebugDir, $"{ProjectName}.Client.dll {serverProcess.ListeningUri.Port}");
186-
return new AspNetProcess(Output, TemplateOutputDir, projectDll, environment, hasListeningUri: false);
187-
}
188-
189-
internal AspNetProcess StartPublishedServerAsync()
190-
{
191-
var environment = new Dictionary<string, string>
192-
{
193-
["ASPNETCORE_URLS"] = _urls,
194-
};
195-
196-
var projectDll = $"{ProjectName}.Server.dll";
197-
return new AspNetProcess(Output, TemplateServerReleaseDir, projectDll, environment);
198-
}
199-
200-
internal AspNetProcess StartPublishedClientAsync()
201-
{
202-
var environment = new Dictionary<string, string>
203-
{
204-
["ASPNETCORE_URLS"] = _urls,
205-
};
206-
207-
var projectDll = $"{ProjectName}.Client.dll";
208-
return new AspNetProcess(Output, TemplateClientReleaseDir, projectDll, environment);
209-
}
210-
211157
internal AspNetProcess StartBuiltProjectAsync(bool hasListeningUri = true, ILogger logger = null)
212158
{
213159
var environment = new Dictionary<string, string>
@@ -239,73 +185,6 @@ internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true)
239185
return new AspNetProcess(Output, TemplatePublishDir, projectDll, environment, hasListeningUri: hasListeningUri);
240186
}
241187

242-
internal async Task<ProcessEx> RestoreWithRetryAsync(ITestOutputHelper output, string workingDirectory)
243-
{
244-
// "npm restore" sometimes fails randomly in AppVeyor with errors like:
245-
// EPERM: operation not permitted, scandir <path>...
246-
// This appears to be a general NPM reliability issue on Windows which has
247-
// been reported many times (e.g., https://github.com/npm/npm/issues/18380)
248-
// So, allow multiple attempts at the restore.
249-
const int maxAttempts = 3;
250-
var attemptNumber = 0;
251-
ProcessEx restoreResult;
252-
do
253-
{
254-
restoreResult = await RestoreAsync(output, workingDirectory);
255-
if (restoreResult.HasExited && restoreResult.ExitCode == 0)
256-
{
257-
return restoreResult;
258-
}
259-
else
260-
{
261-
// TODO: We should filter for EPEM here to avoid masking other errors silently.
262-
output.WriteLine(
263-
$"NPM restore in {workingDirectory} failed on attempt {attemptNumber} of {maxAttempts}. " +
264-
$"Error was: {restoreResult.GetFormattedOutput()}");
265-
266-
// Clean up the possibly-incomplete node_modules dir before retrying
267-
CleanNodeModulesFolder(workingDirectory, output);
268-
}
269-
attemptNumber++;
270-
} while (attemptNumber < maxAttempts);
271-
272-
output.WriteLine($"Giving up attempting NPM restore in {workingDirectory} after {attemptNumber} attempts.");
273-
return restoreResult;
274-
275-
void CleanNodeModulesFolder(string workingDirectory, ITestOutputHelper output)
276-
{
277-
var nodeModulesDir = Path.Combine(workingDirectory, "node_modules");
278-
try
279-
{
280-
if (Directory.Exists(nodeModulesDir))
281-
{
282-
Directory.Delete(nodeModulesDir, recursive: true);
283-
}
284-
}
285-
catch
286-
{
287-
output.WriteLine($"Failed to clean up node_modules folder at {nodeModulesDir}.");
288-
}
289-
}
290-
}
291-
292-
private async Task<ProcessEx> RestoreAsync(ITestOutputHelper output, string workingDirectory)
293-
{
294-
// It's not safe to run multiple NPM installs in parallel
295-
// https://github.com/npm/npm/issues/2500
296-
await NodeLock.WaitAsync();
297-
try
298-
{
299-
output.WriteLine($"Restoring NPM packages in '{workingDirectory}' using npm...");
300-
var result = ProcessEx.RunViaShell(output, workingDirectory, "npm install");
301-
return result;
302-
}
303-
finally
304-
{
305-
NodeLock.Release();
306-
}
307-
}
308-
309188
internal async Task<ProcessEx> RunDotNetEfCreateMigrationAsync(string migrationName)
310189
{
311190
var args = $"--verbose --no-build migrations add {migrationName}";
@@ -335,35 +214,6 @@ internal async Task<ProcessEx> RunDotNetEfCreateMigrationAsync(string migrationN
335214
}
336215
}
337216

338-
internal async Task<ProcessEx> RunDotNetEfUpdateDatabaseAsync()
339-
{
340-
var args = "--verbose --no-build database update";
341-
342-
// Only run one instance of 'dotnet new' at once, as a workaround for
343-
// https://github.com/aspnet/templating/issues/63
344-
await DotNetNewLock.WaitAsync();
345-
try
346-
{
347-
var command = DotNetMuxer.MuxerPathOrDefault();
348-
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DotNetEfFullPath")))
349-
{
350-
args = $"\"{DotNetEfFullPath}\" " + args;
351-
}
352-
else
353-
{
354-
command = "dotnet-ef";
355-
}
356-
357-
var result = ProcessEx.Run(Output, TemplateOutputDir, command, args);
358-
await result.Exited;
359-
return result;
360-
}
361-
finally
362-
{
363-
DotNetNewLock.Release();
364-
}
365-
}
366-
367217
// If this fails, you should generate new migrations via migrations/updateMigrations.cmd
368218
public void AssertEmptyMigration(string migration)
369219
{

src/ProjectTemplates/test/SpaTemplateTest/AngularTemplateTest.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/ProjectTemplates/test/SpaTemplateTest/ReactReduxTemplateTest.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/ProjectTemplates/test/SpaTemplateTest/ReactTemplateTest.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)