Skip to content

Commit 4e163d8

Browse files
tulinkryVladimir Kotal
authored andcommitted
adding a test case for opengrok python scripts (#2498)
1 parent a5b181f commit 4e163d8

File tree

3 files changed

+76
-9
lines changed

3 files changed

+76
-9
lines changed

opengrok-tools/pom.xml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
4040

4141
<properties>
4242
<python.system.executable>python3</python.system.executable>
43-
<python.executable>env/bin/python</python.executable>
43+
<python.environment>${project.build.directory}/env/bin</python.environment>
4444
</properties>
4545

4646
<profiles>
@@ -53,7 +53,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
5353
</activation>
5454
<properties>
5555
<python.system.executable>python</python.system.executable>
56-
<python.executable>env/Scripts/python</python.executable>
56+
<python.environment>${project.build.directory}/env/Scripts</python.environment>
5757
</properties>
5858
</profile>
5959
</profiles>
@@ -183,7 +183,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
183183
<!-- needed for 'pip install pylint' to work -->
184184
<id>Upgrade pip</id>
185185
<configuration>
186-
<executable>${python.executable}</executable>
186+
<executable>${python.environment}/python</executable>
187187
<workingDirectory>${project.build.directory}</workingDirectory>
188188
<arguments>
189189
<argument>-m</argument>
@@ -204,7 +204,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
204204
<goal>exec</goal>
205205
</goals>
206206
<configuration>
207-
<executable>${python.executable}</executable>
207+
<executable>${python.environment}/python</executable>
208208
<workingDirectory>${project.build.directory}</workingDirectory>
209209
<arguments>
210210
<argument>setup.py</argument>
@@ -218,7 +218,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
218218
<execution>
219219
<id>Install python package for tests/pylint</id>
220220
<configuration>
221-
<executable>${python.executable}</executable>
221+
<executable>${python.environment}/python</executable>
222222
<workingDirectory>${project.build.directory}</workingDirectory>
223223
<arguments>
224224
<argument>setup.py</argument>
@@ -233,7 +233,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
233233
<execution>
234234
<id>Install python lint and flake8</id>
235235
<configuration>
236-
<executable>${python.executable}</executable>
236+
<executable>${python.environment}/python</executable>
237237
<workingDirectory>${project.build.directory}</workingDirectory>
238238
<arguments>
239239
<argument>-m</argument>
@@ -251,7 +251,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
251251
<execution>
252252
<id>Python lint</id>
253253
<configuration>
254-
<executable>${python.executable}</executable>
254+
<executable>${python.environment}/python</executable>
255255
<workingDirectory>${project.build.directory}</workingDirectory>
256256
<arguments>
257257
<argument>-m</argument>
@@ -269,7 +269,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
269269
<execution>
270270
<id>Python flake8</id>
271271
<configuration>
272-
<executable>${python.executable}</executable>
272+
<executable>${python.environment}/python</executable>
273273
<workingDirectory>${project.build.directory}</workingDirectory>
274274
<arguments>
275275
<argument>-m</argument>
@@ -288,8 +288,11 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
288288
<execution>
289289
<id>Test python package</id>
290290
<configuration>
291-
<executable>${python.executable}</executable>
291+
<executable>${python.environment}/python</executable>
292292
<workingDirectory>${project.build.directory}</workingDirectory>
293+
<environmentVariables>
294+
<PATH>${python.environment}:${env.PATH}</PATH>
295+
</environmentVariables>
293296
<arguments>
294297
<argument>setup.py</argument>
295298
<argument>test</argument>

opengrok-tools/setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def get_version(version):
5959
'resource',
6060
'filelock'
6161
],
62+
tests_require=[
63+
'parameterized'
64+
],
6265
entry_points={
6366
'console_scripts': [
6467
'opengrok-config-merge=opengrok_tools.config_merge:main',
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
3+
#
4+
# CDDL HEADER START
5+
#
6+
# The contents of this file are subject to the terms of the
7+
# Common Development and Distribution License (the "License").
8+
# You may not use this file except in compliance with the License.
9+
#
10+
# See LICENSE.txt included in this distribution for the specific
11+
# language governing permissions and limitations under the License.
12+
#
13+
# When distributing Covered Code, include this CDDL HEADER in each
14+
# file and include the License file at LICENSE.txt.
15+
# If applicable, add the following below this CDDL HEADER, with the
16+
# fields enclosed by brackets "[]" replaced with your own identifying
17+
# information: Portions Copyright [yyyy] [name of copyright owner]
18+
#
19+
# CDDL HEADER END
20+
#
21+
22+
#
23+
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
24+
#
25+
26+
import unittest
27+
28+
from parameterized import parameterized
29+
30+
from opengrok_tools.utils.command import Command
31+
32+
33+
class TestApp(unittest.TestCase):
34+
@parameterized.expand((
35+
('opengrok'),
36+
('opengrok-indexer'),
37+
('opengrok-groups'),
38+
('opengrok-config-merge'),
39+
('opengrok-deploy'),
40+
('opengrok-java'),
41+
('opengrok-mirror'),
42+
('opengrok-projadm'),
43+
('opengrok-reindex-project'),
44+
('opengrok-sync'),
45+
))
46+
def test_opengrok_binary(self, command):
47+
"""
48+
Test that installed command is able to run
49+
:param command: the command name
50+
:return:
51+
"""
52+
pass
53+
cmd = Command([command, '--help'])
54+
cmd.execute()
55+
self.assertEqual(0, cmd.getretcode())
56+
self.assertEqual(Command.FINISHED, cmd.getstate())
57+
self.assertTrue(len(cmd.getoutputstr()) > 1)
58+
59+
60+
if __name__ == '__main__':
61+
unittest.main()

0 commit comments

Comments
 (0)