tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [02/10] tinkerpop git commit: TINKERPOP-1653 Fixed multiple -e script execution in Console
Date Thu, 25 May 2017 18:52:49 GMT
TINKERPOP-1653 Fixed multiple -e script execution in Console

Added tests - not sure why these weren't there before.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7bf68835
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7bf68835
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7bf68835

Branch: refs/heads/TINKERPOP-1676
Commit: 7bf688350251f64247a71c39900fa015c59eb35b
Parents: 7ea3875
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu May 25 06:45:12 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu May 25 06:45:12 2017 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/console/Console.groovy    |  6 ++---
 .../src/test/python/tests/test_console.py       | 25 ++++++++++++++++----
 .../src/test/python/x-printed.script            | 21 ++++++++++++++++
 gremlin-console/src/test/python/x.groovy        | 20 ----------------
 gremlin-console/src/test/python/x.script        | 20 ++++++++++++++++
 .../src/test/python/y-printed.script            | 21 ++++++++++++++++
 gremlin-console/src/test/python/y.groovy        | 20 ----------------
 gremlin-console/src/test/python/y.script        | 20 ++++++++++++++++
 .../src/test/python/z-printed.script            | 21 ++++++++++++++++
 gremlin-console/src/test/python/z.groovy        | 20 ----------------
 gremlin-console/src/test/python/z.script        | 20 ++++++++++++++++
 11 files changed, 147 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index 393f1f2..3bdc8a1 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -365,7 +365,7 @@ class Console {
     }
 
     private void executeInShell(final List<List<String>> scriptsAndArgs) {
-        scriptsAndArgs.each { scriptAndArgs ->
+        scriptsAndArgs.eachWithIndex { scriptAndArgs, idx ->
             final String scriptFile = scriptAndArgs[0]
             try {
                 // check if this script comes with arguments. if so then set them up in an
"args" bundle
@@ -400,8 +400,6 @@ class Console {
 
                     }
                 }
-
-                if (!interactive) System.exit(0)
             } catch (FileNotFoundException ignored) {
                 io.err.println(Colorizer.render(Preferences.errorColor, "Gremlin file not
found at [$scriptFile]."))
                 if (!interactive) System.exit(1)
@@ -410,6 +408,8 @@ class Console {
                 if (!interactive) System.exit(1)
             }
         }
+
+        if (!interactive) System.exit(0)
     }
 
     public static void main(final String[] args) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/tests/test_console.py
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/tests/test_console.py b/gremlin-console/src/test/python/tests/test_console.py
index f079291..407b563 100644
--- a/gremlin-console/src/test/python/tests/test_console.py
+++ b/gremlin-console/src/test/python/tests/test_console.py
@@ -34,7 +34,7 @@ class TestConsole(object):
         TestConsole._close(child)
 
     def test_just_dash_i(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i x.groovy")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i x.script")
         TestConsole._expect_gremlin_header(child)
         TestConsole._send(child, "x")
         child.expect("==>2\r\n")
@@ -42,7 +42,7 @@ class TestConsole(object):
         TestConsole._close(child)
 
     def test_dash_i_with_args(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.groovy 1 2 3")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.script 1 2 3")
         TestConsole._expect_gremlin_header(child)
         TestConsole._send(child, "y")
         child.expect("==>6\r\n")
@@ -50,7 +50,7 @@ class TestConsole(object):
         TestConsole._close(child)
 
     def test_dash_i_multiple_scripts(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.groovy 1 2 3 -i x.groovy -i \"z.groovy
x -i --color -D\"")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.script 1 2 3 -i x.script -i \"z.script
x -i --color -D\"")
         TestConsole._expect_gremlin_header(child)
         TestConsole._send(child, "y")
         child.expect("==>6\r\n")
@@ -63,8 +63,25 @@ class TestConsole(object):
         TestConsole._expect_prompt(child)
         TestConsole._close(child)
 
+    def test_just_dash_e(self):
+        child = pexpect.spawn(TestConsole.gremlinsh + "-e x-printed.script")
+        child.expect("2\r\n")
+        TestConsole._close(child)
+
+    def test_dash_e_with_args(self):
+        child = pexpect.spawn(TestConsole.gremlinsh + "-e y-printed.script 1 2 3")
+        child.expect("6\r\n")
+        TestConsole._close(child)
+
+    def test_dash_e_multiple_scripts(self):
+        child = pexpect.spawn(TestConsole.gremlinsh + "-e y-printed.script 1 2 3 -e x-printed.script
-e \"z-printed.script x -e --color -D\"")
+        child.expect("6\r\n")
+        child.expect("2\r\n")
+        child.expect("argument=\[x, -e, --color, -D\]\r\n")
+        TestConsole._close(child)
+
     def test_no_mix_dash_i_and_dash_e(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.groovy 1 2 3 -i x.groovy -e \"z.groovy
x -i --color -D\"")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.script 1 2 3 -i x.script -e \"z.script
x -i --color -D\"")
         child.expect("-i and -e options are mutually exclusive - provide one or the other")
         child.expect(pexpect.EOF)
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/x-printed.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/x-printed.script b/gremlin-console/src/test/python/x-printed.script
new file mode 100644
index 0000000..9be57a5
--- /dev/null
+++ b/gremlin-console/src/test/python/x-printed.script
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+x = 1 + 1
+println x
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/x.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/x.groovy b/gremlin-console/src/test/python/x.groovy
deleted file mode 100644
index 31a9f19..0000000
--- a/gremlin-console/src/test/python/x.groovy
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-x = 1 + 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/x.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/x.script b/gremlin-console/src/test/python/x.script
new file mode 100644
index 0000000..31a9f19
--- /dev/null
+++ b/gremlin-console/src/test/python/x.script
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+x = 1 + 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/y-printed.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/y-printed.script b/gremlin-console/src/test/python/y-printed.script
new file mode 100644
index 0000000..e297186
--- /dev/null
+++ b/gremlin-console/src/test/python/y-printed.script
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+y = args.collect{Integer.parseInt(it)}.sum()
+println y
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/y.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/y.groovy b/gremlin-console/src/test/python/y.groovy
deleted file mode 100644
index 8b0adf6..0000000
--- a/gremlin-console/src/test/python/y.groovy
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-y = args.collect{Integer.parseInt(it)}.sum()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/y.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/y.script b/gremlin-console/src/test/python/y.script
new file mode 100644
index 0000000..8b0adf6
--- /dev/null
+++ b/gremlin-console/src/test/python/y.script
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+y = args.collect{Integer.parseInt(it)}.sum()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/z-printed.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/z-printed.script b/gremlin-console/src/test/python/z-printed.script
new file mode 100644
index 0000000..676542a
--- /dev/null
+++ b/gremlin-console/src/test/python/z-printed.script
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+z = "argument=" + args
+println z
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/z.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/z.groovy b/gremlin-console/src/test/python/z.groovy
deleted file mode 100644
index 3d7d101..0000000
--- a/gremlin-console/src/test/python/z.groovy
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-z = "argument=" + args
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/z.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/z.script b/gremlin-console/src/test/python/z.script
new file mode 100644
index 0000000..3d7d101
--- /dev/null
+++ b/gremlin-console/src/test/python/z.script
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+z = "argument=" + args
\ No newline at end of file


Mime
View raw message