Skip to content
This repository has been archived by the owner on Jan 11, 2018. It is now read-only.

Commit

Permalink
Fix aggregate, fix the world
Browse files Browse the repository at this point in the history
  • Loading branch information
d3ming committed Dec 9, 2015
1 parent b63b035 commit a3415ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tagcompare/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def aggregate(outputdir=OUTPUT_DIR):
if not os.path.exists(outputdir):
raise ValueError("outputdir does not exist at %s!" % outputdir)

# TODO: hardcoding path concat is not good
outputdir = str(outputdir).rstrip('/')
buildpaths = glob.glob(outputdir + '/*/')
aggregate_path = os.path.join(outputdir, DEFAULT_BUILD_NAME)

Expand All @@ -219,14 +219,18 @@ def aggregate(outputdir=OUTPUT_DIR):
os.makedirs(aggregate_path)

LOGGER.info("Aggregating build data to %s", aggregate_path)
# Workaround bug with dir_util
# See http://stackoverflow.com/questions/9160227/
dir_util._path_created = {}
for buildpath in buildpaths:
if str(buildpath).endswith(DEFAULT_BUILD_NAME + "/"):
# Don't do this for the default build
continue

buildpath = os.path.join(outputdir, buildpath)
LOGGER.debug("Copying from %s to %s", buildpath,
aggregate_path)
LOGGER.warn("Copying from %s to %s", buildpath,
aggregate_path)

dir_util.copy_tree(buildpath, aggregate_path, update=1)
return aggregate_path

Expand Down
9 changes: 9 additions & 0 deletions tagcompare/test/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil

from tagcompare import compare
from tagcompare import output
Expand All @@ -14,8 +15,15 @@ def compare_configs(pathbuilder, configs):
"""
testpath = os.path.join(os.path.abspath(
os.path.dirname(__file__)), 'assets')

# Make sure we aggregate before a compare
# TODO: This test is more like an integration test in that it tests aggregation
aggregate_path = output.aggregate(outputdir=testpath)
assert aggregate_path == os.path.join(testpath, output.DEFAULT_BUILD_NAME)
assert os.path.exists(aggregate_path), "aggregate path doesn't exist!"
assert len(os.listdir(aggregate_path)) == 12, \
"there should be exactly 12 configs aggregated!"

build = "testbuild"
cid = 477944
pb = output.PathBuilder(basepath=testpath,
Expand All @@ -26,6 +34,7 @@ def compare_configs(pathbuilder, configs):
expected_errors=0, expected_total=4, expected_skips=0)
__test_compare_configs(pb, configs=["chrome", "firefox"],
expected_errors=3, expected_total=4, expected_skips=0)
shutil.rmtree(aggregate_path)


def __test_compare_configs(pb, configs, expected_errors, expected_total, expected_skips):
Expand Down

0 comments on commit a3415ac

Please sign in to comment.