Skip to content

Commit

Permalink
fix subprocess.run check
Browse files Browse the repository at this point in the history
  • Loading branch information
driazati committed Jun 15, 2022
1 parent 45ca55e commit deba0bf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
18 changes: 9 additions & 9 deletions tests/lint/pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
# under the License.
set -euxo pipefail

python3 -m pylint python/tvm --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint vta/python/vta --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/unittest/test_tvmscript_type.py --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/contrib/test_cmsisnn --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/relay/aot/*.py --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint python/tvm --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint vta/python/vta --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/unittest/test_tvmscript_type.py --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/contrib/test_cmsisnn --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint python/tvm --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint vta/python/vta --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint tests/python/unittest/test_tvmscript_type.py --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint tests/python/contrib/test_cmsisnn --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint tests/python/relay/aot/*.py --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint python/tvm --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint vta/python/vta --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint tests/python/unittest/test_tvmscript_type.py --rcfile="$(dirname "$0")"/pylintrc
# python3 -m pylint tests/python/contrib/test_cmsisnn --rcfile="$(dirname "$0")"/pylintrc
python3 -m pylint tests/python/ci --rcfile="$(dirname "$0")"/pylintrc
31 changes: 22 additions & 9 deletions tests/python/ci/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
"https://pr-docs.tlcpack.ai",
"SHA",
"issues/11594/comments",
"Built docs for commit [SHA](SHA) can be found [here](https://pr-docs.tlcpack.ai/PR-11594/3/docs/index.html).",
"Built docs for commit [SHA](SHA) can be found "
"[here](https://pr-docs.tlcpack.ai/PR-11594/3/docs/index.html).",
)
],
)
def test_docs_comment(
tmpdir_factory, target_url, base_url, commit_sha, expected_url, expected_body
):
"""
Test that a comment with a link to the docs is successfully left on PRs
"""
docs_comment_script = REPO_ROOT / "tests" / "scripts" / "github_docs_comment.py"

git = TempGit(tmpdir_factory.mktemp("tmp_git_dir"))
Expand All @@ -53,6 +57,7 @@ def test_docs_comment(
env={"TARGET_URL": target_url, "COMMIT_SHA": commit_sha},
encoding="utf-8",
cwd=git.cwd,
check=False,
)
if proc.returncode != 0:
raise RuntimeError(f"Process failed:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}")
Expand All @@ -73,7 +78,7 @@ def run(pr_body, requested_reviewers, existing_review_users, expected_reviewers)
git.run("remote", "add", "origin", "https://github.com/apache/tvm.git")
reviews = [{"user": {"login": r}} for r in existing_review_users]
requested_reviewers = [{"login": r} for r in requested_reviewers]
proc = subprocess.run( # pylint: disable=subprocess-run-check
proc = subprocess.run(
[str(reviewers_script), "--dry-run", "--testing-reviews-json", json.dumps(reviews)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand All @@ -84,6 +89,7 @@ def run(pr_body, requested_reviewers, existing_review_users, expected_reviewers)
},
encoding="utf-8",
cwd=git.cwd,
check=False,
)
if proc.returncode != 0:
raise RuntimeError(f"Process failed:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}")
Expand Down Expand Up @@ -159,12 +165,13 @@ def run(statuses, expected_rc, expected_output):
}
}
}
proc = subprocess.run( # pylint: disable=subprocess-run-check
proc = subprocess.run(
[str(update_script), "--dry-run", "--testonly-json", json.dumps(data)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
cwd=git.cwd,
check=False,
)

if proc.returncode != expected_rc:
Expand Down Expand Up @@ -258,8 +265,10 @@ def test(commands, should_skip, pr_title, why):
for command in commands:
git.run(*command)
pr_number = "1234"
proc = subprocess.run( # pylint: disable=subprocess-run-check
[str(skip_ci_script), "--pr", pr_number, "--pr-title", pr_title], cwd=git.cwd
proc = subprocess.run(
[str(skip_ci_script), "--pr", pr_number, "--pr-title", pr_title],
cwd=git.cwd,
check=False,
)
expected = 0 if should_skip else 1
assert proc.returncode == expected, why
Expand Down Expand Up @@ -350,7 +359,7 @@ def run(files, should_skip):
git.run("checkout", "-b", "main")
git.run("remote", "add", "origin", "https://github.com/apache/tvm.git")

proc = subprocess.run( # pylint: disable=subprocess-run-check
proc = subprocess.run(
[
str(script),
"--files",
Expand All @@ -360,6 +369,7 @@ def run(files, should_skip):
stderr=subprocess.PIPE,
encoding="utf-8",
cwd=git.cwd,
check=False,
)

if should_skip:
Expand Down Expand Up @@ -398,7 +408,7 @@ def run(pull_request, check):
}
}
}
proc = subprocess.run( # pylint: disable=subprocess-run-check
proc = subprocess.run(
[
str(reviewers_script),
"--dry-run",
Expand All @@ -417,6 +427,7 @@ def run(pull_request, check):
stderr=subprocess.PIPE,
encoding="utf-8",
cwd=git.cwd,
check=False,
)
if proc.returncode != 0:
raise RuntimeError(f"Process failed:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}")
Expand Down Expand Up @@ -573,7 +584,7 @@ def run(source_type, data, check):
env = {
source_type: json.dumps(data),
}
proc = subprocess.run( # pylint: disable=subprocess-run-check
proc = subprocess.run(
[
str(tag_script),
"--dry-run",
Expand All @@ -585,6 +596,7 @@ def run(source_type, data, check):
encoding="utf-8",
cwd=git.cwd,
env=env,
check=False,
)
if proc.returncode != 0:
raise RuntimeError(f"Process failed:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}")
Expand Down Expand Up @@ -871,7 +883,7 @@ def test_should_rebuild_docker(tmpdir_factory, changed_files, name, check, expec
},
}

proc = subprocess.run( # pylint: disable=subprocess-run-check
proc = subprocess.run(
[
str(tag_script),
"--testing-docker-data",
Expand All @@ -881,6 +893,7 @@ def test_should_rebuild_docker(tmpdir_factory, changed_files, name, check, expec
stderr=subprocess.STDOUT,
encoding="utf-8",
cwd=git.cwd,
check=False,
)

assert_in(check, proc.stdout)
Expand Down

0 comments on commit deba0bf

Please sign in to comment.