# Path: tests/utils.py
# def catkin_success(args, env={}):
#     orig_environ = dict(os.environ)
#     try:
#         os.environ.update(env)
#         catkin_main(args)
#     except SystemExit as exc:
#         ret = exc.code
#         if ret != 0:
#             import traceback
#             traceback.print_exc()
#     finally:
#         os.environ = orig_environ
#     return ret == 0
# 
# Path: tests/system/workspace_factory.py
# class workspace_factory(temporary_directory):
# 
#     def __init__(self, source_space='src', prefix=''):
#         super(workspace_factory, self).__init__(prefix=prefix)
#         self.source_space = source_space
# 
#     def __enter__(self):
#         self.temporary_directory = super(workspace_factory, self).__enter__()
#         self.workspace_factory = WorkspaceFactory(self.temporary_directory, self.source_space)
#         return self.workspace_factory
# 
#     def __exit__(self, exc_type, exc_value, traceback):
#         super(workspace_factory, self).__exit__(exc_type, exc_value, traceback)


import os
from ....utils import catkin_success
from ...workspace_factory import workspace_factory




def test_catkin_build_with_whitespace_in_paths():
    with workspace_factory(source_space='source packages') as wf:
        wf.create_package('foo', depends=['bar'])
        wf.create_package('bar')
        wf.build()

        print('Workspace: {0}'.format(wf.workspace))

        assert os.path.isdir(wf.workspace)

        cmd = ['config', '--source-space', wf.source_space,
               '--devel-space', 'devel space',
               '--build-space', 'build space',
               '--install-space', 'install space']
        assert catkin_success(cmd), cmd

        cmd = ['build', '--no-status', '--no-notify', '--verbose']

# Path: tests/utils.py
# def catkin_success(args, env={}):
#     orig_environ = dict(os.environ)
#     try:
#         os.environ.update(env)
#         catkin_main(args)
#     except SystemExit as exc:
#         ret = exc.code
#         if ret != 0:
#             import traceback
#             traceback.print_exc()
#     finally:
#         os.environ = orig_environ
#     return ret == 0
# 
# Path: tests/system/workspace_factory.py
# class workspace_factory(temporary_directory):
# 
#     def __init__(self, source_space='src', prefix=''):
#         super(workspace_factory, self).__init__(prefix=prefix)
#         self.source_space = source_space
# 
#     def __enter__(self):
#         self.temporary_directory = super(workspace_factory, self).__enter__()
#         self.workspace_factory = WorkspaceFactory(self.temporary_directory, self.source_space)
#         return self.workspace_factory
# 
#     def __exit__(self, exc_type, exc_value, traceback):
#         super(workspace_factory, self).__exit__(exc_type, exc_value, traceback)


# Path: tests/system/verbs/catkin_build/test_whitespace_in_paths.py
import os
from ....utils import catkin_success
from ...workspace_factory import workspace_factory





def test_catkin_build_with_whitespace_in_paths():
    with workspace_factory(source_space='source packages') as wf:
        wf.create_package('foo', depends=['bar'])
        wf.create_package('bar')
        wf.build()

        print('Workspace: {0}'.format(wf.workspace))

        assert os.path.isdir(wf.workspace)

        cmd = ['config', '--source-space', wf.source_space,
               '--devel-space', 'devel space',
               '--build-space', 'build space',
               '--install-space', 'install space']
        assert catkin_success(cmd), cmd

        cmd = ['build', '--no-status', '--no-notify', '--verbose']

        assert catkin_success(cmd), cmd