Exemplo n.º 1
0
    def _prepare_test_binary_dir(self, test_binary_dir):

        # Remove binary directory
        subprocess.check_call(
            [config.CMAKE_COMMAND, '-E', 'remove_directory', test_binary_dir],
            cwd=config.CMAKE_CURRENT_BINARY_DIR,
            env=self.env)

        # Create binary directory
        os.mkdir(test_binary_dir)

        # Create directory
        extension_description_dir = test_binary_dir + '/TestIndex'
        os.mkdir(extension_description_dir)

        sys.path.append(config.Slicer_SOURCE_DIR + '/Utilities/Scripts')
        from SlicerWizard import ExtensionProject

        for suffix in ['A', 'B', 'C']:
            # Generate extension sources
            subprocess.check_call(
                [
                    sys.executable, config.Slicer_SOURCE_DIR +
                    '/Utilities/Scripts/ExtensionWizard.py', '--create',
                    'TestExt%s' % suffix, '--addModule',
                    'scripted:Mod%s' % suffix, test_binary_dir
                ],
                cwd=config.CMAKE_CURRENT_BINARY_DIR,
            )
            if suffix == 'B':
                project = ExtensionProject(test_binary_dir +
                                           '/TestExt%s' % suffix)
                project.setValue('EXTENSION_DEPENDS', 'TestExtA')
                project.save()
            if suffix == 'C':
                project = ExtensionProject(test_binary_dir +
                                           '/TestExt%s' % suffix)
                project.setValue('EXTENSION_DEPENDS', 'TestExtA TestExtB')
                project.save()

            # Generate extension description file
            description = subprocess.check_output(
                [
                    sys.executable,
                    config.Slicer_SOURCE_DIR +
                    '/Utilities/Scripts/ExtensionWizard.py',
                    '--localExtensionsDir=%s' % test_binary_dir,
                    '--describe',
                    test_binary_dir + '/TestExt%s' % suffix,
                ],
                cwd=config.CMAKE_CURRENT_BINARY_DIR,
            )
            with open(extension_description_dir + '/TestExt%s.s4ext' % suffix,
                      'w') as description_file:
                description_file.write(description)
  def _prepare_test_binary_dir(self, test_binary_dir):

    # Remove binary directory
    subprocess.check_call(
      [config.CMAKE_COMMAND, '-E', 'remove_directory', test_binary_dir],
      cwd=config.CMAKE_CURRENT_BINARY_DIR,
      env=self.env
    )

    # Create binary directory
    os.mkdir(test_binary_dir)

    # Create directory
    extension_description_dir = test_binary_dir + '/TestIndex'
    os.mkdir(extension_description_dir)

    sys.path.append(config.Slicer_SOURCE_DIR + '/Utilities/Scripts')
    from SlicerWizard import ExtensionProject

    for suffix in ['A', 'B', 'C']:
      # Generate extension sources
      subprocess.check_call(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--create', 'TestExt%s' % suffix,
        '--addModule', 'scripted:Mod%s' % suffix,
        test_binary_dir
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      if suffix == 'B':
        project = ExtensionProject(test_binary_dir + '/TestExt%s' % suffix)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA')
        project.save()
      if suffix == 'C':
        project = ExtensionProject(test_binary_dir + '/TestExt%s' % suffix)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA TestExtB')
        project.save()

      # Generate extension description file
      description = subprocess.check_output(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--localExtensionsDir=%s' % test_binary_dir,
        '--describe', test_binary_dir + '/TestExt%s' % suffix,
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      with open(extension_description_dir + '/TestExt%s.s4ext' % suffix, 'w') as description_file:
        description_file.write(description)
    def _prepare_test_binary_dir(self, test_binary_dir):

        # Remove binary directory
        subprocess.check_call(
            [config.CMAKE_COMMAND, '-E', 'remove_directory', test_binary_dir],
            cwd=config.CMAKE_CURRENT_BINARY_DIR,
            env=self.env)

        # Create binary directory
        os.mkdir(test_binary_dir)

        # Create directory
        extension_description_dir = test_binary_dir + '/TestIndex'
        os.mkdir(extension_description_dir)

        sys.path.append(config.Slicer_SOURCE_DIR + '/Utilities/Scripts')
        from SlicerWizard import ExtensionProject

        for suffix in ['A', 'B', 'C']:
            # Generate extension sources
            subprocess.check_call(
                [
                    sys.executable, config.Slicer_SOURCE_DIR +
                    '/Utilities/Scripts/ExtensionWizard.py', '--create',
                    'TestExt%s' % suffix, '--addModule',
                    'scripted:Mod%s' % suffix, test_binary_dir
                ],
                cwd=config.CMAKE_CURRENT_BINARY_DIR,
            )
            extension_dir = test_binary_dir + '/TestExt%s' % suffix

            if suffix == 'A':
                # Add a failing test to ExtensionA. This allows to check that
                # dependers of ExtensionsA can still configure/build/test without
                # any issues. See #4247
                module_dir = extension_dir + '/Mod%s' % suffix
                module_cmakelists = module_dir + '/Testing/Python/CMakeLists.txt'
                with open(module_cmakelists, 'a') as content:
                    content.write(
                        "add_test(NAME FailingTest COMMAND invalid_test)\n")

                display_error_script = module_dir + '/Testing/Python/slicerDisplayErrors.cmake'
                with open(display_error_script, 'w') as content:
                    content.write(
                        textwrap.dedent("""
          message("ERROR: In /path/to/Slicer/qSlicerCoreApplication.cxx, line 212
          vtkObject (0x25f2b30): This is an an error message from VTK")
          """))
                with open(module_cmakelists, 'a') as content:
                    content.write(
                        "add_test(NAME TestDisplayingError COMMAND ${CMAKE_COMMAND} -P \"%s\")\n"
                        % display_error_script)

            if suffix == 'B':
                project = ExtensionProject(extension_dir)
                project.setValue('EXTENSION_DEPENDS', 'TestExtA')
                project.save()

            if suffix == 'C':
                project = ExtensionProject(extension_dir)
                project.setValue('EXTENSION_DEPENDS', 'TestExtA TestExtB')
                project.save()

            # Generate extension description file
            description = subprocess.check_output(
                [
                    sys.executable,
                    config.Slicer_SOURCE_DIR +
                    '/Utilities/Scripts/ExtensionWizard.py',
                    '--localExtensionsDir=%s' % test_binary_dir,
                    '--describe',
                    extension_dir,
                ],
                cwd=config.CMAKE_CURRENT_BINARY_DIR,
            )
            with open(extension_description_dir + '/TestExt%s.s4ext' % suffix,
                      'w') as description_file:
                description_file.write(description)

            if suffix == 'A':
                #
                # Strip all optional metadata from Extension A. This allows to check
                # that the full process can effectively succeed without them.
                # See issue #4276
                #
                # Extension A is chosen because it has no dependency. This mean we
                # can even strip the DEPENDS option.
                #
                # Finally, note this is done after generating the description file
                # because the ExtensionWizard currently expects them to be set.
                #
                # The list of optional metadata has been copied from
                # SlicerExtensionDescriptionSpec.cmake CMake module.
                #
                patterns = [
                    'EXTENSION_' + pattern for pattern in [
                        'SVNUSERNAME', 'SVNPASSWORD', 'DEPENDS',
                        'BUILD_SUBDIRECTORY', 'HOMEPAGE', 'CONTRIBUTORS',
                        'CATEGORY', 'ICONURL', 'DESCRIPTION', 'SCREENSHOTURLS',
                        'ENABLED', 'STATUS'
                    ]
                ]
                self._remove_matching_lines(extension_dir + '/CMakeLists.txt',
                                            patterns)

        # Add extension description file with invalid repository
        description_file = extension_description_dir + '/TestExtInvalidSCM.s4ext'
        print("Writing %s" % description_file)
        with open(description_file, 'w') as description_file:
            description_file.write(
                textwrap.dedent("""
        scm git
        scmurl git://github.com/Slicer/ExtensionThatDoNotExists
        scmrevision abcdefg
        depends TestExtA TestExtB TestExtC
        """))
  def _prepare_test_binary_dir(self, test_binary_dir):

    # Remove binary directory
    subprocess.check_call(
      [config.CMAKE_COMMAND, '-E', 'remove_directory', test_binary_dir],
      cwd=config.CMAKE_CURRENT_BINARY_DIR,
      env=self.env
    )

    # Create binary directory
    os.mkdir(test_binary_dir)

    # Create directory
    extension_description_dir = test_binary_dir + '/TestIndex'
    os.mkdir(extension_description_dir)

    sys.path.append(config.Slicer_SOURCE_DIR + '/Utilities/Scripts')
    from SlicerWizard import ExtensionProject

    for suffix in ['A', 'B', 'C']:
      # Generate extension sources
      subprocess.check_call(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--create', 'TestExt%s' % suffix,
        '--addModule', 'scripted:Mod%s' % suffix,
        test_binary_dir
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      extension_dir = test_binary_dir + '/TestExt%s' % suffix

      if suffix == 'A':
        # Add a failing test to ExtensionA. This allows to check that
        # dependers of ExtensionsA can still configure/build/test without
        # any issues. See #4247
        module_dir = extension_dir + '/Mod%s' % suffix
        module_cmakelists = module_dir + '/Testing/Python/CMakeLists.txt'
        with open(module_cmakelists, 'a') as content:
          content.write("add_test(NAME FailingTest COMMAND invalid_test)\n")

        display_error_script = module_dir + '/Testing/Python/slicerDisplayErrors.cmake'
        with open(display_error_script, 'w') as content:
          content.write(textwrap.dedent("""
          message("ERROR: In /path/to/Slicer/qSlicerCoreApplication.cxx, line 212
          vtkObject (0x25f2b30): This is an an error message from VTK")
          """))
        with open(module_cmakelists, 'a') as content:
          content.write("add_test(NAME TestDisplayingError COMMAND ${CMAKE_COMMAND} -P \"%s\")\n" % display_error_script)

      if suffix == 'B':
        project = ExtensionProject(extension_dir)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA')
        project.save()

      if suffix == 'C':
        project = ExtensionProject(extension_dir)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA TestExtB')
        project.save()

      # Generate extension description file
      description = subprocess.check_output(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--localExtensionsDir=%s' % test_binary_dir,
        '--describe', extension_dir,
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      with open(extension_description_dir + '/TestExt%s.s4ext' % suffix, 'w') as description_file:
        description_file.write(description)

      if suffix == 'A':
        #
        # Strip all optional metadata from Extension A. This allows to check
        # that the full process can effectively succeed without them.
        # See issue #4276
        #
        # Extension A is chosen because it has no dependency. This mean we
        # can even strip the DEPENDS option.
        #
        # Finally, note this is done after generating the description file
        # because the ExtensionWizard currently expects them to be set.
        #
        # The list of optional metadata has been copied from
        # SlicerExtensionDescriptionSpec.cmake CMake module.
        #
        patterns = ['EXTENSION_' + pattern for pattern in [
          'SVNUSERNAME', 'SVNPASSWORD', 'DEPENDS', 'BUILD_SUBDIRECTORY',
          'HOMEPAGE', 'CONTRIBUTORS', 'CATEGORY', 'ICONURL',
          'DESCRIPTION', 'SCREENSHOTURLS', 'ENABLED', 'STATUS'
          ]]
        self._remove_matching_lines(extension_dir + '/CMakeLists.txt', patterns)

    # Add extension description file with invalid repository
    description_file = extension_description_dir + '/TestExtInvalidSCM.s4ext'
    print("Writing %s" % description_file)
    with open(description_file, 'w') as description_file:
      description_file.write(textwrap.dedent(
        """
        scm git
        scmurl git://github.com/Slicer/ExtensionThatDoNotExists
        scmrevision abcdefg
        depends TestExtA TestExtB TestExtC
        """))
  def _prepare_test_binary_dir(self, test_binary_dir):

    # Remove binary directory
    subprocess.check_call(
      [config.CMAKE_COMMAND, '-E', 'remove_directory', test_binary_dir],
      cwd=config.CMAKE_CURRENT_BINARY_DIR,
      env=self.env
    )

    # Create binary directory
    os.mkdir(test_binary_dir)

    # Create directory
    extension_description_dir = test_binary_dir + '/TestIndex'
    os.mkdir(extension_description_dir)

    sys.path.append(config.Slicer_SOURCE_DIR + '/Utilities/Scripts')
    from SlicerWizard import ExtensionProject

    for suffix in ['A', 'B', 'C']:
      # Generate extension sources
      subprocess.check_call(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--create', 'TestExt%s' % suffix,
        '--addModule', 'scripted:Mod%s' % suffix,
        test_binary_dir
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      extension_dir = test_binary_dir + '/TestExt%s' % suffix

      if suffix == 'A':
        # Add a failing test to ExtensionA. This allows to check that
        # dependers of ExtensionsA can still configure/build/test without
        # any issues. See #4247
        module_dir = extension_dir + '/Mod%s' % suffix
        with open(module_dir + '/Testing/Python/CMakeLists.txt', 'a') as content:
          content.write("add_test(NAME FailingTest COMMAND invalid_test)")

      if suffix == 'B':
        project = ExtensionProject(extension_dir)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA')
        project.save()

      if suffix == 'C':
        project = ExtensionProject(extension_dir)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA TestExtB')
        project.save()

      # Generate extension description file
      description = subprocess.check_output(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--localExtensionsDir=%s' % test_binary_dir,
        '--describe', extension_dir,
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      with open(extension_description_dir + '/TestExt%s.s4ext' % suffix, 'w') as description_file:
        description_file.write(description)

      if suffix == 'A':
        #
        # Strip all optional metadata from Extension A. This allows to check
        # that the full process can effectively succeed without them.
        # See issue #4276
        #
        # Extension A is chosen because it has no dependency. This mean we
        # can even strip the DEPENDS option.
        #
        # Finally, note this is done after generating the description file
        # because the ExtensionWizard currently expects them to be set.
        #
        # The list of optional metadata has been copied from
        # SlicerExtensionDescriptionSpec.cmake CMake module.
        #
        patterns = ['EXTENSION_' + pattern for pattern in [
          'SVNUSERNAME', 'SVNPASSWORD', 'DEPENDS', 'BUILD_SUBDIRECTORY',
          'HOMEPAGE', 'CONTRIBUTORS', 'CATEGORY', 'ICONURL',
          'DESCRIPTION', 'SCREENSHOTURLS', 'ENABLED', 'STATUS'
          ]]
        self._remove_matching_lines(extension_dir + '/CMakeLists.txt', patterns)
Exemplo n.º 6
0
  def _prepare_test_binary_dir(self, test_binary_dir):

    # Remove binary directory
    subprocess.check_call(
      [config.CMAKE_COMMAND, '-E', 'remove_directory', test_binary_dir],
      cwd=config.CMAKE_CURRENT_BINARY_DIR,
      env=self.env
    )

    # Create binary directory
    os.mkdir(test_binary_dir)

    # Create directory
    extension_description_dir = test_binary_dir + '/TestIndex'
    os.mkdir(extension_description_dir)

    sys.path.append(config.Slicer_SOURCE_DIR + '/Utilities/Scripts')
    from SlicerWizard import ExtensionProject

    for suffix in ['A', 'B', 'C']:
      # Generate extension sources
      subprocess.check_call(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--create', 'TestExt%s' % suffix,
        '--addModule', 'scripted:Mod%s' % suffix,
        test_binary_dir
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      extension_dir = test_binary_dir + '/TestExt%s' % suffix

      if suffix == 'A':
        # Add a failing test to ExtensionA. This allows to check that
        # dependers of ExtensionsA can still configure/build/test without
        # any issues. See #4247
        module_dir = extension_dir + '/Mod%s' % suffix
        with open(module_dir + '/Testing/Python/CMakeLists.txt', 'a') as content:
          content.write("add_test(NAME FailingTest COMMAND invalid_test)")

      if suffix == 'B':
        project = ExtensionProject(extension_dir)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA')
        project.save()

      if suffix == 'C':
        project = ExtensionProject(extension_dir)
        project.setValue('EXTENSION_DEPENDS', 'TestExtA TestExtB')
        project.save()

      # Generate extension description file
      description = subprocess.check_output(
        [sys.executable,
        config.Slicer_SOURCE_DIR + '/Utilities/Scripts/ExtensionWizard.py',
        '--localExtensionsDir=%s' % test_binary_dir,
        '--describe', extension_dir,
        ],
        cwd=config.CMAKE_CURRENT_BINARY_DIR,
        )
      with open(extension_description_dir + '/TestExt%s.s4ext' % suffix, 'w') as description_file:
        description_file.write(description)

      if suffix == 'A':
        #
        # Strip all optional metadata from Extension A. This allows to check
        # that the full process can effectively succeed without them.
        # See issue #4276
        #
        # Extension A is chosen because it has no dependency. This mean we
        # can even strip the DEPENDS option.
        #
        # Finally, note this is done after generating the description file
        # because the ExtensionWizard currently expects them to be set.
        #
        # The list of optional metadata has been copied from
        # SlicerExtensionDescriptionSpec.cmake CMake module.
        #
        patterns = ['EXTENSION_' + pattern for pattern in [
          'SVNUSERNAME', 'SVNPASSWORD', 'DEPENDS', 'BUILD_SUBDIRECTORY',
          'HOMEPAGE', 'CONTRIBUTORS', 'CATEGORY', 'ICONURL',
          'DESCRIPTION', 'SCREENSHOTURLS', 'ENABLED', 'STATUS'
          ]]
        self._remove_matching_lines(extension_dir + '/CMakeLists.txt', patterns)