B ۋ\@sddlZddlZddlZddlZddlZddlZddlZddlZdddZddddddZ dd d Z d d Z d dZ ddZ ddZdS)N.cCs|dk r tj}|||}t|dd|tj|tjtj ||d}t|j d|dk r|j |kst d|j n|j |j dfS|j dS)z Helper function to run a shell command and report success/failure depending on the exit status of the shell command. Nz >  )stdoutstderrcwdenvzutf-8zGot unexpected return code {})osenvironcopyupdateprintjoin subprocessrunPIPESTDOUTrdecode returncodeAssertionErrorformat)Zcommand working_dirrexpected_returncodeZenv_resultr@szmake..)rrr)rnameupperreplacerritems)rrrargskwargsZ make_commandZenvvarrrrr!+s  $r!%This test is not supported on Windowscsfdd}|S)Ncs,t|fdd}tjdkr$|S|SdS)NcstdS)N)unittestSkipTest)r*r+)messagerr skip_windowsKsz3skip_windows..wrapper..skip_windowsr) functoolswrapsrr&)fr0)r/rrwrapperJs zskip_windows..wrapperr)r/r4r)r/rr0Is r0cstfdd}|S)Ncs8dtjkr.dtjkr.tjddkr.td||S)NCIZRUN_SLOWZTRAVIS_EVENT_TYPEZcronzSlow test skipped on CI run)rr getr-r.)r*r+)r3rrr4Vs zslow_test..wrapper)r1r2)r3r4r)r3r slow_testUsr7cCs`t|}|r|S|dkr$tjdks.dtjkrNtd|tj dksFdndt d|d S) z Checks if a command is available. If a command MUST be available, because we are in a CI environment, raises an AssertionError. In the docker containers, on Travis and on Windows, CI=true is set. z clang-tidydarwinr5z;{} is not available on PATH. Install it to run this test.{}rr z'On Windows, make sure to add it to PATHz{} not available on CIN) shutilwhichsysplatformrr r-r.rr&r) executablepathrrrensure_available_s  r?c Osdtjkr*|tjddkr*dSdtjkrT|tjddkrTdSt|tjrh|j}nt|tjrz|}ndSdtjkr|j tjddkrdSdtjkr|j tjddkrdSdtjkr|j tjddkrdSd tjkr6|j tjd dkr6dSd tjkrt d dk rt jd d d dgt jt jdd}|jdkrdSxR|jdD]>}|d}|ddkr|ddkr|ddkrdSqWt jd dddgt jt jd}|jdks td|jx|jdD]|} | ds^| ds^| tjd d!s^td"dS| |jd#d$rvdS| tjd d!|j rdSqWdSdS)%NZPQCLEAN_ONLY_TESTS,FZPQCLEAN_SKIP_TESTSTZPQCLEAN_ONLY_TYPESZPQCLEAN_SKIP_TYPESZPQCLEAN_ONLY_SCHEMESZPQCLEAN_SKIP_SCHEMESZPQCLEAN_ONLY_DIFFZgitstatusz --porcelain=2z--branchz..)rrrrzutf-8r#z branch.headZmasterdiffz --name-onlyz origin/master)rrzGot unexpected return code {}Z crypto_kemZ crypto_signtestZduplicate_consistencyz9Running all tests as there are changes outside of schemesr )base)rr lowersplit isinstancepqcleanImplementationschemeSchemetyper&r9r:rrrrrrr splitlinesrr startswithr>r logginginfo) Ztestnamethingr*r+rMZ branch_resultZ branch_linetokensZ diff_resultZ diff_linerrr permit_testwsn                     rVcs.jtddtfdd}|S)NZcheck_cs(tf||r||StddS)NzTest disabled by filter)rVr-r.)r*r+)funcfuncnamerrr4s zfiltered_test..wrapper)__name__lenr1r2)rWr4r)rWrXr filtered_testsr[)rNr)r,)r1rrr-r9r;rKrRrr!r0r7r?rVr[rrrrs   K