Welcome to mirror list, hosted at ThFree Co, Russian Federation.

E2ETesting.targets « E2ETesting « Shared « src - github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d9af5d51a114dc25264aecc7fcff166982fc729b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<Project>
  <!-- Version of this SDK is set in global.json -->
  <Sdk Name="Yarn.MSBuild" />

  <!-- Make sure the settings files get copied to the test output folder. -->
  <ItemGroup>
    <None Update="e2eTestSettings*.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <Content Update="e2eTestSettings*.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <!-- Ensuring that everything is ready before build -->
  <Target Name="EnsureNodeJSRestored" Condition="'$(SeleniumE2ETestsSupported)' == 'true'" BeforeTargets="Build">
    <Message Text="Running yarn install on $(MSBuildProjectFile)" Importance="High" />

    <Message Condition="'$(EnforceE2ETestPrerequisites)' != 'true'"
      Importance="High"
      Text="Prerequisites were not enforced at build time. Running Yarn or the E2E tests might fail as a result. Check /src/Shared/E2ETesting/Readme.md for instructions." />

    <Yarn Command="install --mutex network --frozen-lockfile" Condition="'$(EnforceE2ETestPrerequisites)' == 'true'" IgnoreStandardErrorWarningFormat="$(IgnoreYarnWarnings)"/>
  </Target>

  <Target
    Name="WarnSeleniumNotSupported"
    BeforeTargets="Build"
    Condition="'$(SeleniumE2ETestsSupported)' != 'true'">
    <Message Importance="High" Text="Selenium tests are not supported for OS '$(OS)' and architecture '$(TargetArchitecture)'." />
  </Target>

  <!-- Running prerequisites -->

  <Target Name="EnsurePrerequisites" Condition="'$(EnforceE2ETestPrerequisites)' == 'true'" BeforeTargets="EnsureNodeJSRestored">
    <PropertyGroup>
      <_PackageJson>$(MSBuildProjectDirectory)\package.json</_PackageJson>
    </PropertyGroup>

    <!-- JAVA -->
    <!-- https://github.com/dotnet/aspnetcore-internal/issues/2555 -->
    <Message Importance="High" Text="Ensuring JAVA is available" />
    <Exec Command="java -version" />
    <Message Importance="High" Text="JAVA is available on the PATH" />

    <!-- package.json -->
    <Error Condition="!Exists('$(_PackageJson)')" Text="Can't find $(_PackageJson)" />
    <ReadLinesFromFile File="$(_PackageJson)">
      <Output TaskParameter="Lines" ItemName="_PackageJsonLines" />
    </ReadLinesFromFile>

    <PropertyGroup>
      <_PackageJsonLinesContent>@(_PackageJsonLines)</_PackageJsonLinesContent>
      <_PackageJsonSeleniumPackage>&quot;selenium-standalone&quot;: &quot;^7.1.0&quot;</_PackageJsonSeleniumPackage>
    </PropertyGroup>

    <Error
      Condition="!$(_PackageJsonLinesContent.Contains ('$(_PackageJsonSeleniumPackage)'))"
      Text="Can't find dependency $(_PackageJsonSeleniumPackage) in '$(_PackageJson)'" />
  </Target>

  <!-- Resolve content roots at build time -->

  <Target Name="_ResolveTestProjectReferences" DependsOnTargets="ResolveReferences">
    <PropertyGroup>
      <_DefaultProjectRoot>$([System.IO.Path]::GetFullPath($(_DefaultProjectFilter)))</_DefaultProjectRoot>
    </PropertyGroup>
    <ItemGroup>
      <_ContentRootProjectReferences
        Include="@(ReferencePath)"
        Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ProjectReference' AND $([System.String]::Copy(%(ReferencePath.MSBuildSourceProjectFile)).StartsWith('$(_DefaultProjectRoot)'))" />
    </ItemGroup>
  </Target>

  <Target Name="_AddTestProjectMetadataAttributes" BeforeTargets="GetAssemblyAttributes" DependsOnTargets="_ResolveTestProjectReferences">
    <ItemGroup>
      <_ContentRootMetadata
        Condition="'%(_ContentRootProjectReferences.Identity)' != ''"
        Include="%(_ContentRootProjectReferences.Identity)"
        AssemblyName="%(_ContentRootProjectReferences.FusionName)"
        ContentRootPath="$([System.IO.Path]::GetDirectoryName(%(_ContentRootProjectReferences.MSBuildSourceProjectFile)))"
        ContentRootTest="$([System.IO.Path]::GetFileName(%(_ContentRootProjectReferences.MSBuildSourceProjectFile)))"
        Priority="0" />
    </ItemGroup>

    <ItemGroup>
      <AssemblyAttribute
        Condition=" '%(_ContentRootMetadata.Identity)' != '' "
        Include="System.Reflection.AssemblyMetadataAttribute">
        <_Parameter1>TestAssemblyApplication[%(_ContentRootMetadata.AssemblyName)]</_Parameter1>
        <_Parameter2>%(_ContentRootMetadata.ContentRootPath)</_Parameter2>
      </AssemblyAttribute>
    </ItemGroup>
  </Target>

  <Target Name="_AddSeleniumSupportedMetadataAttribute" BeforeTargets="GetAssemblyAttributes">
    <PropertyGroup>
      <_SeleniumE2ETestsSupportedAttributeValue>false</_SeleniumE2ETestsSupportedAttributeValue>
      <_SeleniumE2ETestsSupportedAttributeValue Condition="'$(SeleniumE2ETestsSupported)' == 'true'">true</_SeleniumE2ETestsSupportedAttributeValue>
    </PropertyGroup>
    <ItemGroup>
      <AssemblyAttribute
        Include="System.Reflection.AssemblyMetadataAttribute">
        <_Parameter1>Microsoft.AspNetCore.Testing.Selenium.Supported</_Parameter1>
        <_Parameter2>$(_SeleniumE2ETestsSupportedAttributeValue)</_Parameter2>
      </AssemblyAttribute>

      <AssemblyAttribute
        Include="System.Reflection.AssemblyMetadataAttribute">
        <_Parameter1>Microsoft.AspNetCore.Testing.SeleniumConfigPath</_Parameter1>
        <_Parameter2>$(SeleniumConfigPath)</_Parameter2>
      </AssemblyAttribute>
    </ItemGroup>
  </Target>

  <Target Name="_AddProcessTrackingMetadataAttribute" BeforeTargets="GetAssemblyAttributes">
    <MakeDir Directories="$(SeleniumProcessTrackingFolder)" />
    <ItemGroup>
      <AssemblyAttribute
        Include="System.Reflection.AssemblyMetadataAttribute">
        <_Parameter1>Microsoft.AspNetCore.Testing.Selenium.ProcessTracking</_Parameter1>
        <_Parameter2>$(SeleniumProcessTrackingFolder)</_Parameter2>
      </AssemblyAttribute>
    </ItemGroup>
    <MakeDir Directories="$(SauceConnectProcessTrackingFolder)" />
    <ItemGroup>
      <AssemblyAttribute
        Include="System.Reflection.AssemblyMetadataAttribute">
        <_Parameter1>Microsoft.AspNetCore.Testing.SauceConnect.ProcessTracking</_Parameter1>
        <_Parameter2>$(SauceConnectProcessTrackingFolder)</_Parameter2>
      </AssemblyAttribute>
    </ItemGroup>
  </Target>

  <Target Name="_EnsureSeleniumScreenShotsFolder" BeforeTargets="Build">
    <MakeDir Directories="$(SeleniumScreenShotsFolderPath)" />
  </Target>

</Project>