ML ipEPdZddlmZddlZddlZddlZddlZddlmZddl Z ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddl m!Z!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+dZ,Gdde"Z-ddZ.Gddej^Z0y)aTest cases for fine-grained incremental checking. Each test cases runs a batch build followed by one or more fine-grained incremental steps. We verify that each step produces the expected output. See the comment at the top of test-data/unit/fine-grained.test for more information. N.B.: Unlike most of the other test suites, testfinegrained does not rely on an alt_lib_path for finding source files. This means that they can test interactions with the lib_path that is built implicitly based on specified sources. ) annotationsN)Any)build)parse_config_file)Server)DEFAULT_STATUS_FILE) CompileError)create_source_list) BuildSource)Options)check_consistency#sort_messages_preserving_file_order) test_temp_dir)DataDrivenTestCase DataSuite DeleteFile UpdateFile)assert_module_equivalenceassert_string_arrays_equalassert_target_equivalencefind_test_files parse_optionsperform_file_operationsFceZdZeddgZdZddZddZddZddZ dd Z dd Z dd Z dd Z dd ZddZddZddZddZy)FineGrainedSuitezfine-grained*.testz#fine-grained-cache-incremental.test)patternexcludeFc|jr0|jdk(ry|jr|jddk7ryy|jdk(ryy)Nz-only_when_nocacheTr==z-only_when_cacheF) use_cache only_whenoutput)selftestcases _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypy/test/testfinegrained.py should_skipzFineGrainedSuite.should_skip;sU >>!!%998??1#5#=!!%77c |j|rtjdj|j}t j jtd}t|dd5}|j|ddd|j||d}|jtjkDrtjd|j||d }t|t}|j!|}d } |j#|| |} | |kr|j%|| } n|j'|| } g} | r| j)t+| |j,J| j)|j/| |||j,| j)|j1| |||j2rt4rt7|j2|j9} g}| D]U}| d z } |j;||||||| |\}}| j=d | j)||j)|W| Dcgc]}|j?d d } }tA|jB| d|jDd|jFd|jHrBtA|jH|jK|d|jDd|jFdyy#1swYrxYwcc}w)N mainwutf8)encodingF) build_cachez)Test case requires a newer Python versionTr \/zInvalid output (z, line )zInvalid active triggers ()&r'pytestskipjoininputospathropenwrite get_optionspython_versionsys version_inforrget_build_steps parse_sourcesr run_checkextendnormalize_messagestmpdir maybe_suggest maybe_inspectfine_grained_managerCHECK_CONSISTENCYr find_steps perform_stepappendreplacerr#fileline triggeredformat_triggered)r$r%main_src main_pathfoptions build_optionsservernum_regular_incremental_stepsstepsourcesmessagesasteps all_triggered operationsr#rPrOs r&run_casezFineGrainedSuite.run_caseKs   H % KKM99X^^,GGLL7 )S6 2 a GGH  ""8X5"I  ! !C$4$4 4 KKC D((8(N !45(,(<(z.FineGrainedSuite.get_options..sr()r incrementaluse_builtins_fixturesshow_traceback error_summaryfine_grained_incrementalr!use_fine_grained_cachecache_fine_grainedlocal_partial_typesrN export_typesnameendswithallow_empty_bodiesresearchfollow_importsfilesr)r$sourcer%r/rUrr_s r&r<zFineGrainedSuite.get_optionss1E"(,%!% %/:?()-)K O&%)^^"&*#(HMM9)1)?)? )L%L" 99/ 8 @%,G "~~ GD!T!%5%=!'<>   r(c|j|ddd}|dxs|d}t|tsJ|jS)NF)rqis_ttyterminal_widthouterr)check isinstancestr splitlines)r$rWrZresponsers r&rBzFineGrainedSuite.run_checksH<<eEZ\<]uo0%#s###~~r(c tj||}|jS#t$r}|jcYd}~Sd}~wwxYw)N)rZrU)rr r[errors)r$rUrZresultes r&rzFineGrainedSuite.builds? [['BF}} ::  s% A ?AAcg}t|D]g\}}|Dcgc]}|jdr|}}t|}|jd|dzdj |fzj i|Scc}w)Nz__>z%d: %sz, ) enumeraterssortedrLr6strip)r$rPrntriggerstriggerfiltereds r&rQz!FineGrainedSuite.format_triggereds$Y/ MKAx/7WGw?O?OPU?VWHWh'H MM8q1udii.A&BBIIK L M Xs A:A:c|jsytjd|tj}|t |j dSy)zHGet the number of regular incremental steps to run, from the test sourcerz# num_build_steps: ([0-9]+)$flagsr0)r!rurv MULTILINEintgroup)r$ program_textms r&r@z FineGrainedSuite.get_build_stepss=~~ II4l",, W =qwwqz? "r(c &t||j|||} ||kr|j|| } n|j|| } g} g} g} g}|jrt rt |j|j|jj|jj} |jjDcgc]\}}| } }}|jj} |jj|dz }|tdt|dz z|| |j j|dz }|tdt|dz z|| |j"j|}|rt%dt|z|| t'| } | }|j(J|j+|j-||||j(|j+|j/|||||fScc}}w)zPerform one fine-grained incremental build step (after some file updates/deletions). Return (mypy output, triggered targets). r0stale recheckedtargets)rrArrBrHrIr rLrPupdated_moduleschanged_modulesprocessed_targetsexpected_stale_modulesgetrrexpected_rechecked_modulesexpected_fine_grained_targetsrrDrErCrFrG)r$r_rWrUrVr%rRrYrXrZ new_messagesupdatedchangedrrPmodrNexpected_staleexpected_recheckedexpectedr\s r&rKzFineGrainedSuite.perform_steps +$$XtW= 0 0::mW=L>>&':L  & & !&"="=>   V88BB C11AAG,2,G,G,W,WXysDsXGX11CCG!88<FZZZZ243GRVZ TNW    r(cxgd}gd}ddg}t||z|||zk(sJt||z|||zk(sJy)N)rzand message continues (x: y)z 1()z ^~~)zfoo/y.py: In function "f":rzand again message continuesrrr)r$msg1msg2rs r&test_long_form_sortingz)TestMessageSorting.test_long_form_sortingsY    9:]^24$;ITTX[XXX24$;ITTX[XXXr(ctd}d}d}gd}t|||g||||gk(sJt|||g||||gk(sJy)Nrz foo/y:123: note: "X" not definedz&mypy: Error not associated with a file)zmypy: Something wrongzfoo/y:12: note: "Y" not definedrr)r$rrmsg3rs r&test_mypy_error_prefixz)TestMessageSorting.test_mypy_error_prefixs|317  3D$3ExP   U    3D$3ExP   U    r(c|d}d}d}d}ddg}t|||g||||gk(sJt||||g|||||gk(sJy)Nrrzab.py:3: error: Problem: errorzaaa:3: error: Badrrr)r$rrnew1new2rs r&test_new_file_at_the_endz+TestMessageSorting.test_new_file_at_the_ends24/"8:]^2D$3ExP   U    3D$d3KXV     [    r(N)rr)rrrrrrrrgr(r&rrys Y" , r(r)r[rrr)1__doc__ __future__rr8rur>unittesttypingrr4mypyrmypy.config_parserrmypy.dmypy_serverrmypy.dmypy_utilr mypy.errorsr mypy.find_sourcesr mypy.modulefinderr mypy.optionsr mypy.server.mergecheckr mypy.server.updatermypy.test.configrmypy.test.datarrrrmypy.test.helpersrrrrrrrIrrDTestCaserrgr(r&rs #  0$/$0) 4B*PP@y@F U@ **@ r(