forked from jasder/antlr
Fix failing C# tests
As a result of a mono upgrade, tests on non windows platform would fail due to a warning. This fix removes the warning by providing compatibility information as part of the build. HashSet was also renamed to a clean name.
This commit is contained in:
parent
1b0b04aa88
commit
2162afb33d
|
@ -26,8 +26,7 @@
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#if !NET35PLUS || COMPACT
|
#if FALSE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
|
@ -43,9 +43,6 @@ Global
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{4CE79A54-058D-4940-875E-7F6AA9922A7D} = {47C0086D-577C-43DA-ADC7-544F27656E45}
|
{4CE79A54-058D-4940-875E-7F6AA9922A7D} = {47C0086D-577C-43DA-ADC7-544F27656E45}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(MonoDevelopProperties) = preSolution
|
|
||||||
StartupItem = Antlr4.Runtime\Antlr4.Runtime.mono.csproj
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
@ -41,4 +42,10 @@
|
||||||
<Name>Antlr4.Runtime.mono</Name>
|
<Name>Antlr4.Runtime.mono</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config">
|
||||||
|
<LogicalName>Test.exe.config</LogicalName>
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v2.0.50727"/>
|
||||||
|
<supportedRuntime version="v4.0"/>
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
|
@ -56,8 +56,10 @@ import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.xpath.XPathConstants;
|
import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathExpression;
|
import javax.xml.xpath.XPathExpression;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -447,17 +449,12 @@ public abstract class BaseTest {
|
||||||
public boolean createProject() {
|
public boolean createProject() {
|
||||||
try {
|
try {
|
||||||
String pack = this.getClass().getPackage().getName().replace(".", "/") + "/";
|
String pack = this.getClass().getPackage().getName().replace(".", "/") + "/";
|
||||||
// save AssemblyInfo
|
// save auxiliary files
|
||||||
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(pack + "AssemblyInfo.cs");
|
saveResourceAsFile(pack + "AssemblyInfo.cs", new File(tmpdir, "AssemblyInfo.cs"));
|
||||||
OutputStream output = new FileOutputStream(new File(tmpdir, "AssemblyInfo.cs").getAbsolutePath());
|
saveResourceAsFile(pack + "App.config", new File(tmpdir, "App.config"));
|
||||||
while(input.available()>0) {
|
|
||||||
output.write(input.read());
|
|
||||||
}
|
|
||||||
output.close();
|
|
||||||
input.close();
|
|
||||||
// update project
|
// update project
|
||||||
String projectName = isWindows() ? "Antlr4.Test.vs2013.csproj" : "Antlr4.Test.mono.csproj";
|
String projectName = isWindows() ? "Antlr4.Test.vs2013.csproj" : "Antlr4.Test.mono.csproj";
|
||||||
input = Thread.currentThread().getContextClassLoader().getResourceAsStream(pack + projectName);
|
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(pack + projectName);
|
||||||
Document prjXml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input);
|
Document prjXml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input);
|
||||||
// update runtime project reference
|
// update runtime project reference
|
||||||
String runtimePath = System.getProperty("antlr-csharp-runtime-project");
|
String runtimePath = System.getProperty("antlr-csharp-runtime-project");
|
||||||
|
@ -498,6 +495,16 @@ public abstract class BaseTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveResourceAsFile(String resourceName, File file) throws IOException {
|
||||||
|
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
|
||||||
|
OutputStream output = new FileOutputStream(file.getAbsolutePath());
|
||||||
|
while(input.available()>0) {
|
||||||
|
output.write(input.read());
|
||||||
|
}
|
||||||
|
output.close();
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
|
||||||
public String execTest() {
|
public String execTest() {
|
||||||
try {
|
try {
|
||||||
String exec = locateExec();
|
String exec = locateExec();
|
||||||
|
|
Loading…
Reference in New Issue