Remove clearing data after each test run (it allows to examine obfuscated assemblies after tests running), use more clear suffix for temp dir instead of GUID

This commit is contained in:
Ivan Kochurkin 2020-08-22 14:43:43 +03:00
Родитель 5d9432a84f
Коммит 56e11d1d9b
4 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -24,6 +24,7 @@ namespace _123_InheritCustomAttr.Test {
new[] {"Monday", "43", "1"}, new[] {"Monday", "43", "1"},
new SettingItem<Protection>("rename") {{"mode", renameMode}, {"flatten", flatten ? "True" : "False"}}, new SettingItem<Protection>("rename") {{"mode", renameMode}, {"flatten", flatten ? "True" : "False"}},
outputHelper, outputHelper,
$"_{renameMode}_{flatten}",
l => Assert.False(l.StartsWith("[WARN]"), "Logged line may not start with [WARN]\r\n" + l)); l => Assert.False(l.StartsWith("[WARN]"), "Logged line may not start with [WARN]\r\n" + l));
public static IEnumerable<object[]> InheritCustomAttributeData() { public static IEnumerable<object[]> InheritCustomAttributeData() {

Просмотреть файл

@ -30,7 +30,8 @@ namespace DynamicTypeRename.Test {
{ "mode", renameMode }, { "mode", renameMode },
{ "flatten", flatten.ToString() } { "flatten", flatten.ToString() }
}, },
outputHelper outputHelper,
$"_{renameMode}_{flatten}"
); );
public static IEnumerable<object[]> RenameDynamicTypeData() { public static IEnumerable<object[]> RenameDynamicTypeData() {

Просмотреть файл

@ -23,6 +23,7 @@ namespace CompressorWithResx.Test {
? new SettingItem<Protection>("resources") {{"mode", resourceProtectionMode}} ? new SettingItem<Protection>("resources") {{"mode", resourceProtectionMode}}
: null, : null,
outputHelper, outputHelper,
$"_{compatKey}_{deriverKey}_{resourceProtectionMode}",
packer: new SettingItem<Packer>("compressor") {{"compat", compatKey}, {"key", deriverKey}}); packer: new SettingItem<Packer>("compressor") {{"compat", compatKey}, {"key", deriverKey}});
public static IEnumerable<object[]> CompressAndExecuteTestData() { public static IEnumerable<object[]> CompressAndExecuteTestData() {

Просмотреть файл

@ -10,21 +10,23 @@ using Xunit.Abstractions;
namespace Confuser.UnitTest { namespace Confuser.UnitTest {
public static class TestRunner { public static class TestRunner {
public static async Task Run(string inputFileName, string[] expectedOutput, SettingItem<Protection> protection, public static async Task Run(string inputFileName, string[] expectedOutput, SettingItem<Protection> protection,
ITestOutputHelper outputHelper, Action<string> outputAction = null, SettingItem<Packer> packer = null, ITestOutputHelper outputHelper, string outputDirSuffix = "", Action<string> outputAction = null, SettingItem<Packer> packer = null,
Action<ProjectModule> projectModuleAction = null) => Action<ProjectModule> projectModuleAction = null) =>
await Run(new[] {inputFileName}, expectedOutput, protection, outputHelper, outputAction, packer, await Run(new[] {inputFileName}, expectedOutput, protection, outputHelper, outputDirSuffix, outputAction, packer,
projectModuleAction); projectModuleAction);
public static async Task Run(string[] inputFileNames, string[] expectedOutput, SettingItem<Protection> protection, ITestOutputHelper outputHelper, public static async Task Run(string[] inputFileNames, string[] expectedOutput, SettingItem<Protection> protection, ITestOutputHelper outputHelper,
Action<string> outputAction = null, SettingItem<Packer> packer = null, string outputDirSuffix = "", Action<string> outputAction = null, SettingItem<Packer> packer = null,
Action<ProjectModule> projectModuleAction = null) { Action<ProjectModule> projectModuleAction = null) {
var baseDir = Environment.CurrentDirectory; var baseDir = Environment.CurrentDirectory;
var outputDir = Path.Combine(baseDir, "obfuscated_" + Guid.NewGuid().ToString()); var outputDir = Path.Combine(baseDir, "obfuscated" + outputDirSuffix);
if (Directory.Exists(outputDir)) {
Directory.Delete(outputDir, true);
}
string entryInputFileName = Path.Combine(baseDir, inputFileNames[0]); string entryInputFileName = Path.Combine(baseDir, inputFileNames[0]);
var entryOutputFileName = Path.Combine(outputDir, inputFileNames[0]); var entryOutputFileName = Path.Combine(outputDir, inputFileNames[0]);
FileUtilities.ClearOutput(entryOutputFileName);
var proj = new ConfuserProject { var proj = new ConfuserProject {
BaseDirectory = baseDir, BaseDirectory = baseDir,
OutputDirectory = outputDir, OutputDirectory = outputDir,
@ -84,8 +86,6 @@ namespace Confuser.UnitTest {
Assert.Equal(42, process.ExitCode); Assert.Equal(42, process.ExitCode);
} }
} }
FileUtilities.ClearOutput(entryOutputFileName);
} }
} }
} }