-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set SourceLink path in target (#272)
* Set SourceLink path in target * Allow disabling Source Link file generation in a target
- Loading branch information
Showing
3 changed files
with
158 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Xml.Linq; | ||
using LibGit2Sharp; | ||
using TestUtilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.SourceLink.IntegrationTests | ||
{ | ||
public class TargetTests : DotNetSdkTestBase | ||
{ | ||
public TargetTests() | ||
: base("Microsoft.SourceLink.GitHub") | ||
{ | ||
} | ||
|
||
[ConditionalFact(typeof(DotNetSdkAvailable))] | ||
public void GenerateSourceLinkFileTarget_EnableSourceLinkCondition() | ||
{ | ||
GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, "http://github.com/test-org/test-repo"); | ||
|
||
VerifyValues( | ||
customProps: @" | ||
<PropertyGroup> | ||
<Test_DefaultEnableSourceControlManagerQueries>$(EnableSourceControlManagerQueries)</Test_DefaultEnableSourceControlManagerQueries> | ||
<Test_DefaultEnableSourceLink>$(EnableSourceLink)</Test_DefaultEnableSourceLink> | ||
</PropertyGroup> | ||
", | ||
customTargets: @" | ||
<Target Name=""Test_SetEnableSourceLink"" BeforeTargets=""InitializeSourceControlInformation""> | ||
<PropertyGroup> | ||
<EnableSourceLink>false</EnableSourceLink> | ||
</PropertyGroup> | ||
</Target> | ||
", | ||
targets: new[] | ||
{ | ||
"Build" | ||
}, | ||
expressions: new[] | ||
{ | ||
"@(SourceRoot)", | ||
"$(Test_DefaultEnableSourceControlManagerQueries)", | ||
"$(Test_DefaultEnableSourceLink)", | ||
"$(SourceLink)" | ||
}, | ||
expectedResults: new[] | ||
{ | ||
ProjectSourceRoot, | ||
"true", | ||
"true", | ||
"" | ||
}); | ||
} | ||
|
||
[ConditionalFact(typeof(DotNetSdkAvailable))] | ||
public void DefaultValuesForEnableProperties_DesignTimeBuild() | ||
{ | ||
GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, "http://github.com/test-org/test-repo"); | ||
|
||
VerifyValues( | ||
customProps: @" | ||
<PropertyGroup> | ||
<Test_DefaultEnableSourceControlManagerQueries>$(EnableSourceControlManagerQueries)</Test_DefaultEnableSourceControlManagerQueries> | ||
<Test_DefaultEnableSourceLink>$(EnableSourceLink)</Test_DefaultEnableSourceLink> | ||
</PropertyGroup> | ||
", | ||
customTargets: "", | ||
targets: new[] | ||
{ | ||
"Build" | ||
}, | ||
expressions: new[] | ||
{ | ||
"@(SourceRoot)", | ||
"$(Test_DefaultEnableSourceControlManagerQueries)", | ||
"$(Test_DefaultEnableSourceLink)", | ||
"$(SourceLink)" | ||
}, | ||
expectedResults: new[] | ||
{ | ||
"", | ||
"", | ||
"", | ||
"" | ||
}, | ||
additionalCommandLineArgs: "/p:DesignTimeBuild=true"); | ||
} | ||
|
||
[ConditionalFact(typeof(DotNetSdkAvailable))] | ||
public void DefaultValuesForEnableProperties_BuildingForLiveUnitTesting() | ||
{ | ||
GitUtilities.CreateGitRepositoryWithSingleCommit(ProjectDir.Path, new[] { ProjectFileName }, "http://github.com/test-org/test-repo"); | ||
|
||
VerifyValues( | ||
customProps: @" | ||
<PropertyGroup> | ||
<Test_DefaultEnableSourceControlManagerQueries>$(EnableSourceControlManagerQueries)</Test_DefaultEnableSourceControlManagerQueries> | ||
<Test_DefaultEnableSourceLink>$(EnableSourceLink)</Test_DefaultEnableSourceLink> | ||
</PropertyGroup> | ||
", | ||
customTargets: "", | ||
targets: new[] | ||
{ | ||
"Build" | ||
}, | ||
expressions: new[] | ||
{ | ||
"@(SourceRoot)", | ||
"$(Test_DefaultEnableSourceControlManagerQueries)", | ||
"$(Test_DefaultEnableSourceLink)", | ||
"$(SourceLink)" | ||
}, | ||
expectedResults: new[] | ||
{ | ||
"", | ||
"", | ||
"", | ||
"" | ||
}, | ||
additionalCommandLineArgs: "/p:BuildingForLiveUnitTesting=true"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters