NL iBVdZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZddlmZddlmZdd lmZmZdd lmZdd lmZmZdd lm Z dd l!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2gdZ3e jhdk\re3jkde jhdk\re3jkddZ6dZ7d&dZ8ejrd'dZ:Gdde.Z;Gdde;Z<Gd d!e;Z=Gd"d#e;Z>d(d$Z?d)d%Z@y)*z6Test cases for building an C extension and running it.) annotationsN)Iterator)Any)build) CompileError)Options)mypyc_output_dir test_temp_dir)DataDrivenTestCase)assert_module_equivalenceperform_file_operations)construct_groups) emitmodule)Errors)CompilerOptions)test_data_prefix)check_serialization_roundtrip)ICODE_GEN_BUILTINS TESTUTIL_PATHMypycDataSuiteassert_test_outputfudge_dir_mtimesshow_cuse_custom_builtins)$zrun-async.testz run-misc.testzrun-functions.testzrun-integers.testz run-i64.testz run-i32.testz run-i16.testz run-u8.testrun-floats.testz run-math.testzrun-bools.testzrun-strings.testzrun-bytes.testzrun-tuples.testzrun-lists.testzrun-dicts.testz run-sets.testzrun-primitives.testzrun-loops.testzrun-exceptions.testzrun-imports.testzrun-classes.testzrun-traits.testzrun-generators.testzrun-generics.testrun-multimodule.testzrun-bench.testrun-mypy-sim.testrun-dunders.testzrun-dunders-special.testzrun-singledispatch.testzrun-attrs.testzrun-signatures.testzrun-weakref.testzrun-python37.testzrun-python38.test) zrun-match.testr zrun-python312.testa from setuptools import setup from mypyc.build import mypycify setup(name='test_run_output', ext_modules=mypycify({}, separate={}, skip_cgen_input={!r}, strip_asserts=False, multi_file={}, opt_level='{}', install_native_libs={}), ) rctjj}d|i} |tjd<|tjddt|d5}t |j |ddd|t_y#1swYxYw#|t_wxYw#t $r?}|jdk(rt||jdk(xs|jducYd}~Sd}~wwxYw)aRun a setup script in a somewhat controlled environment. This is adapted from code in distutils and our goal here is that is faster to not need to spin up a python interpreter to run it. We had to fork it because the real run_setup swallows errors and KeyboardInterrupt with no way to recover them (!). The real version has some extra features that we removed since we weren't using them. Returns whether the setup succeeded. __file__rNrb interruptedT) sysargvcopyopenexecread SystemExitcodeKeyboardInterrupt) script_name script_args save_argvgfes Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/test/test_run.py run_setupr8`s I [!A- !%CHHQK&CHHQRLk4( "AQVVXq! "!CH  " "!CH - 66] "# *vv{,affn,-sG2BB2B: B"B B BB"" C*+4C%C*%C*c#Ktj}tj| dtj|y#tj|wxYww)N)osgetcwdchdir)targetdirs r7 chdir_managerr?s; ))+CHHV    s*A!AA!AA!cHeZdZdZeZeZdZdZdZ dZ d dZ d dZ d dZ d dZy) TestRunz1Test cases that build a C extension and run code.TFcttjj|jt |5t d5|j|ddddddy#1swYxYw#1swYyxYw)Ntmp)rr:pathjoin data_prefixrr?run_case_inner)selftestcases r7run_casezTestRun.run_casesg  T-=-=?Q RT\ ] * %  *    )  * * * * * *s# A4A(A4(A1 -A44A=ctjjtstjtdj |j }tddd5}|j|dddtddd5}|j|dddtjtdd}|j|||j}|ggk(rg}|D]]}ttd tj d |dz }t#d 5t%|ddd|j||_y#1swYxYw#1swYxYw#1swY6xYw) N native.pywutf-8encodingzinterpreted.pyz testutil.pyr%g?z..)r:rDisdirWORKDIRmkdirrEinputr+writeshutilcopyfiler run_case_step find_stepsrtimesleepr?r )rHrItextr5stepsteps operationss r7rGzTestRun.run_case_inners4ww}}W% HHW yy( +sW 5  GGDM  "C' : a GGDM   }5 8T*##% RD=E /J Wb ) JJsO AIDt$ 4' 3 4   x . /    . 4 4s$&EE( E)EE&)E2 c |jjddxrd|jv}t}d|_d|_d|_tjdd|_ d|_ d|_ d|_ |j|_ddi|jd<t!j"d d d}|g}d g}d g}g} |j$D]J\} } t&j(j+| t,} t&j(j/| j1d sZ| j3d sl| j5d dj7t&j8d } |j;| |j;t!j"| | d| j;| |j;| t=j>| t&j(jAt&j(jC| | dzM|D]+}d|jjE|jFid<-|jr+|jIdjA|jJ|nd} tM|| tO|dkDd}d|jv} tQ|jR|j|jT|}tWjX||||d }t[|}tWj\||||\}}}|j^r|jaJd |dk(r to|tqt&jrjudd}t&j(jwt&j(jAtxd}t{|dd5}|j}t~j|| ||jR||dddt|ddgs<|jjdr t|ttJd tjd!k(rd"nd#}tjd$|stjd%|sJd&}t&j(j|s;t&j(jAtd'd&}t=j||t&jrj}|rd(nd)|d*<|jjd+}|rl|d,k(r*tjd,d-tj|g|.n6|d/k(r*tjd/d0tj|g|.nJd1Jd2tjtj|gtjtj|3} tjd4k\r| jd56| jdjd7}!|!j7d8t'jt&j8d8}!|!j}"|jjdr t|| jdk7rtg| jd9k(}#d:}$|#rd;}$tgd<| j|$|#rftjj1d=sGtgtjd>k(rd,}nd/}tgd?|d@tgdAtgdBtt|rtgdCtg|!nt|dk(rdD}%|j}&n"dE|dF}%|jju|g}&|&s.|"Dcgc]#}ti||jj|jl%}"}t||"|%|&|dkDr|jr|dk(rd:n t|dz }|jju|dz }'|'$tdG|z|'|jj|jju|dz }(|($tdH|z|(|jj| jdk(sJy#tb$rG}|jdD],}tgti||jj|jl.Jdd}~wwxYw#1swYxYwcc}w)INz--benchF BenchmarkTfollow_importserrorz unchecked.*rMnativeotherz.py.rz_interpreted.pymypycrLr% _native_libs) multi_fileseparatestrict_dunder_typingdepends_on_native_internal)sourcesoptionscompiler_optionsgroups alt_lib_path)rrerrorsrsz Compile errorMYPYC_OPT_LEVELzsetup.pyrNrOrP build_extz --inplacez --mypyc-showczCompilation failedwin32pydsoz native.*.znative.z driver.pydriver10MYPYC_RUN_BENCHdebuggerlldbz--)envgdbz--argszUnsupported debuggerzaTest can't pass in debugging mode. (Make sure to pass -s to pytest to interact with the debugger))stdoutstderrrr!)timeoututf8z File "iz (likely segmentation fault)z*** Exit status: windarwinz'hint: Use "pytest -n0 -s --mypyc-debug=z- -k " to run test in debuggerzFhint: You may need to build a debug version of Python first and use itz>hint: See also "Debugging Segfaults" in mypyc/doc/dev-intro.mdz Test output:zInvalid outputzInvalid output (step ) recheckedstale)`config getoptionnameruse_builtins_fixturesshow_tracebackstrict_optionalr( version_infopython_version export_types preserve_astsallow_empty_bodiesrm incrementalper_module_optionsr BuildSourcefilesr:rDrelpathr basename startswithendswithsplitreplacesepappendrXrYrEdirname setdefaultmodule get_separaterVrlenrrlrnrparse_and_typecheckrcompile_modules_to_c num_errors flush_errorsrmessagesprintfix_native_line_numberfilelinerintenvirongetabspathrTr+rW setup_formatformatr8rcopy_output_filesr platformglobisfilerr* subprocess check_call executablePopenPIPESTDOUTwait communicatedecoder; splitlines returncodeoutputoutput2rstrexpected_rechecked_modulesr managerrechecked_modulesexpected_stale_modules stale_modules))rHrIincremental_stepbenchrqsourcerp module_names module_paths to_deletefnr^rrmrs native_libsrrresultruircfiles_r6r opt_level setup_filer5suffix driver_pathdefault_driverrrprocroutlinessignalextramsgexpectedexpected_recheckedexpected_stales) r7rZzTestRun.run_case_steps)))U;\ x}}@\)(,%!%"&!$!1!1"1!5# $%)""mm6Fw4O""=1"";$?( z #}    aHB]3Bww#..w7BKK%>+6     33!1 FG_F&;;)9&QWMB  ##%-o-u! q )" - '8!<= WW__RWW\\':%FG *cG 4  GG## (FDOOYP[  k;%?@((9v . / .. .5,,'1tyy9VH-.$))gfX ?cll55e<<<8+%H$H=hZGtu^_VW . /  . ! &M1$&#??-.>-?qA#++//0@"E\dSW*4 N x3 A a G$7$7+q0Rc:JQ:N6OF!)!D!D!H!HIY\]I]!^ !-)&(*^>^&<<@@AQTUAUVN))f$nfnn6R6R!###w *  R,T8==(--PQ R )/ )5 *  vs,)Bb$4c7,(d$ c4-Ac//c47dc,d}tj|j||tj}|s5tj|jd|tj}|r$t j |j dSy)Nz# separate{}: (\[.*\])$)flagsrr%T)researchr MULTILINEast literal_evalgroup)rH program_textrtemplatems r7rzTestRun.get_separatesh- IIhoo&67R\\ Z (//"-|2<<PA ##AGGAJ/ /N)rIr returnNone)rIr rrrr)rrrrrr)__name__ __module__ __qualname____doc__rr base_path optional_outrlrmrnrJrGrZrrr7rArAs;; EILJH *!/F@$DrrAc eZdZdZdZdZddgZy)TestRunMultiFilezRun the main multi-module tests in multi-file compilation mode. In multi-file mode each module gets compiled into a separate C file, but all modules (C files) are compiled together. T_multirrN)rrrrrltest_name_suffixrrrr7rrs J #%8 9Errc eZdZdZdZdZddgZy)TestRunSeparateaYRun the main multi-module tests in separate compilation mode. In this mode there are multiple compilation groups, which are compiled incrementally. Each group is compiled to a separate C file, and these C files are compiled separately. Each compiled module is placed into a separate compilation group, unless overridden by a special comment. Consider this example: # separate: [(["other.py", "other_b.py"], "stuff")] This puts other.py and other_b.py into a compilation group named "stuff". Any files not mentioned in the comment will get single-file groups. T _separaterrN)rrrrrmrrrrr7rrs H" #%8 9Errc eZdZdZdZdZddgZy)TestRunStrictDunderTypingz(Run the tests with strict dunder typing.T_dunder_typingrrN)rrrrrnrrrrr7rrs2' !2 3Errctjjtjdfd|}tjdfd|}|S)apUpdate code locations in test case output to point to the .test file. The description of the test case is written to native.py, and line numbers in test case output often are relative to native.py. This translates the line numbers to be relative to the .test file that contains the test case description, and also updates the file name to the .test file name. Args: message: message to update fnam: path of the .test file delta: line number of the beginning of the test case in the .test file Returns updated message (or original message if we couldn't find anything). znative\.py:([0-9]+):cHdt|jdzfzS)Nz%s:%d:r%rrrdeltafnams r7z(fix_native_line_number..s"8tS_u=T6U+Urz"native.py", line ([0-9]+),cHdt|jdzfzS)Nz"%s", line %d,r%r r s r7rz(fix_native_line_number..s#"dC Oe,C%DDr)r:rDrrsub)messager r s ``r7rrsP 77  D !Dff!UW^Gff&DG Nrc tj|tjdD]}t j ||t jjd|dy#t$rYywxYw)Nz build/*.[ch]z Generated files: z (for first failure only) ) r:rUOSErrorrrXr*r(rrW) target_dirr s r7rrsp   .)& D*%&JJ*:,6STU  sA++ A76A7)r1rr2z list[str]rbool)r=rrzIterator[None])rrr rr rrr)rrrr)Ar __future__rr contextlibros.pathr:rrXrr(r\collections.abcrtypingrmypyr mypy.errorsr mypy.optionsrmypy.test.configr r mypy.test.datar mypy.test.helpersr r mypyc.buildr mypyc.codegenr mypyc.errorsr mypyc.optionsrmypyc.test.configrmypyc.test.test_serializationrmypyc.test.testutilrrrrrrrrrrrrTr8contextmanagerr?rArrrrrrrr7r)s <"    $$ <-P($).G% Nw LL!"w LL%&   F @n@F :w ::g:*446 Vr