Esempio n. 1
0
 def test_fetch(self):
   """Tests fetch() of GM results from actual-results.json ."""
   downloader = download_actuals.Download(
       actuals_base_url=download_actuals.create_filepath_url(
           os.path.join(self._input_dir, 'gm-actuals')),
       gm_actuals_root_url=download_actuals.create_filepath_url(
           os.path.join(self._input_dir, 'fake-gm-imagefiles')))
   downloader.fetch(
       builder_name='Test-Android-GalaxyNexus-SGX540-Arm7-Release',
       dest_dir=self._output_dir_actual)
Esempio n. 2
0
 def test_fetch(self):
     """Tests fetch() of GM results from actual-results.json ."""
     downloader = download_actuals.Download(
         actuals_base_url=download_actuals.create_filepath_url(
             os.path.join(self._input_dir, 'gm-actuals')),
         gm_actuals_root_url=download_actuals.create_filepath_url(
             os.path.join(self._input_dir, 'fake-gm-imagefiles')))
     downloader.fetch(
         builder_name='Test-Android-GalaxyNexus-SGX540-Arm7-Release',
         dest_dir=self._output_dir_actual)
Esempio n. 3
0
 def test_create_filepath_url(self):
   """Tests create_filepath_url(). """
   with self.assertRaises(Exception):
     url_or_path.create_filepath_url('http://1.2.3.4/path')
   # Pass absolute filepath.
   self.assertEquals(
       download_actuals.create_filepath_url(
           '%sdir%sfile' % (os.path.sep, os.path.sep)),
       'file:///dir/file')
   # Pass relative filepath.
   self.assertEquals(
       download_actuals.create_filepath_url(os.path.join('dir', 'file')),
       'file://%s/dir/file' % urllib.pathname2url(os.getcwd()))
Esempio n. 4
0
 def test_create_filepath_url(self):
     """Tests create_filepath_url(). """
     with self.assertRaises(Exception):
         url_or_path.create_filepath_url('http://1.2.3.4/path')
     # Pass absolute filepath.
     self.assertEquals(
         download_actuals.create_filepath_url('%sdir%sfile' %
                                              (os.path.sep, os.path.sep)),
         'file:///dir/file')
     # Pass relative filepath.
     self.assertEquals(
         download_actuals.create_filepath_url(os.path.join('dir', 'file')),
         'file://%s/dir/file' % urllib.pathname2url(os.getcwd()))
 def __init__(self, subdirs, actuals_root,
              generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
              image_base_url=DEFAULT_IMAGE_BASE_URL,
              diff_base_url=None):
   """
   Args:
     actuals_root: root directory containing all render_pictures-generated
         JSON files
     subdirs: (string, string) tuple; pair of subdirectories within
         actuals_root to compare
     generated_images_root: directory within which to create all pixel diffs;
         if this directory does not yet exist, it will be created
     image_base_url: URL under which all render_pictures result images can
         be found; this will be used to read images for comparison within
         this code, and included in the ImagePairSet so its consumers know
         where to download the images from
     diff_base_url: base URL within which the client should look for diff
         images; if not specified, defaults to a "file:///" URL representation
         of generated_images_root
   """
   time_start = int(time.time())
   self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
   self._image_base_url = image_base_url
   self._diff_base_url = (
       diff_base_url or
       download_actuals.create_filepath_url(generated_images_root))
   self._load_result_pairs(actuals_root, subdirs)
   self._timestamp = int(time.time())
   logging.info('Results complete; took %d seconds.' %
                (self._timestamp - time_start))
Esempio n. 6
0
 def __init__(self, actuals_root=DEFAULT_ACTUALS_DIR,
              expected_root=DEFAULT_EXPECTATIONS_DIR,
              generated_images_root=DEFAULT_GENERATED_IMAGES_ROOT,
              diff_base_url=None):
   """
   Args:
     actuals_root: root directory containing all actual-results.json files
     expected_root: root directory containing all expected-results.json files
     generated_images_root: directory within which to create all pixel diffs;
         if this directory does not yet exist, it will be created
     diff_base_url: base URL within which the client should look for diff
         images; if not specified, defaults to a "file:///" URL representation
         of generated_images_root
   """
   time_start = int(time.time())
   self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
   self._diff_base_url = (
       diff_base_url or
       download_actuals.create_filepath_url(generated_images_root))
   self._actuals_root = actuals_root
   self._expected_root = expected_root
   self._load_actual_and_expected()
   self._timestamp = int(time.time())
   logging.info('Results complete; took %d seconds.' %
                (self._timestamp - time_start))
Esempio n. 7
0
 def __init__(self, configs, actuals_root=results.DEFAULT_ACTUALS_DIR,
              generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
              diff_base_url=None, builder_regex_list=None):
   """
   Args:
     configs: (string, string) tuple; pair of configs to compare
     actuals_root: root directory containing all actual-results.json files
     generated_images_root: directory within which to create all pixel diffs;
         if this directory does not yet exist, it will be created
     diff_base_url: base URL within which the client should look for diff
         images; if not specified, defaults to a "file:///" URL representation
         of generated_images_root
     builder_regex_list: List of regular expressions specifying which builders
         we will process. If None, process all builders.
   """
   time_start = int(time.time())
   if builder_regex_list != None:
     self.set_match_builders_pattern_list(builder_regex_list)
   self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
   self._diff_base_url = (
       diff_base_url or
       download_actuals.create_filepath_url(generated_images_root))
   self._actuals_root = actuals_root
   self._load_config_pairs(configs)
   self._timestamp = int(time.time())
   logging.info('Results complete; took %d seconds.' %
                (self._timestamp - time_start))
Esempio n. 8
0
 def __init__(self,
              subdirs,
              actuals_root,
              generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
              image_base_url=DEFAULT_IMAGE_BASE_URL,
              diff_base_url=None):
     """
 Args:
   actuals_root: root directory containing all render_pictures-generated
       JSON files
   subdirs: (string, string) tuple; pair of subdirectories within
       actuals_root to compare
   generated_images_root: directory within which to create all pixel diffs;
       if this directory does not yet exist, it will be created
   image_base_url: URL under which all render_pictures result images can
       be found; this will be used to read images for comparison within
       this code, and included in the ImagePairSet so its consumers know
       where to download the images from
   diff_base_url: base URL within which the client should look for diff
       images; if not specified, defaults to a "file:///" URL representation
       of generated_images_root
 """
     time_start = int(time.time())
     self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
     self._image_base_url = image_base_url
     self._diff_base_url = (
         diff_base_url
         or download_actuals.create_filepath_url(generated_images_root))
     self._load_result_pairs(actuals_root, subdirs)
     self._timestamp = int(time.time())
     logging.info('Results complete; took %d seconds.' %
                  (self._timestamp - time_start))
 def __init__(self,
              actuals_root=results.DEFAULT_ACTUALS_DIR,
              expected_root=DEFAULT_EXPECTATIONS_DIR,
              generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
              diff_base_url=None,
              builder_regex_list=None):
     """
 Args:
   actuals_root: root directory containing all actual-results.json files
   expected_root: root directory containing all expected-results.json files
   generated_images_root: directory within which to create all pixel diffs;
       if this directory does not yet exist, it will be created
   diff_base_url: base URL within which the client should look for diff
       images; if not specified, defaults to a "file:///" URL representation
       of generated_images_root
   builder_regex_list: List of regular expressions specifying which builders
       we will process. If None, process all builders.
 """
     time_start = int(time.time())
     if builder_regex_list != None:
         self.set_match_builders_pattern_list(builder_regex_list)
     self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
     self._diff_base_url = (
         diff_base_url
         or download_actuals.create_filepath_url(generated_images_root))
     self._actuals_root = actuals_root
     self._expected_root = expected_root
     self._load_actual_and_expected()
     self._timestamp = int(time.time())
     logging.info('Results complete; took %d seconds.' %
                  (self._timestamp - time_start))
Esempio n. 10
0
 def test_copy_contents(self):
   """Tests copy_contents(). """
   contents = 'these are the contents'
   tempdir_path = tempfile.mkdtemp()
   try:
     source_path = os.path.join(tempdir_path, 'source')
     source_url = download_actuals.create_filepath_url(source_path)
     with open(source_path, 'w') as source_handle:
       source_handle.write(contents)
     dest_path = os.path.join(tempdir_path, 'new_subdir', 'dest')
     # Destination subdir does not exist, so copy_contents() should fail
     # if create_subdirs_if_needed is False.
     with self.assertRaises(Exception):
       download_actuals.copy_contents(source_url=source_url,
                                      dest_path=dest_path,
                                      create_subdirs_if_needed=False)
     # If create_subdirs_if_needed is True, it should work.
     download_actuals.copy_contents(source_url=source_url,
                                    dest_path=dest_path,
                                    create_subdirs_if_needed=True)
     self.assertEquals(open(dest_path).read(), contents)
   finally:
     shutil.rmtree(tempdir_path)
Esempio n. 11
0
 def test_copy_contents(self):
     """Tests copy_contents(). """
     contents = 'these are the contents'
     tempdir_path = tempfile.mkdtemp()
     try:
         source_path = os.path.join(tempdir_path, 'source')
         source_url = download_actuals.create_filepath_url(source_path)
         with open(source_path, 'w') as source_handle:
             source_handle.write(contents)
         dest_path = os.path.join(tempdir_path, 'new_subdir', 'dest')
         # Destination subdir does not exist, so copy_contents() should fail
         # if create_subdirs_if_needed is False.
         with self.assertRaises(Exception):
             download_actuals.copy_contents(source_url=source_url,
                                            dest_path=dest_path,
                                            create_subdirs_if_needed=False)
         # If create_subdirs_if_needed is True, it should work.
         download_actuals.copy_contents(source_url=source_url,
                                        dest_path=dest_path,
                                        create_subdirs_if_needed=True)
         self.assertEquals(open(dest_path).read(), contents)
     finally:
         shutil.rmtree(tempdir_path)
Esempio n. 12
0
 def __init__(self, actuals_root=results.DEFAULT_ACTUALS_DIR,
              expected_root=DEFAULT_EXPECTATIONS_DIR,
              ignore_failures_file=DEFAULT_IGNORE_FAILURES_FILE,
              generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
              diff_base_url=None, builder_regex_list=None):
   """
   Args:
     actuals_root: root directory containing all actual-results.json files
     expected_root: root directory containing all expected-results.json files
     ignore_failures_file: if a file with this name is found within
         expected_root, ignore failures for any tests listed in the file
     generated_images_root: directory within which to create all pixel diffs;
         if this directory does not yet exist, it will be created
     diff_base_url: base URL within which the client should look for diff
         images; if not specified, defaults to a "file:///" URL representation
         of generated_images_root
     builder_regex_list: List of regular expressions specifying which builders
         we will process. If None, process all builders.
   """
   time_start = int(time.time())
   if builder_regex_list != None:
     self.set_match_builders_pattern_list(builder_regex_list)
   self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
   self._diff_base_url = (
       diff_base_url or
       download_actuals.create_filepath_url(generated_images_root))
   self._actuals_root = actuals_root
   self._expected_root = expected_root
   self._ignore_failures_on_these_tests = []
   if ignore_failures_file:
     self._ignore_failures_on_these_tests = (
         ExpectationComparisons._read_noncomment_lines(
             os.path.join(expected_root, ignore_failures_file)))
   self._load_actual_and_expected()
   self._timestamp = int(time.time())
   logging.info('Results complete; took %d seconds.' %
                (self._timestamp - time_start))