Skip to content

Commit

Permalink
Fix unreliable test
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Aug 9, 2017
1 parent 8b5e581 commit 3cd1a90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 2 additions & 5 deletions SonarScanner.Shim/ProjectLoader.cs
Expand Up @@ -17,13 +17,10 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using SonarQube.Common;
using System;

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using SonarQube.Common;

namespace SonarScanner.Shim
{
Expand Down
10 changes: 7 additions & 3 deletions Tests/SonarScanner.Shim.Tests/PropertiesFileGeneratorTests.cs
Expand Up @@ -398,10 +398,13 @@ public void FileGen_SharedFiles_CaseInsensitive()
{
// Arrange
string testDir = TestUtils.CreateTestSpecificFolder(this.TestContext);
// Create 2 uuids and order them so that test is reproducible
Guid[] uuids = new Guid[] { Guid.NewGuid(), Guid.NewGuid() };
Array.Sort(uuids);

string project1Dir = TestUtils.EnsureTestSpecificFolder(this.TestContext, "project1");
string project1Path = Path.Combine(project1Dir, "project1.proj");
string project1Info = CreateProjectInfoInSubDir(testDir, "projectName1", Guid.NewGuid(), ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
string project1Info = CreateProjectInfoInSubDir(testDir, "projectName1", uuids[0], ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
var sharedFile = Path.Combine(testDir, "contentFile.txt");
var sharedFileDifferentCase = Path.Combine(testDir, "ContentFile.TXT");
CreateEmptyFile(testDir, "contentFile.txt");
Expand All @@ -412,7 +415,7 @@ public void FileGen_SharedFiles_CaseInsensitive()

string project2Dir = TestUtils.EnsureTestSpecificFolder(this.TestContext, "project2");
string project2Path = Path.Combine(project2Dir, "project2.proj");
string project2Info = CreateProjectInfoInSubDir(testDir, "projectName2", Guid.NewGuid(), ProjectType.Product, false, project2Path, "UTF-8"); // not excluded
string project2Info = CreateProjectInfoInSubDir(testDir, "projectName2", uuids[1], ProjectType.Product, false, project2Path, "UTF-8"); // not excluded

// Reference shared file, but not under the project directory
string contentFileList2 = CreateFile(project2Dir, "contentList.txt", sharedFileDifferentCase);
Expand All @@ -427,6 +430,7 @@ public void FileGen_SharedFiles_CaseInsensitive()
// Assert
SQPropertiesFileReader provider = new SQPropertiesFileReader(result.FullPropertiesFilePath);
provider.AssertSettingExists("sonar.projectBaseDir", testDir);
// First one wins
provider.AssertSettingExists("sonar.sources", sharedFile);
}

Expand Down Expand Up @@ -856,7 +860,7 @@ private static string CreateFile(string parentDir, string fileName, string conte
string projectName, Guid projectGuid, ProjectType projectType, bool isExcluded, string fullProjectPath, string encoding,
AnalysisProperties additionalProperties = null)
{
string newDir = Path.Combine(parentDir, Guid.NewGuid().ToString());
string newDir = Path.Combine(parentDir, projectName);
Directory.CreateDirectory(newDir); // ensure the directory exists

ProjectInfo project = new ProjectInfo()
Expand Down

0 comments on commit 3cd1a90

Please sign in to comment.