def testInitialize(self):
        """Tests the __init__ function."""
        configuration_file = self._GetTestFilePath(['dependencies.ini'])
        dependency_helper = dependencies.DependencyHelper(
            configuration_file=configuration_file)
        self.assertIsNotNone(dependency_helper)

        with self.assertRaises(IOError):
            dependencies.DependencyHelper()
Exemple #2
0
  def testCheckTestDependencies(self):
    """Tests the CheckTestDependencies function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    dependency_helper.CheckTestDependencies(verbose_output=False)
    def testCheckSQLite3(self):
        """Tests the _CheckSQLite3 function."""
        configuration_file = self._GetTestFilePath(['dependencies.ini'])
        dependency_helper = dependencies.DependencyHelper(
            configuration_file=configuration_file)

        dependency_helper._CheckSQLite3()
def Main():
  """The main program function.

  Returns:
    bool: True if successful or False if not.
  """
  l2tdevtools_path = os.path.abspath(__file__)
  l2tdevtools_path = os.path.dirname(l2tdevtools_path)
  l2tdevtools_path = os.path.dirname(l2tdevtools_path)

  project_path = os.getcwd()
  projects_helper = project.ProjectHelper(project_path)

  project_file = '{0:s}.ini'.format(projects_helper.project_name)

  project_reader = project_config.ProjectDefinitionReader()
  with open(project_file, 'rb') as file_object:
    project_definition = project_reader.Read(file_object)

  helper = dependencies.DependencyHelper()

  for writer_class in (
      appveyor_yml.AppveyorYmlWriter, pylint_rc.PylintRcWriter,
      travis.TravisRunWithTimeoutScriptWriter,
      requirements_txt.RequirementsWriter, setup.SetupCfgWriter,
      setup.SetupPyWriter, tox_ini.ToxIniWriter,
      travis.TravisInstallScriptWriter, travis.TravisRunTestsScriptWriter,
      travis.TravisRunWithTimeoutScriptWriter, travis_yml.TravisYMLWriter):
    writer = writer_class(l2tdevtools_path, project_definition, helper)
    writer.Write()

  for writer_class in (
      dependencies_py.DependenciesPyWriter, dpkg.DPKGControlWriter,
      gift_copr.GIFTCOPRInstallScriptWriter,
      gift_ppa.GIFTPPAInstallScriptWriter,
      macos.MacOSInstallScriptWriter,
      macos.MacOSMakeDistScriptWriter, macos.MacOSUninstallScriptWriter):
    if not os.path.exists(writer_class.PATH):
      continue

    writer = writer_class(l2tdevtools_path, project_definition, helper)
    writer.Write()

  path = os.path.join(l2tdevtools_path, 'l2tdevtools', 'dependencies.py')
  file_data = []
  with open(path, 'rb') as file_object:
    for line in file_object.readlines():
      if 'GetDPKGDepends' in line:
        break

      file_data.append(line)

  file_data.pop()
  file_data = ''.join(file_data)

  path = os.path.join('utils', 'dependencies.py')
  with open(path, 'wb') as file_object:
    file_object.write(file_data)

  return True
Exemple #5
0
  def testGetL2TBinaries(self):
    """Tests the GetL2TBinaries function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    l2tbinaries = dependency_helper.GetL2TBinaries()
    self.assertEqual(len(l2tbinaries), 1)
Exemple #6
0
  def testGetPylintRcExtensionPkgs(self):
    """Tests the GetPylintRcExtensionPkgs function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    extension_packages = dependency_helper.GetPylintRcExtensionPkgs()
    self.assertEqual(len(extension_packages), 0)
Exemple #7
0
  def testGetRPMRequires(self):
    """Tests the GetRPMRequires function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    rpm_requires = dependency_helper.GetRPMRequires()
    self.assertEqual(len(rpm_requires), 1)
Exemple #8
0
  def testGetDPKGDepends(self):
    """Tests the GetDPKGDepends function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    dpkg_depends = dependency_helper.GetDPKGDepends()
    self.assertEqual(len(dpkg_depends), 1)
Exemple #9
0
  def testImportPythonModule(self):
    """Tests the _ImportPythonModule function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    module_object = dependency_helper._ImportPythonModule('os')
    self.assertIsNotNone(module_object)
Exemple #10
0
  def _CreateTestWriter(self):
    """Creates a dependency file writer for testing.

    Returns:
      GIFTPPAInstallScriptWriter: dependency file writer for testing.
    """
    project_definition = projects.ProjectDefinition('test')

    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    configuration_file = self._GetTestFilePath(['test_dependencies.ini'])
    test_dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    return gift_ppa.GIFTPPAInstallScriptWriter(
        '/fake/l2tdevtools/', project_definition, dependency_helper,
        test_dependency_helper)
Exemple #11
0
    def _CreateTestWriter(self):
        """Creates a dependency file writer for testing.

    Returns:
      TestRequirementsWriter: dependency file writer for testing.
    """
        project_definition = projects.ProjectDefinition('test')

        configuration_file = self._GetTestFilePath(['dependencies.ini'])
        dependency_helper = dependencies.DependencyHelper(
            configuration_file=configuration_file)

        configuration_file = self._GetTestFilePath(['test_dependencies.ini'])
        test_dependency_helper = dependencies.DependencyHelper(
            configuration_file=configuration_file)

        return requirements.TestRequirementsWriter('/fake/l2tdevtools/',
                                                   project_definition,
                                                   dependency_helper,
                                                   test_dependency_helper)
Exemple #12
0
  def testCheckPythonModuleVersion(self):
    """Tests the _CheckPythonModuleVersion function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    module_object = dependency_helper._ImportPythonModule('os')

    result, _ = dependency_helper._CheckPythonModuleVersion(
        'os', module_object, '__version__', '1.0', '2.0')
    self.assertFalse(result)
Exemple #13
0
    def testInitialize(self):
        """Tests the __init__ function."""
        l2tdevtools_path = '/fake/l2tdevtools/'
        project_definition = project.ProjectHelper(l2tdevtools_path)
        configuration_file = self._GetTestFilePath(['dependencies.ini'])
        dependency_helper = dependencies.DependencyHelper(
            configuration_file=configuration_file)

        writer = jenkins_scripts.RunPython3EndToEndTestsScriptWriter(
            l2tdevtools_path, project_definition, dependency_helper, None)
        self.assertIsNotNone(writer)
Exemple #14
0
    def testInitialize(self):
        """Tests that the writer can be initialized."""

        l2tdevtools_path = '/fake/l2tdevtools/'
        project_definition = project.ProjectHelper(l2tdevtools_path)
        configuration_file = self._GetTestFilePath(['dependencies.ini'])
        dependency_helper = dependencies.DependencyHelper(
            configuration_file=configuration_file)

        writer = dpkg.DPKGControlWriter(l2tdevtools_path, project_definition,
                                        dependency_helper, None)
        self.assertIsNotNone(writer)
Exemple #15
0
  def testInitialize(self):
    """Tests that the writer can be initialized."""

    l2tdevtools_path = '/fake/l2tdevtools/'
    project_definition = project.ProjectHelper(l2tdevtools_path)
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    writer = gift_ppa.GIFTPPAInstallScriptWriter(
        l2tdevtools_path, project_definition, dependency_helper)
    self.assertIsNotNone(writer)
Exemple #16
0
  def testCheckPythonModule(self):
    """Tests the _CheckPythonModule function."""
    configuration_file = self._GetTestFilePath(['dependencies.ini'])
    dependency_helper = dependencies.DependencyHelper(
        configuration_file=configuration_file)

    dependency = dependencies.DependencyDefinition('os')
    result, _ = dependency_helper._CheckPythonModule(dependency)
    self.assertTrue(result)

    dependency = dependencies.DependencyDefinition('bogus')
    result, _ = dependency_helper._CheckPythonModule(dependency)
    self.assertFalse(result)

if __name__ == '__main__':
  l2tdevtools_path = os.path.abspath(__file__)
  l2tdevtools_path = os.path.dirname(l2tdevtools_path)
  l2tdevtools_path = os.path.dirname(l2tdevtools_path)

  project_file = os.getcwd()
  project_file = os.path.basename(project_file)
  project_file = '{0:s}.ini'.format(project_file)

  project_reader = project_config.ProjectDefinitionReader()
  with open(project_file, 'rb') as file_object:
    project_definition = project_reader.Read(file_object)

  helper = dependencies.DependencyHelper()

  for writer_class in (
      AppveyorYmlWriter, RequirementsWriter, SetupCfgWriter,
      TravisBeforeInstallScriptWriter, ToxIniWriter):
    writer = writer_class(l2tdevtools_path, project_definition, helper)
    writer.Write()

  for writer_class in (
      DependenciesPyWriter, DPKGControlWriter, GIFTCOPRInstallScriptWriter,
      GIFTPPAInstallScriptWriter):
    if not os.path.exists(writer_class.PATH):
      continue

    writer = writer_class(l2tdevtools_path, project_definition, helper)
    writer.Write()
def Main():
    """The main program function.

  Returns:
    bool: True if successful or False if not.
  """
    l2tdevtools_path = os.path.abspath(__file__)
    l2tdevtools_path = os.path.dirname(l2tdevtools_path)
    l2tdevtools_path = os.path.dirname(l2tdevtools_path)

    project_path = os.getcwd()
    projects_helper = project.ProjectHelper(project_path)
    project_definition = projects_helper.ReadDefinitionFile()

    dependencies_helper = dependencies.DependencyHelper()

    test_dependencies_helper = None
    if os.path.exists('test_dependencies.ini'):
        test_dependencies_helper = dependencies.DependencyHelper(
            'test_dependencies.ini')

    for writer_class in (pylint_rc.PylintRcWriter,
                         travis.TravisRunWithTimeoutScriptWriter,
                         requirements.RequirementsWriter,
                         requirements.TestRequirementsWriter,
                         setup.SetupCfgWriter, setup.SetupPyWriter,
                         travis.TravisInstallScriptWriter,
                         travis.TravisRunPylintScriptWriter,
                         travis.TravisRunPython3ScriptWriter,
                         travis.TravisRunTestsScriptWriter,
                         travis.TravisRunWithTimeoutScriptWriter,
                         travis_yml.TravisYMLWriter):
        writer = writer_class(l2tdevtools_path, project_definition,
                              dependencies_helper, test_dependencies_helper)
        writer.Write()

    for writer_class in (appveyor_yml.AppveyorYmlWriter,
                         check_dependencies.CheckDependenciesWriter,
                         dependencies_py.DependenciesPyWriter,
                         dpkg.DPKGCompatWriter, dpkg.DPKGControlWriter,
                         dpkg.DPKGRulesWriter,
                         gift_copr.GIFTCOPRInstallScriptWriter,
                         gift_ppa.GIFTPPAInstallScriptPY3Writer,
                         jenkins_scripts.LinuxRunEndToEndTestsScriptWriter,
                         jenkins_scripts.RunPython3EndToEndTestsScriptWriter,
                         linux_scripts.UbuntuInstallationScriptWriter,
                         macos.MacOSInstallScriptWriter,
                         macos.MacOSMakeDistScriptWriter,
                         macos.MacOSUninstallScriptWriter,
                         tox_ini.ToxIniWriter):
        if not os.path.exists(writer_class.PATH):
            continue

        writer = writer_class(l2tdevtools_path, project_definition,
                              dependencies_helper, test_dependencies_helper)
        writer.Write()

    output_path = os.path.join('utils', 'dependencies.py')
    if os.path.exists(output_path):
        input_path = os.path.join(l2tdevtools_path, 'l2tdevtools',
                                  'dependencies.py')
        file_data = []
        with io.open(input_path, 'r', encoding='utf-8') as file_object:
            for line in file_object.readlines():
                if 'GetDPKGDepends' in line:
                    break

                file_data.append(line)

        file_data.pop()
        file_data = ''.join(file_data)

        with io.open(output_path, 'w', encoding='utf-8') as file_object:
            file_object.write(file_data)

    # Remove old scripts.
    script_path = os.path.join('config', 'linux', 'gift_ppa_install.sh')
    if os.path.isfile(script_path):
        os.remove(script_path)

    script_path = os.path.join('config', 'travis', 'run_coverage.sh')
    if os.path.isfile(script_path):
        os.remove(script_path)

    return True