public void TestClean() { string contents = @"{ ""version"": ""1.0"", ""defaultProvider"": ""cdnjs"", ""defaultDestination"": ""wwwroot"", ""libraries"": [ { ""library"": ""[email protected]"", ""files"": [ ""jquery.min.js"", ""core.js"" ] } ] }"; File.WriteAllText(Path.Combine(WorkingDir, "libman.json"), contents); var restoreCommand = new RestoreCommand(HostEnvironment); restoreCommand.Configure(null).Execute(); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); var command = new CleanCommand(HostEnvironment); command.Configure(null); int result = command.Execute(); Assert.AreEqual(0, result); Assert.IsFalse(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsFalse(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); }
public void Clean_should_remove_bin_output(bool multiTarget, string targetFramework) { TestAsset helloWorldAsset = CreateTestAsset( multiTarget, nameof(Clean_should_remove_bin_output) + multiTarget + targetFramework, targetFramework: targetFramework); _testRoot = helloWorldAsset.TestRoot; var packCommand = new PackCommand(Log, helloWorldAsset.TestRoot); packCommand.Execute().Should().Pass(); var cleanCommand = new CleanCommand(Log, helloWorldAsset.TestRoot); cleanCommand.Execute().Should().Pass(); var outputDirectory = packCommand.GetOutputDirectory("netcoreapp2.1"); string windowShimPath = Path.Combine(outputDirectory.FullName, $"shims/netcoreapp2.1/win-x64/{_customToolCommandName}.exe"); File.Exists(windowShimPath).Should().BeFalse($"Shim {windowShimPath} should not exists"); string osxShimPath = Path.Combine(outputDirectory.FullName, $"shims/netcoreapp2.1/osx.10.12-x64/{_customToolCommandName}"); File.Exists(osxShimPath).Should().BeFalse($"Shim {osxShimPath} should not exists"); }
public override void Run(string[] args) { cmd.Quiet = false; options = new CmdParserOptionSet() { { "h|help", "Display this help information. To see online help, use: git help <command>", v => OfflineHelp() }, { "d", "Remove untracked directories in addition to untracked files", v => cmd.D = true }, { "f|force", "If the git configuration specifies clean", v => cmd.Force = true }, { "n|dry-run", "Don't actually remove anything, just show what would be done", v => cmd.DryRun = true }, { "q|quiet", "Be quiet, only report errors, but not the files that are successfully removed", v => cmd.Quiet = true }, { "x", "Don't use the ignore rules", v => cmd.x = true }, { "X", "Remove only files ignored by git", v => cmd.X = true }, }; try { List <String> arguments = ParseOptions(args); if (arguments.Count > 0) { cmd.Arguments = arguments; cmd.Execute(); } else { OfflineHelp(); } } catch (Exception e) { cmd.OutputStream.WriteLine(e.Message); } }
public void It_cleans_without_logging_assets_message() { var testAsset = _testAssetsManager .CopyTestAsset("HelloWorld", "CleanHelloWorld") .WithSource() .Restore(Log); var lockFilePath = Path.Combine(testAsset.TestRoot, "obj", "project.assets.json"); LockFile lockFile = LockFileUtilities.GetLockFile(lockFilePath, NullLogger.Instance); lockFile.LogMessages.Add( new AssetsLogMessage( LogLevel.Warning, NuGetLogCode.NU1500, "a test warning", null)); new LockFileFormat().Write(lockFilePath, lockFile); var cleanCommand = new CleanCommand(Log, testAsset.TestRoot); cleanCommand .Execute("/p:CheckEolTargetFramework=false") .Should() .Pass() .And .NotHaveStdOutContaining("warning"); }
public void MigratesTheFileSystem( [Frozen] Mock <IFileSystem> fileSystem, [Frozen] Mock <IFileSystemMigrator> migrator) { // Arrange var sut = new CleanCommand(null, fileSystem.Object, new Mock <ILog>().Object, migrator.Object); // Act sut.Execute(); // Assert migrator.Verify(m => m.Migrate(), Times.Once); }
public void It_cleans_without_assets_file_present() { var testAsset = _testAssetsManager .CopyTestAsset("HelloWorld") .WithSource(); var assetsFilePath = Path.Combine(testAsset.TestRoot, "obj", "project.assets.json"); File.Exists(assetsFilePath).Should().BeFalse(); var cleanCommand = new CleanCommand(Log, testAsset.TestRoot); cleanCommand .Execute() .Should() .Pass(); }
public void It_can_persist_generatedfile_between_cleans() { // Regression test for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1405579 var tfm = "net6.0"; var testProject = CreateTestProject(tfm); testProject.AdditionalProperties["ImplicitUsings"] = "enable"; var testAsset = _testAssetsManager.CreateTestProject(testProject); var globalUsingsFileName = $"{testAsset.TestProject.Name}.GlobalUsings.g.cs"; var buildCommand = new BuildCommand(testAsset); buildCommand .Execute() .Should() .Pass(); var outputDirectory = buildCommand.GetIntermediateDirectory(tfm); outputDirectory.Should().HaveFile(globalUsingsFileName); var cleanCommand = new CleanCommand(testAsset); cleanCommand .Execute() .Should() .Pass(); // Verify the GlobalUsings.g.cs does not get removed on clean. outputDirectory.Should().HaveFile(globalUsingsFileName); File.ReadAllText(Path.Combine(outputDirectory.FullName, globalUsingsFileName)).Should().Be( @"// <auto-generated/> global using global::System; global using global::System.Collections.Generic; global using global::System.IO; global using global::System.Linq; global using global::System.Net.Http; global using global::System.Threading; global using global::System.Threading.Tasks; "); }
public void Clean_RemovesManifestFrom_BuildAndIntermediateOutput() { var expectedManifest = LoadBuildManifest(); var testAsset = "RazorComponentApp"; ProjectDirectory = CreateAspNetSdkTestAsset(testAsset); var build = new BuildCommand(ProjectDirectory); build.Execute().Should().Pass(); var intermediateOutputPath = build.GetIntermediateDirectory(DefaultTfm, "Debug").ToString(); var outputPath = build.GetOutputDirectory(DefaultTfm, "Debug").ToString(); // GenerateStaticWebAssetsManifest should generate the manifest file. var path = Path.Combine(intermediateOutputPath, "StaticWebAssets.build.json"); new FileInfo(path).Should().Exist(); var manifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)); AssertManifest(manifest, expectedManifest); // GenerateStaticWebAssetsManifest should copy the file to the output folder. var finalPath = Path.Combine(outputPath, "ComponentApp.staticwebassets.json"); new FileInfo(finalPath).Should().Exist(); var finalManifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(finalPath)); AssertManifest(finalManifest, expectedManifest); var clean = new CleanCommand(Log, ProjectDirectory.Path); clean.Execute().Should().Pass(); // Obj folder manifest does not exist new FileInfo(path).Should().NotExist(); // Bin folder manifest does not exist new FileInfo(finalPath).Should().NotExist(); }
public void DeleteOutdated(DateTime threshold) { _clean.Execute(threshold); }