예제 #1
0
  def test_missing_sk_user_config(self):
    tmp = tempfile.mkdtemp()
    original = os.path.join(tmp, MISSING_FILENAME)
    assert not os.path.exists(original)


    # With require_sk_user_config set to True, an AssertionError will be
    # thrown when original_sk_user_config is missing.
    with self.assertRaises(AssertionError):
      ordered_set = [ 'define' ]
      gen_config(original_sk_user_config=original,
                 require_sk_user_config=True,
                 target_dir=tmp, ordered_set=ordered_set)

    # With require_sk_user_config set to False, it is okay for
    # original_sk_user_config to be missing.
    generate_dummy_user_config(original_sk_user_config=original,
                               require_sk_user_config=False, target_dir=tmp)
    actual_name = os.path.join(tmp, MISSING_FILENAME)
    utils.compare_to_expectation(actual_name=actual_name,
                                 expectation_name=MISSING_FILENAME,
                                 assert_true=self.assertTrue,
                                 msg=REBASELINE_MSG)

    shutil.rmtree(tmp)
예제 #2
0
  def test_include_static_deps_writer(self):
    outdir = tempfile.mkdtemp()
    generate_dummy_static_deps_makefile(outdir)

    filename = test_variables.STATIC_DEPS_MK
    utils.compare_to_expectation(os.path.join(outdir, filename),
                                 filename, self.assertTrue, REBASELINE_MSG)
예제 #3
0
    def test_missing_sk_user_config(self):
        tmp = tempfile.mkdtemp()
        original = os.path.join(tmp, MISSING_FILENAME)
        assert not os.path.exists(original)

        # With require_sk_user_config set to True, an AssertionError will be
        # thrown when original_sk_user_config is missing.
        with self.assertRaises(AssertionError):
            ordered_set = ['define']
            gen_config(original_sk_user_config=original,
                       require_sk_user_config=True,
                       target_dir=tmp,
                       ordered_set=ordered_set)

        # With require_sk_user_config set to False, it is okay for
        # original_sk_user_config to be missing.
        generate_dummy_user_config(original_sk_user_config=original,
                                   require_sk_user_config=False,
                                   target_dir=tmp)
        actual_name = os.path.join(tmp, MISSING_FILENAME)
        utils.compare_to_expectation(actual_name=actual_name,
                                     expectation_name=MISSING_FILENAME,
                                     assert_true=self.assertTrue,
                                     msg=REBASELINE_MSG)

        shutil.rmtree(tmp)
예제 #4
0
    def test_include_static_deps_writer(self):
        outdir = tempfile.mkdtemp()
        generate_dummy_static_deps_makefile(outdir)

        filename = test_variables.STATIC_DEPS_MK
        utils.compare_to_expectation(os.path.join(outdir, filename), filename,
                                     self.assertTrue, REBASELINE_MSG)
예제 #5
0
  def test_write_android_mk(self):
    outdir = tempfile.mkdtemp()
    generate_dummy_makefile(outdir)

    utils.compare_to_expectation(os.path.join(outdir, MAKEFILE_NAME),
                                 MAKEFILE_NAME, self.assertTrue, REBASELINE_MSG)

    shutil.rmtree(outdir)
예제 #6
0
 def test_gen_config(self):
   tmp = tempfile.mkdtemp()
   generate_dummy_user_config(FULL_DUMMY_PATH, True, tmp)
   actual_name = os.path.join(tmp, USER_CONFIG_NAME)
   utils.compare_to_expectation(actual_name=actual_name,
                       expectation_name=USER_CONFIG_NAME,
                       assert_true=self.assertTrue, msg=REBASELINE_MSG)
   shutil.rmtree(tmp)
예제 #7
0
  def test_tool_writer(self):
    outdir = tempfile.mkdtemp()
    tool_dir = os.path.join(outdir, TOOL_DIR)
    os.mkdir(tool_dir)
    generate_dummy_tool_makefile(tool_dir)

    utils.compare_to_expectation(os.path.join(tool_dir, MAKEFILE_NAME),
                                 os.path.join(TOOL_DIR, MAKEFILE_NAME),
                                 self.assertTrue, REBASELINE_MSG)
    def test_tool_writer(self):
        outdir = tempfile.mkdtemp()
        tool_dir = os.path.join(outdir, TOOL_DIR)
        os.mkdir(tool_dir)
        generate_dummy_tool_makefile(tool_dir)

        utils.compare_to_expectation(os.path.join(tool_dir, MAKEFILE_NAME),
                                     os.path.join(TOOL_DIR, MAKEFILE_NAME),
                                     self.assertTrue, REBASELINE_MSG)
    def test_write_android_mk(self):
        outdir = tempfile.mkdtemp()
        generate_dummy_makefile(outdir)

        utils.compare_to_expectation(os.path.join(outdir, MAKEFILE_NAME),
                                     MAKEFILE_NAME, self.assertTrue,
                                     REBASELINE_MSG)

        shutil.rmtree(outdir)
예제 #10
0
 def test_gen_config(self):
     tmp = tempfile.mkdtemp()
     generate_dummy_user_config(FULL_DUMMY_PATH, True, tmp)
     actual_name = os.path.join(tmp, USER_CONFIG_NAME)
     utils.compare_to_expectation(actual_name=actual_name,
                                  expectation_name=USER_CONFIG_NAME,
                                  assert_true=self.assertTrue,
                                  msg=REBASELINE_MSG)
     shutil.rmtree(tmp)
예제 #11
0
  def test_write_group(self):
    animals = ('dog', 'cat', 'mouse', 'elephant')
    fd, filename = tempfile.mkstemp()
    with open(filename, 'w') as f:
      makefile_writer.write_group(f, 'animals', animals, False)
    os.close(fd)
    # Now confirm that it matches expectations
    utils.compare_to_expectation(filename, 'animals.txt', self.assertTrue)

    with open(filename, 'w') as f:
      makefile_writer.write_group(f, 'animals_append', animals, True)
    # Now confirm that it matches expectations
    utils.compare_to_expectation(filename, 'animals_append.txt',
                                 self.assertTrue)
    os.remove(filename)
예제 #12
0
    def test_write_group(self):
        animals = ('dog', 'cat', 'mouse', 'elephant')
        fd, filename = tempfile.mkstemp()
        with open(filename, 'w') as f:
            makefile_writer.write_group(f, 'animals', animals, False)
        os.close(fd)
        # Now confirm that it matches expectations
        utils.compare_to_expectation(filename, 'animals.txt', self.assertTrue)

        with open(filename, 'w') as f:
            makefile_writer.write_group(f, 'animals_append', animals, True)
        # Now confirm that it matches expectations
        utils.compare_to_expectation(filename, 'animals_append.txt',
                                     self.assertTrue)
        os.remove(filename)
예제 #13
0
  def test_write_local_vars(self):
    vars_dict = generate_dummy_vars_dict(None)
    # Compare various ways of calling write_local_vars to expectations.
    for (filename, append, name) in generate_write_local_vars_params():
      fd, outfile = tempfile.mkstemp()
      with open(outfile, 'w') as f:
        makefile_writer.write_local_vars(f, vars_dict, append, name)
      os.close(fd)

      # Compare to the expected file.
      utils.compare_to_expectation(outfile, filename, self.assertTrue,
                                   REBASELINE_MSG)

      # KNOWN_TARGETS is always a key in the input VarsDict, but it should not
      # be written to the resulting file.
      # Note that this assumes none of our dummy entries is 'KNOWN_TARGETS'.
      known_targets_name = 'KNOWN_TARGETS'
      self.assertEqual(len(vars_dict[known_targets_name]), 1)

      with open(outfile, 'r') as f:
        self.assertNotIn(known_targets_name, f.read())
      os.remove(outfile)
예제 #14
0
    def test_write_local_vars(self):
        vars_dict = generate_dummy_vars_dict(None)
        # Compare various ways of calling write_local_vars to expectations.
        for (filename, append, name) in generate_write_local_vars_params():
            fd, outfile = tempfile.mkstemp()
            with open(outfile, 'w') as f:
                makefile_writer.write_local_vars(f, vars_dict, append, name)
            os.close(fd)

            # Compare to the expected file.
            utils.compare_to_expectation(outfile, filename, self.assertTrue,
                                         REBASELINE_MSG)

            # KNOWN_TARGETS is always a key in the input VarsDict, but it should not
            # be written to the resulting file.
            # Note that this assumes none of our dummy entries is 'KNOWN_TARGETS'.
            known_targets_name = 'KNOWN_TARGETS'
            self.assertEqual(len(vars_dict[known_targets_name]), 1)

            with open(outfile, 'r') as f:
                self.assertNotIn(known_targets_name, f.read())
            os.remove(outfile)