From 89ec962034a984dd5ed089616dcba455753094c4 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Sat, 15 Feb 2020 19:26:18 +0100 Subject: [PATCH 1/9] fix CodeBase existing inproc collector settings --- .../Processors/CollectArgumentProcessor.cs | 2 +- .../CollectArgumentProcessorTests.cs | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/vstest.console/Processors/CollectArgumentProcessor.cs b/src/vstest.console/Processors/CollectArgumentProcessor.cs index f603e2314c..7c9e7101cc 100644 --- a/src/vstest.console/Processors/CollectArgumentProcessor.cs +++ b/src/vstest.console/Processors/CollectArgumentProcessor.cs @@ -187,7 +187,7 @@ internal static void EnableCoverletInProcDataCollector(string argument, DataColl { // Set Assembly qualified name and codebase if not already set dataCollectorSettings.AssemblyQualifiedName = dataCollectorSettings.AssemblyQualifiedName ?? CoverletConstants.CoverletDataCollectorAssemblyQualifiedName; - dataCollectorSettings.CodeBase = dataCollectorSettings.CodeBase ?? CoverletConstants.CoverletDataCollectorCodebase; + dataCollectorSettings.CodeBase = (dataCollectorSettings.CodeBase ?? GetCoverletCodeBasePath(runSettingProvider, fileHelper)) ?? CoverletConstants.CoverletDataCollectorCodebase; dataCollectorSettings.IsEnabled = true; } } diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index 7a21b8eef8..3c99240feb 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -278,14 +278,34 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatOutProcProcDataCollectorSet [TestMethod] public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent() { - var runsettingsString = $"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; + var runsettingsString = $"\r\n\r\n \r\n c:\\AdapterFolderPath\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; runsettingsString = string.Format(runsettingsString, string.Empty); var runsettings = new RunSettings(); runsettings.LoadSettingsXml(runsettingsString); this.settingsProvider.SetActiveRunSettings(runsettings); - this.executor.Initialize("XPlat Code Coverage"); + Mock fileHelper = new Mock(); + fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); + CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); + executor.Initialize("XPlat Code Coverage"); + + Assert.AreEqual($"\r\n\r\n \r\n c:\\AdapterFolderPath\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + } + + [TestMethod] + public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent_NoTestAdaptersPaths() + { + var runsettingsString = $"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; + runsettingsString = string.Format(runsettingsString, string.Empty); + var runsettings = new RunSettings(); + runsettings.LoadSettingsXml(runsettingsString); + this.settingsProvider.SetActiveRunSettings(runsettings); + Mock fileHelper = new Mock(); + // Suppose file exists to be sure that we won't find adapter path on runsettings config + fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); + CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); + executor.Initialize("XPlat Code Coverage"); - Assert.AreEqual($"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual($"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); } #endregion From 741b00445b6d53db72c7202a8cb15a2bff57f232 Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 11:26:35 +0200 Subject: [PATCH 2/9] Update CollectArgumentProcessorTests.cs --- .../CollectArgumentProcessorTests.cs | 68 +++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index 18d70ba377..de1f03b94f 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -531,8 +531,50 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope fileHelper.Setup(f => f.Exists(It.IsAny())).Returns(true); CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); executor.Initialize("XPlat Code Coverage"); - - Assert.AreEqual($"\r\n\r\n \r\n c:\\AdapterFolderPath\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + + +/* + + + + c:\AdapterFolderPath + + + + + + + + + + + + + + + +*/ + + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " c:\AdapterFolderPath", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""), this.settingsProvider.ActiveRunSettings.SettingsXml); } [TestMethod] @@ -549,9 +591,27 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); executor.Initialize("XPlat Code Coverage"); - Assert.AreEqual($"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", this.settingsProvider.ActiveRunSettings.SettingsXml); + Assert.AreEqual(string.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + $" ", + " ", + " ", + ""), this.settingsProvider.ActiveRunSettings.SettingsXml); } #endregion } -} \ No newline at end of file +} From 2b5831f1b4bc9df6fd70c30e0fb25a9bd8aec278 Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 11:28:08 +0200 Subject: [PATCH 3/9] Update CollectArgumentProcessorTests.cs --- .../CollectArgumentProcessorTests.cs | 33 +++---------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index de1f03b94f..e1c91eac37 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -532,29 +532,6 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object); executor.Initialize("XPlat Code Coverage"); - -/* - - - - c:\AdapterFolderPath - - - - - - - - - - - - - - - -*/ - Assert.AreEqual(string.Join(Environment.NewLine, "", "", @@ -598,15 +575,15 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope " ", " ", " ", - " ", - " ", - " ", - " ", + " ", + " ", + " ", + " ", " ", " ", " ", " ", - $" ", + $" ", " ", " ", ""), this.settingsProvider.ActiveRunSettings.SettingsXml); From 498bc09d8e95194e38ced146309a210f8338140b Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 11:29:30 +0200 Subject: [PATCH 4/9] Update CollectArgumentProcessorTests.cs --- .../Processors/CollectArgumentProcessorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index e1c91eac37..7b9caa5d4e 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -578,7 +578,7 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope " ", " ", " ", - " ", + $" ", " ", " ", " ", From ca1af2d181f3f4a52e9d92b3e51644e5b75afa5f Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 11:30:59 +0200 Subject: [PATCH 5/9] Update CollectArgumentProcessorTests.cs --- .../Processors/CollectArgumentProcessorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index 7b9caa5d4e..a8e0c79432 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -583,7 +583,7 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope " ", " ", " ", - $" ", + $" ", " ", " ", ""), this.settingsProvider.ActiveRunSettings.SettingsXml); From 6c9837d87ab3ba1042a9ae9f5e4ebae7917e6dc3 Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 12:30:22 +0200 Subject: [PATCH 6/9] Update CollectArgumentProcessorTests.cs --- .../Processors/CollectArgumentProcessorTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index a8e0c79432..08434bdbc2 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -533,7 +533,7 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope executor.Initialize("XPlat Code Coverage"); Assert.AreEqual(string.Join(Environment.NewLine, - "", + "", "", " ", " c:\AdapterFolderPath", @@ -569,7 +569,7 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope executor.Initialize("XPlat Code Coverage"); Assert.AreEqual(string.Join(Environment.NewLine, - "", + "", "", " ", " ", From 4a46233a902402fd798925b1c221cf52de101b9b Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 12:50:44 +0200 Subject: [PATCH 7/9] Update CollectArgumentProcessorTests.cs --- .../Processors/CollectArgumentProcessorTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index 08434bdbc2..c5ccf6ba19 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -508,12 +508,12 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatOutProcProcDataCollectorSet " ", " ", " ", - $" ", + $" ", " ", " ", " ", " ", - $" ", + $" ", " ", " ", ""), this.settingsProvider.ActiveRunSettings.SettingsXml); @@ -536,14 +536,14 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope "", "", " ", - " c:\AdapterFolderPath", + " c:\\AdapterFolderPath", " ", " ", " ", " ", " ", " ", - " ", + $" ", " ", " ", " ", From 4ee8b2ebf455f4c60307f9258240a29e06f650a2 Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 13:13:42 +0200 Subject: [PATCH 8/9] Update CollectArgumentProcessorTests.cs --- .../Processors/CollectArgumentProcessorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index c5ccf6ba19..53d0ea34a7 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -548,7 +548,7 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope " ", " ", " ", - $" ", + $" ", " ", " ", ""), this.settingsProvider.ActiveRunSettings.SettingsXml); From aba15bf2693399ee9f46bebc333a8aedf4de1d5f Mon Sep 17 00:00:00 2001 From: Medeni Baykal <433724+Haplois@users.noreply.github.com> Date: Mon, 31 May 2021 14:42:48 +0200 Subject: [PATCH 9/9] Fixed tests --- .../Processors/CollectArgumentProcessorTests.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs index 53d0ea34a7..ae7287cb06 100644 --- a/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CollectArgumentProcessorTests.cs @@ -522,7 +522,7 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatOutProcProcDataCollectorSet [TestMethod] public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent() { - var runsettingsString = $"\r\n\r\n \r\n c:\\AdapterFolderPath\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; + var runsettingsString = $"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"; runsettingsString = string.Format(runsettingsString, string.Empty); var runsettings = new RunSettings(); runsettings.LoadSettingsXml(runsettingsString); @@ -535,9 +535,6 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope Assert.AreEqual(string.Join(Environment.NewLine, "", "", - " ", - " c:\\AdapterFolderPath", - " ", " ", " ", " ", @@ -548,7 +545,7 @@ public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPrope " ", " ", " ", - $" ", + $" ", " ", " ", ""), this.settingsProvider.ActiveRunSettings.SettingsXml);