-
Notifications
You must be signed in to change notification settings - Fork 247
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 scripts to automatically detect deleted tests #427
Open
FanYuliang
wants to merge
3
commits into
TestingResearchIllinois:main
Choose a base branch
from
FanYuliang:upstream_main_unhistory
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import pandas as pd | ||
import subprocess | ||
from glob import glob | ||
import os | ||
import shutil | ||
from tqdm import tqdm | ||
import json | ||
|
||
archieved = [ | ||
"https://github.com/gooddata/GoodData-CL" | ||
] | ||
|
||
|
||
df = pd.read_csv("../pr-data.csv") | ||
error_log = [] | ||
test_file_deleted = [] | ||
test_method_deleted = [] | ||
base_dir = os.getcwd() | ||
|
||
df = df.groupby("Project URL").agg(lambda x: list(x)) | ||
|
||
for url, row in tqdm(df.iterrows(), total=df.shape[0]): | ||
|
||
testname_list, status_list, note_list = row["Fully-Qualified Test Name (packageName.ClassName.methodName)"], row["Status"], row["Notes"] | ||
print("url", url) | ||
if url in archieved: | ||
print("this url has been archieved! skip") | ||
continue | ||
|
||
clone_cmd = "git clone --quiet {} tmp && cd tmp".format(url) | ||
subprocess.run(clone_cmd, shell=True, stdout=open(os.devnull, 'wb')) | ||
print("clone done!!!") | ||
for full_testname, status, note in zip(testname_list, status_list, note_list): | ||
testfile_name, test_method_name = full_testname.split(".")[-2], full_testname.split(".")[-1] | ||
|
||
if pd.isna(status) and pd.isna(note): | ||
|
||
if "[" in test_method_name or "\"" in test_method_name: | ||
print("{}, {} is a PUT; skip".format(url, full_testname)) | ||
continue | ||
if testfile_name[-4:] != "Test": | ||
error_log.append("{}, {}".format(url, full_testname)) | ||
continue | ||
|
||
fnames = glob("**/{}.java".format(testfile_name), recursive=True) | ||
if len(fnames) == 0: | ||
# try to get the commit id | ||
git_find_SHA = "cd tmp && git rev-list -n 1 HEAD -- **/{}.java".format(testfile_name) | ||
commit_SHA = subprocess.check_output(git_find_SHA, shell=True).decode("utf-8") | ||
|
||
if len(commit_SHA) > 0: | ||
test_file_deleted.append("{}, {}, {}".format(url, full_testname, url+"/commit/"+commit_SHA)) | ||
print("[INFO]:detected Test File " + "{}, {} was deleted at SHA {}".format(url, full_testname, commit_SHA)) | ||
# test file not found; add to log | ||
else: | ||
print("[INFO]: detected deleted Test File WITHOUT FINDING SHA: ", "{}, {}".format(url, full_testname)) | ||
|
||
|
||
# clean the repo and repeat | ||
os.chdir(base_dir) | ||
shutil.rmtree("tmp") | ||
|
||
|
||
with open("new_test_file_deleted.json", "w") as f: | ||
json.dump(test_file_deleted, f) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pandas | ||
tqdm |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many tests in pr-data.csv have "Test" in the beginning instead of the end.