Skip to content

Commit

Permalink
create new building target 'GenerateTests' (#3087)
Browse files Browse the repository at this point in the history
  • Loading branch information
changlong-liu authored Feb 14, 2023
1 parent 43c568a commit c68fdee
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/AutoRest.CSharp/build/CodeGeneration.targets
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@
<Exec Command="npx autorest@$(AutoRestVersion) --max-memory-size=8192 --skip-csproj --skip-upgrade-check --version=$(AutoRestCoreVersion) $(AutoRestTestsInput) $(AutoRestAdditionalParameters) --use=$(MSBuildThisFileDirectory)../tools/net6.0/any/ --output-folder=$(MSBuildProjectDirectory)/Generated --clear-output-folder=true --shared-source-folders=&quot;$(AzureCoreSharedCodeDirectory);$(AutoRestSharedCodeDirectory)&quot; --testmodeler={}" />
</Target>

<Target Name="GenerateTests" Condition="'$(AutoRestTestsInput)' != ''">
<PropertyGroup>

</PropertyGroup>

<ReadLinesFromFile File="$(AutoRestTestsInput)">
<Output TaskParameter="Lines" ItemName="AutoRestInputLines"/>
</ReadLinesFromFile>

<ItemGroup>
<GithubUrls Include="$([System.Text.RegularExpressions.Regex]::Match('%(AutoRestInputLines.Identity)', 'https?://(raw.)?github.+'))" />
<GithubUrlsWithoutIssues Include="%(GithubUrls.Identity)" Condition="! ($([System.Text.RegularExpressions.Regex]::IsMatch('%(GithubUrls.Identity)', '/issues/\d+')))" />
<GithubUrlsWithoutHash Include="%(GithubUrlsWithoutIssues.Identity)" Condition="! ($([System.Text.RegularExpressions.Regex]::IsMatch('%(GithubUrlsWithoutIssues.Identity)', '[\w\d]{40}')))" />
</ItemGroup>

<Error Text="Following GitHub URLs do not contain commit hash: @(GithubUrlsWithoutHash) please use permalinks for code generation inputs (see https://help.github.com/en/github/managing-files-in-a-repository/getting-permanent-links-to-files) " Condition="'@(GithubUrlsWithoutHash)' != ''" />

<Exec Command="npx autorest@$(AutoRestVersion) --max-memory-size=8192 --skip-csproj --skip-upgrade-check --version=$(AutoRestCoreVersion) $(AutoRestTestsInput) $(AutoRestAdditionalParameters) --use=$(MSBuildThisFileDirectory)../tools/net6.0/any/ --output-folder=$(MSBuildProjectDirectory)/Generated --clear-output-folder=true --shared-source-folders=&quot;$(AzureCoreSharedCodeDirectory);$(AutoRestSharedCodeDirectory)&quot; --testmodeler={}" />
</Target>

<PropertyGroup Condition="'$(_GenerateCode)' == 'true'">
<NoWarn>$(NoWarn);CA1812</NoWarn>
</PropertyGroup>
Expand Down

0 comments on commit c68fdee

Please sign in to comment.