Skip to content

Conversation

Nebelhom
Copy link
Collaborator

This PR addresses Issue #168

@Nebelhom
Copy link
Collaborator Author

@JarekPs, @davehunt

Could you maybe have a look over it? Thanks a lot

@ghost
Copy link

ghost commented Nov 19, 2013

@Nebelhom looks like travis is sad ;(

@Nebelhom
Copy link
Collaborator Author

@JarekPs

Travis is sad, because it cannot find ./run_tests.sh

I don't really find that surprising, giving that I removed it ;)

@ghost
Copy link

ghost commented Nov 20, 2013

Yup, and that's first thing to fix ;-)

  1. I would move all call(['python']) into function python() like you've done install()
  2. I would move requirements hardcoded here into separate requirements_test.txt. Then you could install them via pip install -r requirements_test.txt. Alternatively you could put them in setup py in extras_require. However, it's my personal opinion, final decision should be made by @whimboo or @davehunt.

Besides, me gusta 👍

run_tests.py Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer a bash script...

@davehunt
Copy link
Member

I agree with @JarekPs comments too, and would be interested to see if we can list the test dependencies in setup.py, but would otherwise be happy with a requirements file for them.

@whimboo
Copy link
Contributor

whimboo commented Nov 21, 2013

As mentioned earlier we might want to have it as 'python setup.py test' later. So I would defer the package dependency updates to a separate pull and keep this for the conversion only. For the remaining changes the following URL might be useful: http://pytest.org/latest/goodpractises.html

@Nebelhom
Copy link
Collaborator Author

@whimboo @davehunt @JarekPs

Does one of you know of a good HOWTO on using extras_require? It doesn't want to work for me.

http://peak.telecommunity.com/DevCenter/setuptools#declaring-extras-optional-features-with-their-own-dependencies

and various stackoverflows haven't helped yet...

thax guys

@whimboo
Copy link
Contributor

whimboo commented Nov 28, 2013

Why do you need extras_require on this PR? As said earlier and I think Dave repeated it, its a separate issue.

@Nebelhom
Copy link
Collaborator Author

Nebelhom commented Dec 2, 2013

I've decided now (with the advice of my fellow developers, i.e. you) to just translate the bash script to a python script.

Unfortunately, I encounter two issues that I am not able to fix (or understand for that matter). Any help/hints with them are greatly appreciated.

  1. It seems that every time I call pip.main, the output line repeats itself once more for each call (i.e. after 4 calls, I see four lines saying "Cleaning up...")

  2. The script finds an installation of ManifestDestiny but cannot find manifestparser, thus not running the test scripts

Traceback (most recent call last):
File "tests/test.py", line 12, in
from manifestparser import TestManifest
ImportError: No module named manifestparser

  1. Travis-Ci gives a Permission Denied error

@davehunt
Copy link
Member

davehunt commented Dec 3, 2013

  1. It seems that every time I call pip.main, the output line repeats itself once more for each call (i.e. after 4 calls, I see four lines saying "Cleaning up...")

Looks like this happens after install. See https://github.com/pypa/pip/blob/develop/pip/commands/install.py#L292, if you want to skip the cleanup it looks like there are some options. The other option would be to change the log level.

  1. The script finds an installation of ManifestDestiny but cannot find manifestparser, thus not running the test scripts

This would imply that ManifestDestiny is not installed. 0.6 is available now, maybe try upgrading? Alternatively, paste the full output from your script.

  1. Travis-Ci gives a Permission Denied error

Is run_tests.py executable?

@Nebelhom
Copy link
Collaborator Author

Nebelhom commented Dec 6, 2013

@whimboo @JarekPs

In the end, @davehunt's insights made the difference. Many thanks to you for this.

Apart from the issue with the logger output, everything is fixed now. While I will try and sort this problem out (most likely setting a suitable flag somewhere), you can already have a browse and check if you like what you see.

comments are welcome. Thanks guys.

run_tests.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this install virtualenv globally on the users machine, and sudo permissions are necessary? I still think we have to download it ourselves as given in the comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it actually would. Never thought of it that way.

After a brief search, I cam across the following links with this problem in mind:

http://stackoverflow.com/questions/9348869/how-to-install-virtualenv-without-using-sudo

http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python

The former cites the latter. Would this be a good alternative?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please check the build scripts of mozmill-environment. We should never have to install virtualenv on the testers box.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you're right as usual. all the build scripts include virtualenv. I'll remove the line.

Copy link
Member

Choose a reason for hiding this comment

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

Are you suggest that running mozdownload tests should be dependent on having a mozmill-environment @whimboo? I don't think this is a good idea. I would suggest throwing an exception if virtualenv is not present and instruct the user to install it in order to run the tests.

@Nebelhom
Copy link
Collaborator Author

@davehunt @whimboo @JarekPs

One final look over, please? thanks for the help.

run_tests.py Outdated
Copy link
Member

Choose a reason for hiding this comment

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

We repeat the tests/venv several times. I would suggest putting this a part of the path into a variable.

@Nebelhom
Copy link
Collaborator Author

@davehunt

You were right! I changed it accordingly. Could you look over it again?

Let's get this landed :)

run_tests.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, what about putting all this into a requirements.txt file under tests? I think that would be easier to maintain also in terms if we don't want to have those strict requirements in the future.

@Nebelhom
Copy link
Collaborator Author

@whimboo

I tried to rewrite the script according to the mozmill-environment script. Could you please give me your feedback? I am sure there are things that will need adjusting... Thanks

README.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that you have added the shebang to the py file, you can start it directly without specifying the python interpreter.

@whimboo
Copy link
Contributor

whimboo commented Jan 7, 2014

The latest update looks fine! There are a couple of majorly nits which have to be fixed. Thanks for the update Johannes!

@Nebelhom
Copy link
Collaborator Author

@whimboo Rebase was done. Let's hope Travis runs it now...

it failed :( And again I cannot actually look at why it failed. For some reason, Travis does not give me access. It always forwards me to the getting started page...

@whimboo
Copy link
Contributor

whimboo commented Feb 14, 2014

You don't see the results here?

$ ./run_tests.py
Traceback (most recent call last):
File "./run_tests.py", line 12, in
import mozfile
ImportError: No module named mozfile

I do not see that you are running python setup.py develop before running the tests. That would install all dependencies, including mozfile.

@Nebelhom
Copy link
Collaborator Author

@whimboo

After having talked to you on IRC, I think we both agree that we would like to call setup.py develop from within ./run_tests.py.

The problem we are encountering with mozfile is that we are calling setup.py from within the virtualenv (and thus install it in the virtualenv) while we use mozfile "before" starting the virtualenv to remove the venv directory. Therefore, if mozfile is not yet installed, it won't work.

I could, of course, call pip install mozfile before and pip uninstall mozfile after the start of the venv, to make it work.

Do you have a better idea?

@davehunt
Copy link
Member

Yep, you're trying to use mozfile from outside of your virtual environment, so you would need it to be installed globally. You could even have a situation where your Python script has dependencies that are not satisfied by your Python package. For Travis-CI you could simply install the script dependencies because you're in a temporary environment, but locally this would attempt to install globally.

Another option is YAVE (yet another virtual environment) for the script to run in, with its own requirements. Personally, I would probably just avoid using external dependencies in the script.

@whimboo
Copy link
Contributor

whimboo commented Feb 18, 2014

Oh, yeah. Lets remove it then and return to shutil.rmdir() in this case. I missed that we call this outside of the created venv. So it doesn't make that much sense right now.

@whimboo
Copy link
Contributor

whimboo commented Mar 6, 2014

@Nebelhom you missed to mention your latest update here. I assume this PR is ready for the final review?

@Nebelhom
Copy link
Collaborator Author

Nebelhom commented May 9, 2014

@whimboo

yup, if I remember correctly, this PR is ready for its final review.

Travis still seems to be happy...

@whimboo whimboo changed the title Converted run_tests.sh to python script (#168) Convert run_tests script to Python (#168) May 19, 2014
@whimboo
Copy link
Contributor

whimboo commented May 19, 2014

This looks great now. I squashed the commit and landed the patch as feb16bf. Thanks a lot for all your work Johannes!

@Nebelhom
Copy link
Collaborator Author

@whimboo Oh wow, never thought I would see the day this one would get accepted. Phew! Let's wait a week and see how many crashes it causes ;)

Thanks for your support there whimboo. I'm really glad we managed to get it landed!

@whimboo
Copy link
Contributor

whimboo commented May 22, 2014

You are most welcome @Nebelhom!! It's great to see your Python skillz improved each and every time a new patch gets uploaded.

@Nebelhom Nebelhom deleted the run_tests2py branch March 6, 2015 16:27
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