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.
|
||||
//
|
||||
|
||||
#if !NET35PLUS || COMPACT
|
||||
|
||||
#if FALSE
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
|
@ -43,9 +43,6 @@ Global
|
|||
GlobalSection(NestedProjects) = preSolution
|
||||
{4CE79A54-058D-4940-875E-7F6AA9922A7D} = {47C0086D-577C-43DA-ADC7-544F27656E45}
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = Antlr4.Runtime\Antlr4.Runtime.mono.csproj
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
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>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
@ -41,4 +42,10 @@
|
|||
<Name>Antlr4.Runtime.mono</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config">
|
||||
<LogicalName>Test.exe.config</LogicalName>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</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.XPathExpression;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -447,17 +449,12 @@ public abstract class BaseTest {
|
|||
public boolean createProject() {
|
||||
try {
|
||||
String pack = this.getClass().getPackage().getName().replace(".", "/") + "/";
|
||||
// save AssemblyInfo
|
||||
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(pack + "AssemblyInfo.cs");
|
||||
OutputStream output = new FileOutputStream(new File(tmpdir, "AssemblyInfo.cs").getAbsolutePath());
|
||||
while(input.available()>0) {
|
||||
output.write(input.read());
|
||||
}
|
||||
output.close();
|
||||
input.close();
|
||||
// save auxiliary files
|
||||
saveResourceAsFile(pack + "AssemblyInfo.cs", new File(tmpdir, "AssemblyInfo.cs"));
|
||||
saveResourceAsFile(pack + "App.config", new File(tmpdir, "App.config"));
|
||||
// update project
|
||||
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);
|
||||
// update runtime project reference
|
||||
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() {
|
||||
try {
|
||||
String exec = locateExec();
|
||||
|
|
Loading…
Reference in New Issue