Running & Testing Lint Checks in Specific Directories

Skip to first unread message

Zachary Sperske

Jun 7, 2021, 7:44:56 AM6/7/21
to lint-dev
I'm working on a lint check that analyzes vector resources and will fail if the vector is not using a theme attribute from a provided set of attributes ie `android:fillColor="?attr/icon_primary_color"`.

I only want this check to run in a particular resource directory (design-system/icons/drawable). My gradle module has other directories that I don't want the check to run in.

I can simply restrict the path by hardcoding a check into my Detectors `visitAttribute` method, however that will cause my tests to start failing because they use paths like:


If you try and muck with the file path in the test, the detector will no longer run when the test runs.

Is there something in the test API that I am missing to allow paths that are more specific? Are there better ways to limit what directory my lint check runs in? I find myself wanting the ability to add parameters to my lint check but am I missing a simpler solution?

Tor Norbye

Jul 14, 2021, 8:20:44 PM7/14/21
to lint-dev
If I understand correctly you want to make sure that the created test project is also under design-system/icons/drawable ? If you're simply looking for that to be somewhere in the parent you could set a particular root directory for the test.

class SomeTest {
    var temporaryFolder = TemporaryFolder()

    fun `some test`() {
        val root = temporaryFolder.newFolder("design-system/icons/drawable")
       .expect( .... )

-- Tor
Reply all
Reply to author
0 new messages