Baunsgaard commented on code in PR #2241:
URL: https://github.com/apache/systemds/pull/2241#discussion_r2021042224


##########
src/test/java/org/apache/sysds/test/component/misc/CLIOptionsParserTest.java:
##########
@@ -450,4 +455,193 @@ public void testNVArgs4() throws Exception {
                Map<String, String> m = o.argVals;
                Assert.assertEquals("'def'", m.get("$abc"));
        }
+
+       @Test
+       public void parseCLArgumentsLineageDAGHEIGHTTest() throws 
ParseException {
+               String[] args = new String[]{"-f", "test", "-lineage", 
"policy_dagheight"};
+               DMLOptions opts = parseCLArguments(args);
+               Assert.assertTrue(opts.lineage && opts.linCachePolicy == 
LineageCacheConfig.LineageCachePolicy.DAGHEIGHT);
+       }
+
+       @Test
+       public void parseCLIArgumentsLineageEstimateTest() throws 
ParseException {
+               String[] args = new String[]{"-f", "test", "-lineage", 
"estimate"};
+               DMLOptions opts = parseCLArguments(args);
+               Assert.assertTrue(opts.lineage && opts.lineage_estimate);
+       }
+
+       @Test
+       public void parseCLArgumentsGPUTest() throws ParseException {
+               String[] args = new String[]{"-f", "test", "-gpu",};
+               DMLOptions opts = parseCLArguments(args);
+               Assert.assertTrue(opts.gpu);
+       }
+
+       @Test
+       public void parseCLArgumentsInvalidExplainTest() throws ParseException {
+               String[] args = new String[]{"-f", "test","-explain","XYZ"};
+               try {
+                       parseCLArguments(args);
+               } catch (ParseException e) {
+                       assert e.getMessage().equals("Invalid argument 
specified for -hops option, must be one of [hops, runtime, recompile_hops, 
recompile_runtime, codegen, codegen_recompile]");
+               }
+       }
+       @Test

Review Comment:
   there is some formatting issues in this PR.



##########
src/test/java/org/apache/sysds/test/component/misc/DMLScriptTest.java:
##########
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.sysds.test.component.misc;
+
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.sysds.api.DMLOptions;
+import org.apache.sysds.api.DMLScript;
+import org.apache.sysds.parser.LanguageException;
+import org.apache.sysds.test.LoggingUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.apache.sysds.api.DMLScript.executeScript;
+import static org.apache.sysds.api.DMLScript.readDMLScript;
+
[email protected]
+public class DMLScriptTest {
+
+    @Test
+    public void executeDMLScriptParsingExceptionTest() throws IOException {
+        // Create a ListAppender to capture log messages
+        final LoggingUtils.TestAppender appender = LoggingUtils.overwrite();
+        try {
+            Logger.getLogger(DMLScript.class).setLevel(Level.DEBUG);
+
+            String[] args = new String[]{"-f", "test","-explain","XYZ"};
+            Assert.assertFalse(executeScript(args));
+
+            final List<LoggingEvent> log = LoggingUtils.reinsert(appender);
+            Assert.assertEquals(log.get(0).getMessage(), "Parsing Exception 
Invalid argument specified for -hops option, must be one of [hops, runtime, 
recompile_hops, recompile_runtime, codegen, codegen_recompile]");
+        } finally {
+            LoggingUtils.reinsert(appender);
+        }
+}
+
+    @Test
+    public void executeDMLScriptAlreadySelectedExceptionTest() throws 
IOException {
+        final LoggingUtils.TestAppender appender = LoggingUtils.overwrite();
+        try {
+            Logger.getLogger(DMLScript.class).setLevel(Level.DEBUG);
+
+            String[] args = new String[]{"-f", "test", "-clean"};
+            Assert.assertFalse(executeScript(args));
+
+            final List<LoggingEvent> log = LoggingUtils.reinsert(appender);
+            Assert.assertEquals(log.get(0).getMessage(), "Mutually exclusive 
options were selected. The option 'clean' was specified but an option from this 
group has already been selected: 'f'");
+        } finally {
+            LoggingUtils.reinsert(appender);
+        }
+}

Review Comment:
   .



##########
src/test/java/org/apache/sysds/test/component/misc/DMLScriptTest.java:
##########
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.sysds.test.component.misc;
+
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.sysds.api.DMLOptions;
+import org.apache.sysds.api.DMLScript;
+import org.apache.sysds.parser.LanguageException;
+import org.apache.sysds.test.LoggingUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.apache.sysds.api.DMLScript.executeScript;
+import static org.apache.sysds.api.DMLScript.readDMLScript;
+
[email protected]
+public class DMLScriptTest {
+
+    @Test
+    public void executeDMLScriptParsingExceptionTest() throws IOException {
+        // Create a ListAppender to capture log messages
+        final LoggingUtils.TestAppender appender = LoggingUtils.overwrite();
+        try {
+            Logger.getLogger(DMLScript.class).setLevel(Level.DEBUG);
+
+            String[] args = new String[]{"-f", "test","-explain","XYZ"};
+            Assert.assertFalse(executeScript(args));
+
+            final List<LoggingEvent> log = LoggingUtils.reinsert(appender);
+            Assert.assertEquals(log.get(0).getMessage(), "Parsing Exception 
Invalid argument specified for -hops option, must be one of [hops, runtime, 
recompile_hops, recompile_runtime, codegen, codegen_recompile]");
+        } finally {
+            LoggingUtils.reinsert(appender);
+        }
+}

Review Comment:
   format



-- 
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]

Reply via email to