Skip to content

Remove runtests.py #5274

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

Merged
merged 5 commits into from
Jul 18, 2018
Merged

Remove runtests.py #5274

merged 5 commits into from
Jul 18, 2018

Conversation

elazarg
Copy link
Contributor

@elazarg elazarg commented Jun 25, 2018

  • Replace runtests.py with a gentle reminder to use pytest script that executes pytest+lint+self check.
  • Remove waiter.py
  • Remove selfcheck unit test
  • Run self check from travis using python3 -m mypy --config-file mypy_self_check.ini -p mypy
  • Run linter explicitly from travis using flake8 -j0
  • Update docs

This is work-in-progress, here for review and testing. I tried to implement what I understood from the comments in #5270, but I'm not sure I got it right.

TODO: fix test run in typeshed.

Concludes #1673.

@elazarg elazarg force-pushed the pytest-complete branch 5 times, most recently from 8722b57 to 1b03518 Compare June 26, 2018 06:39
@elazarg elazarg changed the title [WIP] Remove runtests.py Remove runtests.py Jun 26, 2018
@elazarg
Copy link
Contributor Author

elazarg commented Jun 26, 2018

I'm not completely sure what is the ideal workflow. I've separated the tests from the self check, but it is one of the tests that one should run before opening a PR.

pytest && flake8 && python3 -m mypy --config-file mypy_self_check.ini -p mypy is a lengthy command to run. Maybe leave runtests.py as a shorthand?

(Or maybe you meant something entirely different? @gvanrossum @ilevkivskyi)

@emmatyping
Copy link
Member

emmatyping commented Jun 26, 2018

I personally would prefer to leave the self check under pytest, as it is a bit of a lengthy command to type out the entire command, and not very memorable. However I defer to the judgement of others, I can always use tox :)

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 26, 2018

I don't have a strong preference about whether to run self check under pytest, but if it's not being run under pytest, we should definitely have a simple, consistent way of running self check locally instead of running a long command line. It would be good to have an easy way of self checking using dmypy as well.

@ilevkivskyi
Copy link
Member

I would rather keep all three separate: tests, self-check, and flake8 (but this is also not a strong preference). For self-check I am mostly using Ctrk + Shift + M :-) If anyone else uses PyCharm, I can share my config for mypy plugin:

Mypy command: dmypy start -- --follow-imports=error --config-file=mypy_self_check.ini ; dmypy check mypy
PATH suffix: path/to/venv/bin

@JelleZijlstra
Copy link
Member

I would actually prefer to have everything (including self-check and lint) run under pytest, so that it's easy to run all tests locally without having to remember a lot of commands.

@elazarg
Copy link
Contributor Author

elazarg commented Jun 26, 2018

Looks like the simplest solution is to keep runtests as a simple scripts that executes pytest, self check and lint.

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 26, 2018

Looks like the simplest solution is to keep runtests as a simple scripts that executes pytest, self check and lint.

This is still worse that the legacy script since it will be harder to run just lint or self check. Whatever solution we use to replace runtests should make all of these easy (i.e. no need to remember complex command lines):

  • Run everything, including tests, lint and self check (matches what the travis build does).
  • Run only self check.
  • Run only lint.
  • Run some subset of tests (this already works).

Nice to haves, for extra credit:

  • It would be nice if the self check would run an incremental build by default.
  • Being able to run all tests without running self check or lint.
  • Provide also a way of running a dmypy self check, since these are often much faster than non-dmypy builds.

@elazarg
Copy link
Contributor Author

elazarg commented Jun 26, 2018

Ok. Here's another suggestion:

$ ./runtests.py (runs everything)

$ ./runtests.py [lint] [self] [pytest] [args...] any subset of the three. Arguments are passed to pytest only without any preprocessing (if pytest is not mentioned, reject additional arguments). Arguments are trailing only.

Passing arguments to self check will be performed manually.

Possibly use self-dmypy or something similar instead of self for dmypy self check.

@gvanrossum
Copy link
Member

gvanrossum commented Jun 26, 2018 via email

@elazarg elazarg force-pushed the pytest-complete branch 2 times, most recently from 502b55e to aafab7a Compare June 27, 2018 02:02
@elazarg
Copy link
Contributor Author

elazarg commented Jun 27, 2018

Done. The commands are evaluated eagerly asserted to find typos.

Copy link
Member

@emmatyping emmatyping left a comment

Choose a reason for hiding this comment

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

Just a few minor points. Overall looks great!

runtests.py Outdated
import os
from os.path import join, isdir
from sys import exit
from os import system
import sys
Copy link
Member

Choose a reason for hiding this comment

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

Nit: maybe fold this and the sys.exit import into one import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

runtests.py Outdated
for arg in args:
cmd = cmds[arg]
print('$', cmd)
res = (system(cmd) & 0x7F00) >> 8
Copy link
Member

Choose a reason for hiding this comment

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

Why the bit twiddling here? Wouldn't it be better to use subrocess.call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to have the full command copy-pastable in the source. To clarify that this is a shorthand script, and that nothing more is going on than a mere execution of a command.

.travis.yml Outdated
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then flake8; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.5.1' ]]; then python runtests.py package; fi
- pytest -n12
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then flake8 -j0; fi
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should have j12 here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, because why not.

tox.ini Outdated

[testenv:type]
description = type check ourselves
basepython = python3.6
commands = python runtests.py self-check -p '-n0' -p '-v'
commands = python3 -m mypy -p mypy
Copy link
Member

Choose a reason for hiding this comment

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

For consistency, we should point to the self-check config here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@elazarg
Copy link
Contributor Author

elazarg commented Jul 8, 2018

@ethanhs do you approve now?

@emmatyping
Copy link
Member

You have a merge conflict, but otherwise I approve.

@elazarg
Copy link
Contributor Author

elazarg commented Jul 9, 2018

I have no idea what's this conflict is about. It does not show up in my local merge, and the "resolve conflicts" key is disabled.

@elazarg
Copy link
Contributor Author

elazarg commented Jul 9, 2018

Moreover, the conflict said to be in a file that should be removed completely.

@elazarg
Copy link
Contributor Author

elazarg commented Jul 9, 2018

screen shot 2018-07-08 at 22 07 18

@emmatyping
Copy link
Member

It is listed when I merge master as CONFLICT (modify/delete): waiter.py deleted in HEAD.... I believe you should be able to git rm waiter.py then commit the merge.

@elazarg
Copy link
Contributor Author

elazarg commented Jul 9, 2018

But it does not exist.

~/workspace/mypy$ git status
On branch pytest-complete
Your branch is up to date with 'origin/pytest-complete'.

nothing to commit, working tree clean
~/workspace/mypy$ git rm waiter.py
fatal: pathspec 'waiter.py' did not match any files

@emmatyping
Copy link
Member

Ah, if it doesn't exist on disk you need git rm --cached waiter.py. This is probably one of the more illogical git commands...

@JelleZijlstra
Copy link
Member

The conflict is presumably that somebody else modified waiter.py on master, and you deleted it. The way to fix it would be to run git merge origin/master (I think, I don't do manual merges that often), and then when there's a conflict, git rm waiter.py as Ethan says.

@elazarg
Copy link
Contributor Author

elazarg commented Jul 9, 2018

~/workspace/mypy$ git rm --cached waiter.py
fatal: pathspec 'waiter.py' did not match any files

@elazarg
Copy link
Contributor Author

elazarg commented Jul 9, 2018

Sorry guys I'm so amazingly stupid. I've merged upstream/master but forgot git fetch upstream.

@elazarg elazarg force-pushed the pytest-complete branch from 587c09a to b2c59e6 Compare July 9, 2018 15:03
@Michael0x2a
Copy link
Collaborator

@ethanhs -- just to check, we can merge this now, right?

@emmatyping
Copy link
Member

@Michael0x2a yes, this should be good to go.

@ilevkivskyi ilevkivskyi merged commit 3e53036 into python:master Jul 18, 2018
@ilevkivskyi
Copy link
Member

Thanks for all the work on tests @elazarg!

@gvanrossum
Copy link
Member

gvanrossum commented Jul 18, 2018 via email

@JukkaL
Copy link
Collaborator

JukkaL commented Jul 19, 2018

This is great! Thanks Elazar!

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.

7 participants