-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Add some simple tests for annotation reachability checker in Kotlin. Reviewed By: rgrig Differential Revision: D59587456 Privacy Context Container: L1208441 fbshipit-source-id: a8cfa7a4f0a4030cc8738472dbaf0f15a754151a
- Loading branch information
1 parent
d5be102
commit d84062a
Showing
5 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"force-delete-results-dir": true, | ||
"annotation-reachability-expensive": false, | ||
"annotation-reachability-no-allocation": false, | ||
"annotation-reachability-custom-pairs": [ | ||
{ | ||
"sources": ["UserDefinedSource"], | ||
"sinks": ["UserDefinedSink"], | ||
"sanitizers": ["UserDefinedSanitizer"] | ||
} | ||
], | ||
"annotation-reachability-apply-superclass-annotations": false, | ||
"annotation-reachability-report-source-and-sink": true | ||
} |
51 changes: 51 additions & 0 deletions
51
infer/tests/codetoanalyze/kotlin/annotreach/CustomAnnotations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
package codetoanalyze.kotlin.annotreach | ||
|
||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class UserDefinedSource | ||
|
||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class UserDefinedSink | ||
|
||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class UserDefinedSanitizer | ||
|
||
class CustomAnnotations { | ||
@UserDefinedSink fun sink(): Unit {} | ||
|
||
fun notSink(): Unit {} | ||
|
||
@UserDefinedSource | ||
fun sourceBad(): Unit { | ||
sink() | ||
} | ||
|
||
@UserDefinedSource | ||
fun sourceOk(): Unit { | ||
notSink() | ||
} | ||
|
||
@UserDefinedSanitizer | ||
fun canCallSink(): Unit { | ||
sink() | ||
} | ||
|
||
@UserDefinedSource | ||
fun sourceWithSanitizerOk(): Unit { | ||
canCallSink() | ||
} | ||
|
||
fun notSourceOk(): Unit { | ||
sink() | ||
} | ||
|
||
@UserDefinedSource @UserDefinedSink fun sourceAndSinkAtTheSameTimeBad(): Unit {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
TESTS_DIR = ../../.. | ||
|
||
INFER_OPTIONS = --debug-exceptions --annotation-reachability-only | ||
INFERPRINT_OPTIONS = --issues-tests | ||
|
||
SOURCES = $(wildcard *.kt) | ||
|
||
CLEAN_EXTRA = *.class META-INF | ||
|
||
include $(TESTS_DIR)/kotlinc.make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CustomAnnotations.kt, codetoanalyze.kotlin.annotreach.CustomAnnotations.sourceBad():void, 1, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] | ||
CustomAnnotations.kt, codetoanalyze.kotlin.annotreach.CustomAnnotations.sourceAndSinkAtTheSameTimeBad():void, 0, CHECKERS_ANNOTATION_REACHABILITY_ERROR, no_bucket, ERROR, [] |