Make symlink prohibition rule catch links with folder target · arduino/arduino-lint@1e517c4 (original) (raw)

Original file line number Diff line number Diff line change
@@ -105,14 +105,28 @@ func TestLibraryHasSubmodule(t *testing.T) {
105 105
106 106 func TestLibraryContainsSymlinks(t *testing.T) {
107 107 testLibrary := "Recursive"
108 +// Set up a library with a file target symlink.
108 109 symlinkPath := librariesTestDataPath.Join(testLibrary, "test-symlink")
109 110 // It's probably most friendly to developers using Windows to create the symlink needed for the test on demand.
110 111 err := os.Symlink(librariesTestDataPath.Join(testLibrary, "library.properties").String(), symlinkPath.String())
111 112 require.Nil(t, err, "This test must be run as administrator on Windows to have symlink creation privilege.")
112 113 defer symlinkPath.RemoveAll() // clean up
113 114
114 115 testTables := []libraryRuleFunctionTestTable{
115 - {"Has symlink", testLibrary, ruleresult.Fail, ""},
116 + {"Has file target symlink", testLibrary, ruleresult.Fail, ""},
117 + }
118 +
119 +checkLibraryRuleFunction(LibraryContainsSymlinks, testTables, t)
120 +
121 +err = symlinkPath.RemoveAll()
122 +require.Nil(t, err)
123 +
124 +// Set up a library with a folder target symlink.
125 +err = os.Symlink(librariesTestDataPath.Join(testLibrary, "src").String(), symlinkPath.String())
126 +require.Nil(t, err)
127 +
128 +testTables = []libraryRuleFunctionTestTable{
129 + {"Has folder target symlink", testLibrary, ruleresult.Fail, ""},
116 130 }
117 131
118 132 checkLibraryRuleFunction(LibraryContainsSymlinks, testTables, t)