Skip to content
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

Update some Android astubx models #1052

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions jar-infer/nullaway-integration-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ dependencies {
}
testImplementation project(":nullaway")
testImplementation project(":jar-infer:test-java-lib-jarinfer")

// For now we can only test one of the SDK models at a time; so exactly
// one of the following lines should be uncommented
//testImplementation project(":jar-infer:android-jarinfer-models-sdk28")
//testImplementation project(":jar-infer:android-jarinfer-models-sdk29")
testImplementation project(":jar-infer:android-jarinfer-models-sdk30")
//testImplementation project(":jar-infer:android-jarinfer-models-sdk31")
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,37 @@ public void jarinferNullableReturnsTest() {
"}")
.doTest();
}

/**
* Tests our pre-generated models for Android SDK classes. See also the build.gradle file for this
* project which determines which SDK version's models are being tested.
*/
@Test
public void jarInferAndroidSDKModels() {
compilationHelper
.setArgs(
Arrays.asList(
"-d",
temporaryFolder.getRoot().getAbsolutePath(),
"-XepOpt:NullAway:AnnotatedPackages=com.uber",
"-XepOpt:NullAway:JarInferEnabled=true"))
// stub implementation of SpannableStringBuilder.append(CharSequence) which we know is
// modelled as having a @Nullable parameter
.addSourceLines(
"SpannableStringBuilder.java",
"package android.text;",
"public class SpannableStringBuilder {",
" public SpannableStringBuilder append(CharSequence text) { return this; }",
"}")
.addSourceLines(
"Test.java",
"package com.uber;",
"class Test {",
" void test1(android.text.SpannableStringBuilder builder) {",
" // BUG: Diagnostic contains: passing @Nullable parameter 'null'",
" builder.append(null);",
" }",
"}")
.doTest();
}
}
Loading