Skip to content
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 instructions to codegen test failures #582

Merged
merged 3 commits into from
Jan 5, 2022

Conversation

stroxler
Copy link
Contributor

@stroxler stroxler commented Jan 5, 2022

Summary

It's nice that the tests warn us if you need to rerun code generation, but we don't actually document how to run code generation anywhere so every time I hit the failures I get frustrated trying to remember!

I thought about adding it to the README but I'm not actually sure it adds any value - instead, why not add it to the relevant failures. That way the codegen instructions aren't adding noise to the general getting-started docs, but they are right there whenever we need them.

Test Plan

In a branch where I added lpar and rpar to With statements, I ran

> python -m unittest libcst.codegen.tests.test_codegen_clean
FFF
======================================================================
FAIL: test_codegen_clean_matcher_classes (libcst.codegen.tests.test_codegen_clean.TestCodegenClean)
Verifies that codegen of matcher classes would not result in a
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/stroxler/kode/LibCST/libcst/codegen/tests/test_codegen_clean.py", line 95, in test_codegen_clean_matcher_classes
    self.assert_code_matches(old_code, new_code, "libcst.matchers.__init__")
  File "/Users/stroxler/kode/LibCST/libcst/codegen/tests/test_codegen_clean.py", line 25, in assert_code_matches
    self.assertTrue(
AssertionError: False is not true : libcst.matchers.__init__ needs new codegen, see `python -m libcst.codegen.generate --help` for instructions

======================================================================
FAIL: test_codegen_clean_return_types (libcst.codegen.tests.test_codegen_clean.TestCodegenClean)
Verifies that codegen of return types would not result in a
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/stroxler/kode/LibCST/libcst/codegen/tests/test_codegen_clean.py", line 128, in test_codegen_clean_return_types
    self.assert_code_matches(old_code, new_code, "libcst.matchers._return_types")
  File "/Users/stroxler/kode/LibCST/libcst/codegen/tests/test_codegen_clean.py", line 25, in assert_code_matches
    self.assertTrue(
AssertionError: False is not true : libcst.matchers._return_types needs new codegen, see `python -m libcst.codegen.generate --help` for instructions

======================================================================
FAIL: test_codegen_clean_visitor_functions (libcst.codegen.tests.test_codegen_clean.TestCodegenClean)
Verifies that codegen of visitor functions would not result in a
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/stroxler/kode/LibCST/libcst/codegen/tests/test_codegen_clean.py", line 63, in test_codegen_clean_visitor_functions
    self.assert_code_matches(old_code, new_code, "libcst._typed_visitor")
  File "/Users/stroxler/kode/LibCST/libcst/codegen/tests/test_codegen_clean.py", line 25, in assert_code_matches
    self.assertTrue(
AssertionError: False is not true : libcst._typed_visitor needs new codegen, see `python -m libcst.codegen.generate --help` for instructions

----------------------------------------------------------------------
Ran 3 tests in 40.231s

FAILED (failures=3)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 5, 2022
@zsol
Copy link
Member

zsol commented Jan 5, 2022

I normally run tox -e codegen if I'm not in a hurry, I'd recommend that to new folks. Great idea btw!

@codecov-commenter
Copy link

Codecov Report

Merging #582 (02e82df) into main (d9a1dc8) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #582   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files         241      241           
  Lines       24658    24660    +2     
=======================================
+ Hits        23360    23362    +2     
  Misses       1298     1298           
Impacted Files Coverage Δ
libcst/codegen/tests/test_codegen_clean.py 89.09% <100.00%> (+0.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9a1dc8...02e82df. Read the comment docs.

@stroxler stroxler merged commit 601db54 into Instagram:main Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants