-
Notifications
You must be signed in to change notification settings - Fork 64
[tests] fix for Xamarin.Android.Tools.Bytecode-Tests #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Context: dotnet/android#978 When bumping java.interop in xamarin-android, a test failure occurred in the `ClassPath.GetDocletType` method. This was added in dotnet#188, but since `ANDROID_SDK_PATH` is not set during java.interop’s test runs the test was skipped. The incoming `path` can be a directory, so the `File.OpenText` call will fail in that case. Added a `File.Exists` check as a fix.
|
@jonathanpeppers, |
|
This PR concerns me, because the entire method is starting to concern me. Then there's line 243: using (var reader = File.OpenText (Path.Combine (path, "index.html")))If Which makes line 255 really weird and suspect: if Did it ever work? PR #188 was only merged 22 days ago; maybe that code path hasn't actually been used or tested yet, especially since PR #188 contained no unit tests. (Doh!) |
| using (var reader = File.OpenText (path)) { | ||
| int len = reader.ReadBlock (buf, 0, buf.Length); | ||
| rawXML = new string (buf, 0, len); | ||
| if (File.Exists (path)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...Which means this proposed "fix" is Doomed To Fail™: if path must be a directory, then File.Exist(path) will always be false, meaning this code is dead code; it's not executable.
I think we need @Redth to chime in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the ClassParse task just passes in DocumentationPaths strings which usually is a directory, but could be a file, as the ApiXmlDocPaths is intended to be a path to an xml file.
I think this fix should work in this case since File.Exists will indeed skip over directories and this code is only hit for files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a quick test we could add with a file? Looking at the code, I think this part would fail if a file path came in:
using (var reader = File.OpenText (Path.Combine (path, "index.html")))
reader.ReadBlock (buf, 0, buf.Length);
|
@Redth is going to address in another PR |
Context: dotnet/android#978
When bumping java.interop in xamarin-android, a test failure occurred
in the
ClassPath.GetDocletTypemethod. This was added in #188, butsince
ANDROID_SDK_PATHis not set during java.interop’s test runs thetest was skipped.
The incoming
pathcan be a directory, so theFile.OpenTextcallwill fail in that case. Added a
File.Existscheck as a fix.