Skip to content

Commit cf385eb

Browse files
[tests] ported environment variables to MSBuild
This ensures the following values are set on Windows: - MONO_TRACE_LISTENER - JAVA_INTEROP_GREF_LOG - JAVA_INTEROP_LREF_LOG This also cleans up what needs to be done downstream in xamarin-android: dotnet/android#949 This required a new `Java.Interop.BootstrapTasks` project that adds a `SetEnvironmentVariable` MSBuild task. This will be useful down the road, for setting "prepare" steps in this repo for Windows. Also minor updates to `.gitignore` file.
1 parent 968b474 commit cf385eb

File tree

7 files changed

+117
-3
lines changed

7 files changed

+117
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ TestResult-*.xml
88
xa-gendarme.html
99
packages
1010
.vs/
11+
*.userprefs

Java.Interop.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil.Mdb",
9797
EndProject
9898
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.GenericMarshaler", "src\Java.Interop.GenericMarshaler\Java.Interop.GenericMarshaler.csproj", "{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}"
9999
EndProject
100+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.BootstrapTasks", "src\Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj", "{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}"
101+
EndProject
100102
Global
101103
GlobalSection(SolutionConfigurationPlatforms) = preSolution
102104
Debug|Any CPU = Debug|Any CPU
@@ -339,6 +341,14 @@ Global
339341
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
340342
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
341343
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Release|Any CPU.Build.0 = Release|Any CPU
344+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
345+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
346+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
347+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.Release|Any CPU.Build.0 = Release|Any CPU
348+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
349+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
350+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.XAIntegrationRelease|Any CPU.ActiveCfg = Release|Any CPU
351+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}.XAIntegrationRelease|Any CPU.Build.0 = Release|Any CPU
342352
EndGlobalSection
343353
GlobalSection(NestedProjects) = preSolution
344354
{0C001D50-4176-45AE-BDC8-BA626508B0CC} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
@@ -381,5 +391,6 @@ Global
381391
{15945D4B-FF56-4BCC-B598-2718D199DD08} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
382392
{C0487169-8F81-497F-919E-EB42B1D0243F} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
383393
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF} = {4C173212-371D-45D8-BA83-9226194F48DC}
394+
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A} = {172B608B-E6F3-41CC-9949-203A76BA247C}
384395
EndGlobalSection
385396
EndGlobal

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ shell:
137137

138138
# $(call RUN_TEST,filename,log-lref?)
139139
define RUN_TEST
140-
MONO_TRACE_LISTENER=Console.Out \
141-
JAVA_INTEROP_GREF_LOG=g-$(basename $(notdir $(1))).txt $(if $(2),JAVA_INTEROP_LREF_LOG=l-$(basename $(notdir $(1))).txt,) \
142140
$(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/RunNUnitTests.targets /p:TestAssembly=$(1) ;
143141
endef
144142

build-tools/scripts/RunNUnitTests.targets

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
<_NUnit>$(_Runtime) packages\NUnit.Runners.2.6.3\tools\nunit-console.exe</_NUnit>
99
<_Run Condition=" '$(RUN)' != '' ">--run=&quot;$(RUN)&quot;</_Run>
1010
</PropertyGroup>
11+
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\Java.Interop.BootstrapTasks.dll" TaskName="Java.Interop.BootstrapTasks.SetEnvironmentVariable" />
1112
<ItemGroup>
1213
<_TestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\*-*Tests.dll" Condition=" '$(TestAssembly)' == '' " />
1314
<_TestAssembly Include="$(TestAssembly)" Condition=" '$(TestAssembly)' != '' " />
1415
</ItemGroup>
15-
<Target Name="RunTests">
16+
<Target Name="RunTests"
17+
Outputs="$(_TopDir)\TestResult-%(_TestAssembly.Filename).xml">
18+
<SetEnvironmentVariable Name="MONO_TRACE_LISTENER" Value="Console.Out" />
19+
<SetEnvironmentVariable Name="JAVA_INTEROP_GREF_LOG" Value="g-%(_TestAssembly.Filename).txt" />
20+
<SetEnvironmentVariable Name="JAVA_INTEROP_LREF_LOG" Value="l-%(_TestAssembly.Filename).txt" />
1621
<Exec
1722
Command="$(_NUnit) $(NUNIT_EXTRA) %(_TestAssembly.Identity) $(_Run) --noshadow --result=&quot;TestResult-%(Filename).xml&quot; --output=&quot;bin\Test$(Configuration)\TestOutput-%(Filename).txt&quot;"
1823
WorkingDirectory="$(_TopDir)"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>Java.Interop.BootstrapTasks</RootNamespace>
9+
<AssemblyName>Java.Interop.BootstrapTasks</AssemblyName>
10+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
11+
<ProductVersion>8.0.30703</ProductVersion>
12+
<SchemaVersion>2.0</SchemaVersion>
13+
</PropertyGroup>
14+
<Import Project="..\..\Configuration.props" />
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>True</DebugSymbols>
17+
<DebugType>Full</DebugType>
18+
<Optimize>False</Optimize>
19+
<OutputPath>..\..\bin\BuildDebug</OutputPath>
20+
<ErrorReport>prompt</ErrorReport>
21+
<WarningLevel>4</WarningLevel>
22+
<ConsolePause>false</ConsolePause>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<Optimize>true</Optimize>
26+
<OutputPath>..\..\bin\BuildRelease</OutputPath>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
<ConsolePause>false</ConsolePause>
30+
</PropertyGroup>
31+
<ItemGroup>
32+
<Reference Include="mscorlib" />
33+
<Reference Include="System" />
34+
<Reference Include="System.Net.Http" />
35+
<Reference Include="System.Xml" />
36+
<Reference Include="Microsoft.Build.Framework" />
37+
<Reference Include="Microsoft.Build.Utilities.v4.0" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<Compile Include="Properties\AssemblyInfo.cs" />
41+
<Compile Include="Java.Interop.BootstrapTasks\SetEnvironmentVariable.cs" />
42+
</ItemGroup>
43+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
44+
</Project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
3+
using Microsoft.Build.Framework;
4+
using Microsoft.Build.Utilities;
5+
6+
namespace Java.Interop.BootstrapTasks
7+
{
8+
public class SetEnvironmentVariable : Task
9+
{
10+
[Required]
11+
public string Name { get; set; }
12+
13+
[Required]
14+
public string Value { get; set; }
15+
16+
public override bool Execute ()
17+
{
18+
Log.LogMessage (MessageImportance.Low, $"Task {nameof (SetEnvironmentVariable)}");
19+
Log.LogMessage (MessageImportance.Low, $" {nameof (Name)}: {Name}");
20+
Log.LogMessage (MessageImportance.Low, $" {nameof (Value)}: {Value}");
21+
22+
Environment.SetEnvironmentVariable (Name, Value);
23+
24+
return !Log.HasLoggedErrors;
25+
}
26+
}
27+
}
28+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
// Information about this assembly is defined by the following attributes.
5+
// Change them to the values specific to your project.
6+
7+
[assembly: AssemblyTitle ("Java.Interop.BootstrapTasks")]
8+
[assembly: AssemblyDescription ("")]
9+
[assembly: AssemblyConfiguration ("")]
10+
[assembly: AssemblyCompany ("Xamarin Inc.")]
11+
[assembly: AssemblyProduct ("")]
12+
[assembly: AssemblyCopyright ("Xamarin Inc.")]
13+
[assembly: AssemblyTrademark ("Xamarin")]
14+
[assembly: AssemblyCulture ("")]
15+
16+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+
[assembly: AssemblyVersion ("1.0.*")]
21+
22+
// The following attributes are used to specify the signing key for the assembly,
23+
// if desired. See the Mono documentation for more information about signing.
24+
25+
//[assembly: AssemblyDelaySign(false)]
26+
//[assembly: AssemblyKeyFile("")]
27+

0 commit comments

Comments
 (0)