Skip to content

add count_test, filter_param, ctest_indent #27

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/generate_ctest/count_test_on_each_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## By Oscar Chen and Chris Shen from CS527, Fall 2022
## This program will generate a "{project}_test_num_on_param.txt" file in same directory that records the number of test methods related to each param.
## In each line of the generated file, the number of tests methods always comes before the param name
## File required: openctest/data/ctest_mapping/opensource-{project}.json
## openctest/core/generate_value/{project}-generated-values.tsv
import json
from program_input import p_input
j = json.load(open("../../data/ctest_mapping/opensource-"+p_input["project"]+".json"))
c = {}
for p in open("../generate_value/"+p_input["project"]+"-generated-values.tsv").readlines():
key = p.split("\t")[0]
if (key in j.keys()):
c.update({key: len(j[key])})
with open(p_input["project"]+"_test_num_on_param.txt", "w") as outfile:
for k in c.keys():
outfile.write(str(c[k])+"\t"+k+"\n")
7 changes: 7 additions & 0 deletions core/generate_ctest/ctest_indent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## By Oscar Chen and Chris Shen from CS527, Fall 2022
## This program helps create an indented version of ctests-{project}.json
## Fire required: openctest/core/generate_ctest/ctest_mapping/ctests-{project}.json
import json
from program_input import p_input
j = json.load(open("ctest_mapping/ctests-"+p_input["project"]+".json"))
json.dump(j, open("ctest_mapping/ctests-"+p_input["project"]+"-indent.json", "w"), indent=4)
16 changes: 16 additions & 0 deletions core/generate_ctest/filter_param_by_test_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## By Oscar Chen and Chris Shen from CS527, Fall 2022
## This program will filter the params with number of test reference in between min and max
## The selected params will be saved in {project}.tsv in same directory
## Fill free to modify min and max to what you need
## File required: openctest/data/ctest_mapping/opensource-{project}.json
## openctest/core/generate_value/{project}-generated-values.tsv
import json
from program_input import p_input
min = 0
max = 50
j = json.load(open("../../data/ctest_mapping/opensource-"+p_input["project"]+".json"))
w = open(p_input["project"]+".tsv", "w")
for p in open("../generate_value/"+p_input["project"]+"-generated-values.tsv").readlines():
key = p.split("\t")[0]
if key in j.keys() and (len(j[key]) >= min) and (len(j[key]) < max):
w.write(p)