nick-boss-tech commented on code in PR #5289:
URL: https://github.com/apache/solr/pull/5289#discussion_r4476220067


##########
solr/core/src/java/org/apache/solr/cli/RunExampleTool.java:
##########
@@ -576,11 +576,17 @@ void initDirs(
 
     exampleDir =
         (exampleDirArg != null) ? Path.of(exampleDirArg) : 
serverDir.getParent().resolve("example");
-    if (!Files.isDirectory(exampleDir))
+    if (!Files.isDirectory(exampleDir)) {

Review Comment:
   Done: the directory check now runs once and the two cases are separate ifs, 
no nesting. In the current head, `f2166af983`.
   
   🤖 *AI-generated text above* 🤖



##########
solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java:
##########
@@ -673,4 +673,81 @@ public void testFailExecuteScript() throws Exception {
     int code = runTool(tool, toolArgs);
     assertEquals("Execution should have failed with return code 1", 1, code);
   }
+
+  @Test
+  public void testMissingDefaultExampleDirectoryExplainsSlimDistribution() 
throws Exception {
+    Path solrServerDir = createTestServerDir();
+    RunExampleTool tool =
+        new RunExampleTool(null, System.in, new 
CLITestHelper.TestingRuntime(false));
+
+    IllegalArgumentException exception =
+        expectThrows(
+            IllegalArgumentException.class,
+            () -> tool.initDirs(solrServerDir.toString(), null, null, null, 
"techproducts"));
+
+    assertEquals(
+        "Examples are not included in the slim distribution. "
+            + "Use the full Solr distribution to run examples.",
+        exception.getMessage());
+  }
+
+  @Test
+  public void testExplicitMissingExampleDirectoryRemainsInvalid() throws 
Exception {
+    Path solrServerDir = createTestServerDir();
+    Path missingExampleDir = 
solrServerDir.getParent().resolve("custom-example");
+    RunExampleTool tool =
+        new RunExampleTool(null, System.in, new 
CLITestHelper.TestingRuntime(false));
+
+    IllegalArgumentException exception =
+        expectThrows(
+            IllegalArgumentException.class,
+            () ->
+                tool.initDirs(
+                    solrServerDir.toString(),
+                    null,
+                    missingExampleDir.toString(),
+                    null,
+                    "techproducts"));
+
+    assertTrue(
+        exception.getMessage(),
+        exception.getMessage().startsWith("Value of --example-dir option is 
invalid! "));

Review Comment:
   Took your "does not exist" wording for the default directory: the message 
now reads "The default example directory does not exist or is not a directory," 
followed by the slim explanation. The user-supplied `--example-dir` message 
keeps "is invalid," since that path was typed in explicitly.
   
   🤖 *AI-generated text above* 🤖



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to