コード例 #1
0
    def test_jooq_codegen(self):
        squarepants_java = 'squarepants/src/test/java'
        jooq_package = 'com.squareup.squarepants.integration.jooq'
        jooq_path = os.path.join(squarepants_java,
                                 jooq_package.replace('.', '/'))
        spot_check = [
            '{package}.{name}'.format(package=jooq_package, name=name)
            for name in ('model.Tables', 'model.tables.People',
                         'model.tables.Places')
        ]

        jooq_model_directory = os.path.join('squarepants', 'src', 'test',
                                            'java', 'com', 'squareup',
                                            'squarepants', 'integration',
                                            'jooq', 'model')
        shutil.rmtree(jooq_model_directory, ignore_errors=True)

        def check_classes(should_exist):
            for class_name in spot_check:
                path = '{}.java'.format(
                    os.path.join(squarepants_java,
                                 class_name.replace('.', '/')))
                self.assertEquals(should_exist, os.path.exists(path))
            if not should_exist:
                # No need to spin up jvm just to check to see if classes *don't* exist.
                return
            run = self.pants('run', '{}:bin'.format(jooq_path))
            self.assert_success(run)
            existence = {}
            for line in run.split('\n'):
                if line and '\t' in line:
                    key, val = line.split('\t')
                    existence[key] = val
            for class_name in spot_check:
                self.assertEquals(existence[class_name], 'present')

        check_classes(False)

        with frozen_dir(jooq_path):
            # jOOQ is awkward because it generates code to the normal source folders, which is then
            # checked in. So we do this in a frozen_dir context to clean up after it.
            self.assert_success(self.pants('jooq', jooq_path))
            check_classes(True)

        check_classes(False)
コード例 #2
0
  def test_jooq_codegen(self):
    squarepants_java = 'squarepants/src/test/java'
    jooq_package = 'com.squareup.squarepants.integration.jooq'
    jooq_path = os.path.join(squarepants_java, jooq_package.replace('.', '/'))
    spot_check = ['{package}.{name}'.format(package=jooq_package, name=name)
                  for name in ('model.Tables', 'model.tables.People', 'model.tables.Places')]

    jooq_model_directory = os.path.join('squarepants', 'src', 'test', 'java', 'com', 'squareup',
                                        'squarepants', 'integration', 'jooq', 'model')
    shutil.rmtree(jooq_model_directory, ignore_errors=True)

    def check_classes(should_exist):
      for class_name in spot_check:
        path = '{}.java'.format(os.path.join(squarepants_java, class_name.replace('.', '/')))
        self.assertEquals(should_exist, os.path.exists(path))
      if not should_exist:
        # No need to spin up jvm just to check to see if classes *don't* exist.
        return
      run = self.pants('run', '{}:bin'.format(jooq_path))
      self.assert_success(run)
      existence = {}
      for line in run.split('\n'):
        if line and '\t' in line:
          key, val = line.split('\t')
          existence[key] = val
      for class_name in spot_check:
        self.assertEquals(existence[class_name], 'present')

    check_classes(False)

    with frozen_dir(jooq_path):
      # jOOQ is awkward because it generates code to the normal source folders, which is then
      # checked in. So we do this in a frozen_dir context to clean up after it.
      self.assert_success(self.pants('jooq', jooq_path))
      check_classes(True)

    check_classes(False)
コード例 #3
0
 def _generated_module(self, module):
   with frozen_dir(module):
     with self._rename_test_builds(module):
       PomToBuild().convert_pom(os.path.join(module, 'pom.xml'))
       yield module
コード例 #4
0
 def _generated_module(self, module):
     with frozen_dir(module):
         with self._rename_test_builds(module):
             PomToBuild().convert_pom(os.path.join(module, 'pom.xml'))
             yield module