@@ -140,6 +140,37 @@ public void testMenuPrefixes() {
140140 assertMenuPath ("Foo > Bar > Math > Trig > tan" , scripts , 11 );
141141 }
142142
143+ /**
144+ * Tests that scripts are discovered only once when present in multiple base
145+ * directories.
146+ */
147+ @ Test
148+ public void testOverlappingDirectories () {
149+ final Context context = new Context (ScriptService .class );
150+ final ScriptService scriptService = context .service (ScriptService .class );
151+
152+ // Scripts -> Plugins
153+ scriptService .addScriptDirectory (new File (scriptsDir , "Scripts" ),
154+ new MenuPath ("Plugins" ));
155+ // everything else "in place"
156+ scriptService .addScriptDirectory (scriptsDir );
157+
158+ final ArrayList <ScriptInfo > scripts = findScripts (scriptService );
159+
160+ assertEquals (11 , scripts .size ());
161+ assertMenuPath ("Plugins > The Lazy Dog" , scripts , 0 );
162+ assertMenuPath ("Math > add" , scripts , 1 );
163+ assertMenuPath ("Plugins > brown" , scripts , 2 );
164+ assertMenuPath ("Math > Trig > cos" , scripts , 3 );
165+ assertMenuPath ("Math > divide" , scripts , 4 );
166+ assertMenuPath ("Plugins > fox" , scripts , 5 );
167+ assertMenuPath ("Math > multiply" , scripts , 6 );
168+ assertMenuPath ("Plugins > quick" , scripts , 7 );
169+ assertMenuPath ("Math > Trig > sin" , scripts , 8 );
170+ assertMenuPath ("Math > subtract" , scripts , 9 );
171+ assertMenuPath ("Math > Trig > tan" , scripts , 10 );
172+ }
173+
143174 // -- Helper methods --
144175
145176 private ArrayList <ScriptInfo > findScripts (final ScriptService scriptService ) {
0 commit comments