Exemple #1
0
    def test_install(self):
        # Fail (on purpose) if not given exactly one command line argument.
        self.assertEqual(len(sys.argv), 2)
        with open(sys.argv[1], 'r') as f:
            lines = f.readlines()

        # Install into bazel read-only temporary directory. The temporary
        # directory does not need to be removed as bazel tests are run in a
        # scratch space.
        install_test_helper.install()
        installation_folder = install_test_helper.get_install_dir()
        self.assertTrue(os.path.isdir(installation_folder))

        # Verify install directory content.
        content = set(os.listdir(installation_folder))
        self.assertSetEqual(set(['bin', 'include', 'lib', 'share']), content)

        # Our launched processes should be independent, not inherit their
        # runfiles from the install_test.py runner.
        cmd_env = dict(os.environ)
        for key in ["RUNFILES_MANIFEST_FILE", "RUNFILES_DIR", "TEST_SRCDIR"]:
            if key in cmd_env:
                del cmd_env[key]

        # Execute the install actions.
        for cmd in lines:
            cmd = cmd.strip()
            print("+ {}".format(cmd))
            install_test_helper.check_call(
                [os.path.join(os.getcwd(), cmd)],
                env=cmd_env)
Exemple #2
0
 def setUpClass(cls):
     # Install into bazel read-only temporary directory.  We expect this
     # method to be called exactly once, so we assert that the install
     # directory must not exist beforehand, but must exist afterward.
     cls._installation_folder = install_test_helper.get_install_dir()
     assert not os.path.exists(cls._installation_folder)
     install_test_helper.install()
     assert os.path.isdir(cls._installation_folder)
Exemple #3
0
 def testInstall(self):
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder,
                                          ['bin', 'lib', 'share'])
     self.assertEqual(None, result)
     executable_folder = os.path.join(tmp_folder, "bin")
     subprocess.check_call([os.path.join(executable_folder, "lcm-gen")])
Exemple #4
0
 def testDrakeFindResourceOrThrowInInstall(self):
     # Install into a temporary directory. The temporary directory does not
     # need to be removed as bazel tests are run in a scratch space.
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder, ['lib', 'share'])
     self.assertEqual(None, result)
     # Set the correct PYTHONPATH to use the correct pydrake module.
     env_python_path = "PYTHONPATH"
     tool_env = dict(os.environ)
     tool_env[env_python_path] = os.path.abspath(
         os.path.join(tmp_folder, "lib", "python2.7", "site-packages"))
     data_folder = os.path.join(tmp_folder, "share", "drake", "drake")
     # Call python2 to force using python brew install. Calling python
     # system would result in a crash since pydrake was built against
     # brew python. On Linux this will still work and force using
     # python2 which should be a link to the actual executable.
     # Calling `pydrake.getDrakePath()` twice verifies that there
     # is no memory allocation issue in the C code.
     output_path = subprocess.check_output(
         [
             "python2", "-c",
             "import pydrake; print(pydrake.getDrakePath());\
          import pydrake; print(pydrake.getDrakePath())"
         ],
         env=tool_env,
     ).strip()
     found_install_path = (data_folder in output_path)
     self.assertEqual(found_install_path, True)
 def testDrakeFindResourceOrThrowInInstall(self):
     # Install into a temporary directory. The temporary directory does not
     # need to be removed as bazel tests are run in a scratch space.
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder, ['lib', 'share'])
     self.assertEqual(None, result)
     # Override PYTHONPATH to only use the installed `pydrake` module.
     env_python_path = "PYTHONPATH"
     tool_env = dict(os.environ)
     tool_env[env_python_path] = os.path.abspath(
         os.path.join(tmp_folder, "lib", "python2.7", "site-packages"))
     data_folder = os.path.join(tmp_folder, "share", "drake")
     # Call the same Python binary. On Mac, calling the system `python`
     # would result in a crash since pydrake was built against brew python.
     # On Linux, this will still work and force using
     # python2 which should be a link to the actual executable.
     # Calling `pydrake.getDrakePath()` twice verifies that there
     # is no memory allocation issue in the C code.
     output_path = subprocess.check_output(
         [
             sys.executable, "-c",
             "import pydrake; print(pydrake.getDrakePath());\
          import pydrake; print(pydrake.getDrakePath())"
         ],
         cwd='/',  # Defeat the "search in parent folders" heuristic.
         env=tool_env,
     ).strip()
     found_install_path = (data_folder in output_path)
     self.assertEqual(found_install_path, True)
 def testDrakeFindResourceOrThrowInInstall(self):
     # Install into a temporary directory. The temporary directory does not
     # need to be removed as bazel tests are run in a scratch space.
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder, ['lib', 'share'])
     self.assertEqual(None, result)
     # Override PYTHONPATH to only use the installed `pydrake` module.
     env_python_path = "PYTHONPATH"
     tool_env = dict(os.environ)
     tool_env[env_python_path] = os.path.abspath(
         os.path.join(tmp_folder, "lib", "python2.7", "site-packages")
     )
     data_folder = os.path.join(tmp_folder, "share", "drake")
     # Call the same Python binary. On Mac, calling the system `python`
     # would result in a crash since pydrake was built against brew python.
     # On Linux, this will still work and force using
     # python2 which should be a link to the actual executable.
     # Calling `pydrake.getDrakePath()` twice verifies that there
     # is no memory allocation issue in the C code.
     output_path = subprocess.check_output(
         [sys.executable,
          "-c", "import pydrake; print(pydrake.getDrakePath());\
          import pydrake; print(pydrake.getDrakePath())"
          ],
         cwd='/',  # Defeat the "search in parent folders" heuristic.
         env=tool_env,
         ).strip()
     found_install_path = (data_folder in output_path)
     self.assertEqual(found_install_path, True)
Exemple #7
0
 def test_install(self):
     # Install into a temporary directory.
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder, ['lib'])
     self.assertEqual(None, result)
     # Override PYTHONPATH to only use the installed `pydrake` module.
     env_python_path = "PYTHONPATH"
     tool_env = dict(os.environ)
     tool_env[env_python_path] = os.path.abspath(
         os.path.join(tmp_folder, "lib", "python2.7", "site-packages"))
     # Ensure we can import all user-visible modules.
     script = "import pydrake.all"
     subprocess.check_call([sys.executable, "-c", script], env=tool_env)
Exemple #8
0
    def test_install(self):
        # Fail (on purpose) if not given exactly one command line argument.
        self.assertEqual(len(sys.argv), 2)
        with open(sys.argv[1], 'r') as f:
            lines = f.readlines()

        # Install into bazel read-only temporary directory. The temporary
        # directory does not need to be removed as bazel tests are run in a
        # scratch space.
        install_test_helper.install()
        installation_folder = install_test_helper.get_install_dir()
        self.assertTrue(os.path.isdir(installation_folder))

        # Verify install directory content.
        content = set(os.listdir(installation_folder))
        self.assertSetEqual(set(['bin', 'include', 'lib', 'share']), content)

        # Execute the install actions.
        for cmd in lines:
            cmd = cmd.strip()
            print("+ {}".format(cmd))
            install_test_helper.check_call([os.path.join(os.getcwd(), cmd)])
Exemple #9
0
 def test_install(self):
     # Install into a temporary directory.
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder, ['lib'])
     self.assertEqual(None, result)
     # Override PYTHONPATH to only use the installed `pydrake` module.
     env_python_path = "PYTHONPATH"
     tool_env = dict(os.environ)
     tool_env[env_python_path] = os.path.abspath(
         os.path.join(tmp_folder, "lib", "python2.7", "site-packages")
     )
     # Ensure we can import all user-visible modules.
     script = "import pydrake.all"
     subprocess.check_call([sys.executable, "-c", script], env=tool_env)
Exemple #10
0
    def test(self):
        # Install into the tmpdir that Bazel has created for us.
        tmpdir = os.environ["TEST_TMPDIR"]
        self.assertTrue(os.path.exists(tmpdir))
        install_dir = os.path.join(tmpdir, "install")
        result = install_test_helper.install(install_dir, rmdir_cwd=False)
        self.assertEqual(None, result)

        # Make sure the simulation can run without error.  We set cwd="/" to
        # defeat the "search in parent folders" heuristic, so that the "use
        # libdrake.so relative paths" must be successful.
        simulation = os.path.join(
            install_dir, "share/drake/examples/kuka_iiwa_arm/kuka_simulation")
        self.assertTrue(os.path.exists(simulation), "Can't find " + simulation)
        subprocess.check_call([simulation, "--simulation_sec=0.01"], cwd="/")
    def test(self):
        # Install into the tmpdir that Bazel has created for us.
        tmpdir = os.environ["TEST_TMPDIR"]
        self.assertTrue(os.path.exists(tmpdir))
        install_dir = os.path.join(tmpdir, "install")
        result = install_test_helper.install(install_dir, rmdir_cwd=False)
        self.assertEqual(None, result)

        # Make sure the simulation can run without error.  We set cwd="/" to
        # defeat the "search in parent folders" heuristic, so that the "use
        # libdrake.so relative paths" must be successful.
        simulation = os.path.join(
            install_dir,
            "share/drake/examples/kuka_iiwa_arm/kuka_simulation")
        self.assertTrue(os.path.exists(simulation), "Can't find " + simulation)
        subprocess.check_call([simulation, "--simulation_sec=0.01"], cwd="/")
 def testInstall(self):
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder,
                                          ['bin', 'lib', 'share'])
     self.assertEqual(None, result)
     executable_folder = os.path.join(tmp_folder, "bin")
     try:
         subprocess.check_output(
             [os.path.join(executable_folder, "drake-lcm-spy"), "--help"],
             stderr=subprocess.STDOUT)
         # If the process doesn't fail, we cannot test the string
         # returned in the exception output. Since this should not
         # happen, we fail here. If lcm is updated to return 0 when
         # "--help" is called, this test will fail and will need to be
         # updated.
         self.fail(
             "drake-lcm-spy execution passed instead of failing. Update test"  # noqa
         )
     except subprocess.CalledProcessError as e:
         self.assertIn("usage: lcm-spy [options]", e.output)
 def testInstall(self):
     tmp_folder = "tmp"
     result = install_test_helper.install(tmp_folder,
                                          ['bin', 'lib', 'share'])
     self.assertEqual(None, result)
     executable_folder = os.path.join(tmp_folder, "bin")
     try:
         subprocess.check_output(
             [os.path.join(executable_folder, "drake-lcm-spy"), "--help"],
             stderr=subprocess.STDOUT
             )
         # If the process doesn't fail, we cannot test the string
         # returned in the exception output. Since this should not
         # happen, we fail here. If lcm is updated to return 0 when
         # "--help" is called, this test will fail and will need to be
         # updated.
         self.fail(
             "drake-lcm-spy execution passed instead of failing. Update test"  # noqa
             )
     except subprocess.CalledProcessError as e:
         self.assertIn("usage: lcm-spy [options]", e.output)
Exemple #14
0
import os
import sys
import install_test_helper

# Install into bazel read-only temporary directory. The temporary
# directory does not need to be removed as bazel tests are run in a
# scratch space.
install_test_helper.install()
installation_folder = install_test_helper.get_install_dir()
assert os.path.isdir(installation_folder)
# Verify install directory content.
content = os.listdir(installation_folder)
assert set(['bin', 'include', 'lib', 'share']) == set(content)
# Will fail (on purpose) if not exactly one command line argument given.
assert len(sys.argv) == 2

with open(sys.argv[1], "r") as f:
    lines = f.readlines()

# Execute the install actions.
for cmd in lines:
    cmd = cmd.strip()
    install_test_helper.check_call(os.path.join(os.getcwd(), cmd))