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 script to check duplicates entry in path #15263

Merged
merged 15 commits into from
Jul 14, 2017

Conversation

k-okada
Copy link
Contributor

@k-okada k-okada commented Jun 17, 2017

as suggested at ros-infrastructure/rosdep#520 (review)
added argumetns to allow take local files

./scripts/check_duplicates.py rosdep/*.yaml

I also added this to test, but I'm afraid this is too aggresive

@tfoote

@mikaelarguedas
Copy link
Member

please rebase on top on current master, to provide a PR with a single commit 67963d8

Please see the travis log to see the reason of the failure

@k-okada k-okada force-pushed the add_check_scripts branch 5 times, most recently from e922faa to 6e4c29a Compare June 18, 2017 05:46
@k-okada
Copy link
Contributor Author

k-okada commented Jun 18, 2017

fixed and passed test, but that's strange, because the test should be failed.
may be we do need not run rosdep init & rosdep update to enable this test code.

@k-okada
Copy link
Contributor Author

k-okada commented Jun 18, 2017

ok, fixed, now it fails as expected, https://travis-ci.org/ros/rosdistro/builds/244168788?utm_source=github_status&utm_medium=notification
need to merge #15260 #15259 to pass this test.


checking with ['indigo', 'ubuntu', 'trusty']
checking sources
- file:///home/travis/build/ros/rosdistro/indigo/distribution.yaml
- flie://home/travis/build/ros/rosdistro/rosdep/base.yaml
- flie://home/travis/build/ros/rosdistro/rosdep/gentoo.yaml
- flie://home/travis/build/ros/rosdistro/rosdep/python.yaml
- flie://home/travis/build/ros/rosdistro/rosdep/ruby.yaml
checking duplicates
* file:///home/travis/build/ros/rosdistro/indigo/distribution.yaml
* flie://home/travis/build/ros/rosdistro/rosdep/base.yaml
  ERR: pocketsphinx is multiply defined in
	file:///home/travis/build/ros/rosdistro/indigo/distribution.yaml and 
	flie://home/travis/build/ros/rosdistro/rosdep/base.yaml
* flie://home/travis/build/ros/rosdistro/rosdep/gentoo.yaml
* flie://home/travis/build/ros/rosdistro/rosdep/python.yaml
  ERR: xdot is multiply defined in
	file:///home/travis/build/ros/rosdistro/indigo/distribution.yaml and 
	flie://home/travis/build/ros/rosdistro/rosdep/python.yaml

@k-okada k-okada force-pushed the add_check_scripts branch 7 times, most recently from 2307ccf to a8bddd7 Compare July 7, 2017 23:52
@k-okada
Copy link
Contributor Author

k-okada commented Jul 8, 2017

@mikaelarguedas @tfoote ik, now we passed the travis test so ready fo a reivew,
I confirmed this PR failes if we revert commit 2993ff6

* flie://home/travis/build/ros/rosdistro/rosdep/ruby.yaml
* flie://home/travis/build/ros/rosdistro/rosdep/python.yaml
  ERR: xdot is multiply defined in
	file:///home/travis/build/ros/rosdistro/indigo/distribution.yaml and 
	flie://home/travis/build/ros/rosdistro/rosdep/python.yaml
* sources.list
checking with ['jade', 'ubuntu', 'trusty']
checking sources

https://travis-ci.org/ros/rosdistro/builds/251355160

I have to install python-rosdep to run this feature, but I am not confident in this implementation, if someone know better way, let me know.



def print_err(msg):
printc(' ERR: ' + msg, 'red')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather avoid adding this colorization logic just for this test. None of the other tests does it either.

print_test('checking with %s'%(matcher.tags))
sources = [x for x in sources if matcher.matches(x)]
ret = ret & check_duplicates(sources)
return ret
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please return an integer from the main function which represents an error code or 0 if successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this commit 00fd688
It seems nosetest need to return True or False, not integer,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I can follow: how is the main function being called from nosetests? nosetests should only pick up the test functions defined in rosdep_duplicates_test.py.

Copy link
Contributor Author

@k-okada k-okada Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dirk-thomas yes and I called main as check_duplicatesat the last of rosdep_duplicates_test.py
https://github.com/ros/rosdistro/pull/15263/files#diff-857189dd46c3a32ffe6a1424eaf41c5fR5

I just followed https://github.com/ros/rosdistro/blob/master/test/rosdep_formatting_test.py and https://github.com/ros/rosdistro/blob/master/scripts/check_rosdep.py style, so please let me know your recommended test and script code, so that I can follow your direction.

parser.add_argument('infiles', nargs='*', help='input rosdep YAML file')
args = parser.parse_args()
if not main(args.infiles):
sys.exit(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be sys.exit(main(...)) then.


def test():
files = os.listdir('rosdep')
files = filter(lambda x: x.endswith('.yaml'), files) # accept only file ends with .yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a list comprehension for this instead. Also please follow PEP 8 for the comments (two spaces + # + one space + comment text)

files = filter(lambda x: x.endswith('.yaml'), files) # accept only file ends with .yaml
files = [os.path.join('rosdep', x) for x in files] # use relative path
with Fold() as fold:
print("""Running 'scripts/check_duplicates.py' on all '*.yaml' in the 'rosdep' directory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use single " here. No need to use """.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dirk-thomas thank you for comment, I think I have fixed all parts

rosdep_data = yaml.load(f.read())
# osx-homebrow uses xos tag
tag = 'osx' if 'osx-' in filepath else ''
model = CachedDataSource('yaml', 'flie:/'+filepath, [tag], rosdep_data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: flie

Copy link
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is currently failing.

@dirk-thomas dirk-thomas merged commit 3a6a34f into ros:master Jul 14, 2017
@k-okada k-okada deleted the add_check_scripts branch July 15, 2017 01:38
@k-okada
Copy link
Contributor Author

k-okada commented Jul 15, 2017

@dirk-thomas thank you!!

@dirk-thomas
Copy link
Member

Thank you for your effort coming up with the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants