Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
b8935980
Unverified
Commit
b8935980
authored
Jun 06, 2023
by
Sylvain Gugger
Committed by
GitHub
Jun 06, 2023
Browse files
Modification of one text example file should trigger said test (#24051)
parent
02fe3af2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
tests/repo_utils/test_tests_fetcher.py
tests/repo_utils/test_tests_fetcher.py
+35
-0
utils/tests_fetcher.py
utils/tests_fetcher.py
+3
-0
No files found.
tests/repo_utils/test_tests_fetcher.py
View file @
b8935980
...
@@ -759,6 +759,41 @@ src/transformers/configuration_utils.py
...
@@ -759,6 +759,41 @@ src/transformers/configuration_utils.py
assert
tests_to_run
==
"tests/models/bert/test_modeling_bert.py"
assert
tests_to_run
==
"tests/models/bert/test_modeling_bert.py"
def
test_infer_tests_to_run_with_examples_modifs
(
self
):
with
tempfile
.
TemporaryDirectory
()
as
tmp_folder
:
tmp_folder
=
Path
(
tmp_folder
)
models
=
[
"bert"
,
"gpt2"
]
repo
=
create_tmp_repo
(
tmp_folder
,
models
=
models
)
# Modification in one example trigger the corresponding test
commit_changes
(
"examples/pytorch/text-classification/run_glue.py"
,
"from transformers import BertModeln
\n\n
code1"
,
repo
,
)
with
patch_transformer_repo_path
(
tmp_folder
):
infer_tests_to_run
(
tmp_folder
/
"test-output.txt"
,
diff_with_last_commit
=
True
)
with
open
(
tmp_folder
/
"examples_test_list.txt"
,
"r"
)
as
f
:
example_tests_to_run
=
f
.
read
()
assert
example_tests_to_run
==
"examples/pytorch/test_pytorch_examples.py"
# Modification in one test example file trigger that test
repo
=
create_tmp_repo
(
tmp_folder
,
models
=
models
)
commit_changes
(
"examples/pytorch/test_pytorch_examples.py"
,
"""test_args = "run_glue.py"
\n
more_code"""
,
repo
,
)
with
patch_transformer_repo_path
(
tmp_folder
):
infer_tests_to_run
(
tmp_folder
/
"test-output.txt"
,
diff_with_last_commit
=
True
)
with
open
(
tmp_folder
/
"examples_test_list.txt"
,
"r"
)
as
f
:
example_tests_to_run
=
f
.
read
()
assert
example_tests_to_run
==
"examples/pytorch/test_pytorch_examples.py"
def
test_parse_commit_message
(
self
):
def
test_parse_commit_message
(
self
):
assert
parse_commit_message
(
"Normal commit"
)
==
{
"skip"
:
False
,
"no_filter"
:
False
,
"test_all"
:
False
}
assert
parse_commit_message
(
"Normal commit"
)
==
{
"skip"
:
False
,
"no_filter"
:
False
,
"test_all"
:
False
}
...
...
utils/tests_fetcher.py
View file @
b8935980
...
@@ -533,6 +533,9 @@ def init_test_examples_dependencies():
...
@@ -533,6 +533,9 @@ def init_test_examples_dependencies():
test_example_deps
[
str
(
test_file
.
relative_to
(
PATH_TO_REPO
))]
=
[
test_example_deps
[
str
(
test_file
.
relative_to
(
PATH_TO_REPO
))]
=
[
str
(
e
.
relative_to
(
PATH_TO_REPO
))
for
e
in
examples
if
e
.
name
in
content
str
(
e
.
relative_to
(
PATH_TO_REPO
))
for
e
in
examples
if
e
.
name
in
content
]
]
test_example_deps
[
str
(
test_file
.
relative_to
(
PATH_TO_REPO
))].
append
(
str
(
test_file
.
relative_to
(
PATH_TO_REPO
))
)
return
test_example_deps
,
all_examples
return
test_example_deps
,
all_examples
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment