Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add folding of log sections for tests on Travis #14147

Merged
merged 1 commit into from Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file added test/__init__.py
Empty file.
19 changes: 19 additions & 0 deletions test/fold_block.py
@@ -0,0 +1,19 @@
import os

next_block_id = 1


class Fold(object):

def __init__(self):
global next_block_id
self.block_id = next_block_id
next_block_id += 1

def __enter__(self):
if os.environ.get('TRAVIS') == 'true':
print('travis_fold:start:block%d' % self.block_id)

def __exit__(self, type, value, traceback):
if os.environ.get('TRAVIS') == 'true':
print('travis_fold:end:block%d' % self.block_id)
20 changes: 11 additions & 9 deletions test/rosdep_formatting_test.py
Expand Up @@ -4,19 +4,21 @@

from scripts.check_rosdep import main as check_rosdep

from .fold_block import Fold


def test():
files = os.listdir('rosdep')

print("""
Running 'scripts/check_rosdep.py' on all '*.yaml' in the 'rosdep' directory.
with Fold():
print("""Running 'scripts/check_rosdep.py' on all '*.yaml' in the 'rosdep' directory.
If this fails you can run 'scripts/clean_rosdep.py' to help cleanup.
""")

for f in sorted(files):
fname = os.path.join('rosdep', f)
if not f.endswith('.yaml'):
print("Skipping rosdep check of file %s" % fname)
continue
print("Checking rosdep file: %s" % fname)
assert check_rosdep(fname)
for f in sorted(files):
fname = os.path.join('rosdep', f)
if not f.endswith('.yaml'):
print("Skipping rosdep check of file %s" % fname)
continue
print("Checking rosdep file: %s" % fname)
assert check_rosdep(fname)
10 changes: 6 additions & 4 deletions test/rosdistro_check_urls_test.py
Expand Up @@ -6,6 +6,8 @@
from scripts import eol_distro_names
from scripts.check_rosdistro_urls import main as check_rosdistro_urls

from .fold_block import Fold

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))


Expand All @@ -16,10 +18,10 @@ def test_rosdistro_urls():
for distro_name in sorted(index.distributions.keys()):
if distro_name in eol_distro_names:
continue
print("""
Checking if the distribution files of '%s' contain valid urls for known hosting services.
with Fold():
print("""Checking if the distribution files of '%s' contain valid urls for known hosting services.
If this fails you can run 'scripts/check_rosdistro_urls.py file://`pwd`/%s %s' to perform the same check locally.
""" % (distro_name, 'index.yaml', distro_name))
if not check_rosdistro_urls(index_url, distro_name):
failed_distros.append(distro_name)
if not check_rosdistro_urls(index_url, distro_name):
failed_distros.append(distro_name)
assert not failed_distros, "There were problems with urls in the distribution files for these distros: %s" % failed_distros
10 changes: 6 additions & 4 deletions test/rosdistro_verify_test.py
Expand Up @@ -2,15 +2,17 @@

from rosdistro.verify import verify_files_identical

from .fold_block import Fold

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))


def test_verify_files_identical():
print("""
Checking if index.yaml and all referenced files comply to the formatting rules.
with Fold():
print("""Checking if index.yaml and all referenced files comply to the formatting rules.
If this fails you can run 'rosdistro_reformat index.yaml' to help cleanup.
'rosdistro_reformat' shows the diff between the current files and their expected formatting.
""")

index_url = 'file://' + FILES_DIR + '/index.yaml'
assert verify_files_identical(index_url)
index_url = 'file://' + FILES_DIR + '/index.yaml'
assert verify_files_identical(index_url)
27 changes: 19 additions & 8 deletions test/test_build_caches.py
@@ -1,20 +1,31 @@
import os

from rosdistro import get_index
from rosdistro.distribution_cache_generator import generate_distribution_caches
from rosdistro.distribution_cache_generator import generate_distribution_cache

from scripts import eol_distro_names

from .fold_block import Fold

INDEX_YAML = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'index.yaml'))


def test_build_caches():
print("""
Checking if the 'package.xml' files for all packages are fetchable.
with Fold():
print("""Checking if the 'package.xml' files for all packages are fetchable.
If this fails you can run 'rosdistro_build_cache index.yaml' to perform the same check locally.
""")
index = 'file://' + os.path.abspath(INDEX_YAML)
index = get_index(index)
dist_names = sorted(index.distributions.keys())
dist_names = [n for n in dist_names if n not in eol_distro_names]
generate_distribution_caches(INDEX_YAML, dist_names=dist_names)
index = 'file://' + os.path.abspath(INDEX_YAML)
index = get_index(index)
dist_names = sorted(index.distributions.keys())
dist_names = [n for n in dist_names if n not in eol_distro_names]

errors = []
for dist_name in dist_names:
with Fold():
try:
generate_distribution_cache(index, dist_name)
except RuntimeError as e:
errors.append(str(e))
if errors:
raise RuntimeError('\n'.join(errors))
46 changes: 25 additions & 21 deletions test/test_url_validity.py
Expand Up @@ -9,21 +9,23 @@
from io import StringIO
import os
import subprocess
import yaml
from yaml.composer import Composer
from yaml.constructor import Constructor
import sys
import unittest
from urlparse import urlparse

import rosdistro
from scripts import eol_distro_names
import unidiff
from urlparse import urlparse
import yaml
from yaml.composer import Composer
from yaml.constructor import Constructor

from .fold_block import Fold

# for commented debugging code below
# import pprint

DIFF_TARGET = 'origin/master'
EOL_DISTROS = ['groovy', 'hydro']


TARGET_FILE_BLACKLIST = []
Expand All @@ -47,7 +49,7 @@ def get_eol_distribution_filenames(url=None):
distribution_filenames = []
i = rosdistro.get_index(url)
for d_name, d in i.distributions.items():
if d_name in EOL_DISTROS:
if d_name in eol_distro_names:
for f in d['distribution']:
dpath = os.path.abspath(urlparse(f).path)
distribution_filenames.append(dpath)
Expand Down Expand Up @@ -222,28 +224,30 @@ def main():
url = 'file://%s/index.yaml' % directory
path = os.path.abspath(path)
if path not in get_all_distribution_filenames(url):
print("not verifying diff of file %s" % path)
# print("not verifying diff of file %s" % path)
continue
is_eol_distro = path in get_eol_distribution_filenames(url)
data = load_yaml_with_lines(path)
with Fold():
print("verifying diff of file '%s'" % path)
is_eol_distro = path in get_eol_distribution_filenames(url)
data = load_yaml_with_lines(path)

repos = data['repositories']
if not repos:
continue
repos = data['repositories']
if not repos:
continue

changed_repos = isolate_yaml_snippets_from_line_numbers(repos, lines)
changed_repos = isolate_yaml_snippets_from_line_numbers(repos, lines)

# print("In file: %s Changed repos are:" % path)
# pprint.pprint(changed_repos)
# print("In file: %s Changed repos are:" % path)
# pprint.pprint(changed_repos)

for n, r in changed_repos.items():
errors = check_repo_for_errors(r)
detected_errors.extend(["In file '''%s''': " % path + e
for e in errors])
if is_eol_distro:
errors = detect_post_eol_release(n, r, lines)
for n, r in changed_repos.items():
errors = check_repo_for_errors(r)
detected_errors.extend(["In file '''%s''': " % path + e
for e in errors])
if is_eol_distro:
errors = detect_post_eol_release(n, r, lines)
detected_errors.extend(["In file '''%s''': " % path + e
for e in errors])

for e in detected_errors:

Expand Down