Robot Framework Integrated Development Environment (RIDE)
jarrunner.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from org.robotframework import RobotPythonRunner
17 
18 from robotide.lib.robot.errors import INFO_PRINTED
19 from robotide.lib.robot.libdoc import libdoc_cli
20 from robotide.lib.robot.run import run_cli
21 from robotide.lib.robot.rebot import rebot_cli
22 from robotide.lib.robot.testdoc import testdoc_cli
23 from robotide.lib.robot.tidy import tidy_cli
24 
25 
26 USAGE = """robotframework.jar - Robot Framework runner.
27 
28 Usage: java -jar robotframework.jar [command] [options] [input(s)]
29 
30 Available commands:
31  run - Run Robot Framework tests. The default, if no command is given.
32  rebot - Post process Robot Framework output files.
33  libdoc - Create test library or resource file documentation.
34  tidy - Clean-up and changed format of test data files.
35  testdoc - Create documentation from Robot Framework test data files.
36 
37 Run `java -jar robotframework.jar command --help` for more information about
38 an individual command.
39 
40 Examples:
41  java -jar robotframework.jar mytests.robot
42  java -jar robotframework.jar run mytests.robot
43  java -jar robotframework.jar rebot --log mylog.html out.xml
44  java -jar robotframework.jar tidy --format robot mytests.html
45 """
46 
47 
48 
49 class JarRunner(RobotPythonRunner):
50 
53  _commands = {'run': run_cli, 'rebot': rebot_cli, 'tidy': tidy_cli,
54  'libdoc': libdoc_cli, 'testdoc': testdoc_cli}
55 
56  def run(self, args):
57  try:
58  self._run_run(args)
59  except SystemExit as err:
60  return err.code
61 
62  def _run(self, args):
63  if not args or args[0] in ('-h', '--help'):
64  print(USAGE)
65  raise SystemExit(INFO_PRINTED)
66  command, args = self._parse_command_line_parse_command_line(args)
67  command(args) # Always calls sys.exit()
68 
69  def _parse_command_line(self, args):
70  if args[0] in self._commands_commands:
71  return self._commands_commands[args[0]], args[1:]
72  return run_cli, args
Used for Java-Jython interop when RF is executed from .jar file.
Definition: jarrunner.py:49