<s> from __future__ import unicode_literals <EOL> import functools <EOL> import os <EOL> import re <EOL> from rpaths import Path , unicode <EOL> import sqlite3 <EOL> import subprocess <EOL> import sys <EOL> import yaml <EOL> from reprounzip . unpackers . common import join_root <EOL> from reprounzip . utils import PY3 , stderr_bytes , stderr , download_file <EOL> tests = Path ( __file__ ) . parent . absolute ( ) <EOL> def in_temp_dir ( f ) : <EOL> @ functools . wraps ( f ) <EOL> def wrapper ( * args , ** kwargs ) : <EOL> tmp = Path . tempdir ( prefix = '<STR_LIT>' ) <EOL> try : <EOL> with tmp . in_dir ( ) : <EOL> return f ( * args , ** kwargs ) <EOL> finally : <EOL> tmp . rmtree ( ignore_errors = True ) <EOL> return wrapper <EOL> def print_arg_list ( f ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( f ) <EOL> def wrapper ( arglist , * args , ** kwargs ) : <EOL> print ( "<STR_LIT>" + <EOL> "<STR_LIT:U+0020>" . join ( a if isinstance ( a , unicode ) <EOL> else a . decode ( '<STR_LIT:utf-8>' , '<STR_LIT:replace>' ) <EOL> for a in arglist ) ) <EOL> return f ( arglist , * args , ** kwargs ) <EOL> return wrapper <EOL> @ print_arg_list <EOL> def call ( args ) : <EOL> r = subprocess . call ( args ) <EOL> print ( "<STR_LIT>" % r ) <EOL> return r <EOL> @ print_arg_list <EOL> def check_call ( args ) : <EOL> return subprocess . check_call ( args ) <EOL> @ print_arg_list <EOL> def check_output ( args , stream = '<STR_LIT>' ) : <EOL> if stream == '<STR_LIT>' : <EOL> kw = { '<STR_LIT>' : subprocess . PIPE } <EOL> elif stream == '<STR_LIT>' : <EOL> kw = { '<STR_LIT>' : subprocess . PIPE } <EOL> else : <EOL> raise ValueError <EOL> p = subprocess . Popen ( args , ** kw ) <EOL> if stream == '<STR_LIT>' : <EOL> fp = p . stdout <EOL> else : <EOL> fp = p . stderr <EOL> output = [ ] <EOL> while True : <EOL> line = fp . readline ( ) <EOL> if not line : <EOL> break <EOL> stderr_bytes . write ( line ) <EOL> output . append ( line ) <EOL> retcode = p . wait ( ) <EOL> if retcode != <NUM_LIT:0> : <EOL> raise subprocess . CalledProcessError ( retcode , args ) <EOL> return b'<STR_LIT>' . join ( output ) <EOL> def build ( target , sources , args = [ ] ) : <EOL> check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , target ] + <EOL> [ ( tests / s ) . path <EOL> for s in sources ] + <EOL> args ) <EOL> @ in_temp_dir <EOL> def functional_tests ( raise_warnings , interactive , run_vagrant , run_docker ) : <EOL> rpz_python = [ os . environ . get ( '<STR_LIT>' , sys . executable ) ] <EOL> rpuz_python = [ os . environ . get ( '<STR_LIT>' , sys . executable ) ] <EOL> if raise_warnings : <EOL> rpz_python . extend ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> rpuz_python . extend ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in os . environ : <EOL> rpz_python . extend ( [ '<STR_LIT>' ] + os . environ [ '<STR_LIT>' ] . split ( '<STR_LIT:U+0020>' ) ) <EOL> rpuz_python . extend ( [ '<STR_LIT>' ] + os . environ [ '<STR_LIT>' ] . split ( '<STR_LIT:U+0020>' ) ) <EOL> reprozip_main = tests . parent / '<STR_LIT>' <EOL> reprounzip_main = tests . parent / '<STR_LIT>' <EOL> verbose = [ '<STR_LIT>' ] * <NUM_LIT:3> <EOL> rpz = rpz_python + [ reprozip_main . absolute ( ) . path ] + verbose <EOL> rpuz = rpuz_python + [ reprounzip_main . absolute ( ) . path ] + verbose <EOL> print ( "<STR_LIT>" % ( rpz , rpuz ) ) <EOL> output = check_output ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> assert any ( b'<STR_LIT>' in l <EOL> for l in output . splitlines ( ) ) <EOL> output = check_output ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> assert any ( b'<STR_LIT>' in l <EOL> for l in output . splitlines ( ) ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:-c>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:-c>' , '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:-c>' , '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> sudo = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def check_simple ( args , stream , infile = <NUM_LIT:1> ) : <EOL> output = check_output ( args , stream ) . splitlines ( ) <EOL> try : <EOL> first = output . index ( b"<STR_LIT>" ) <EOL> except ValueError : <EOL> stderr . write ( "<STR_LIT>" % output ) <EOL> raise <EOL> if infile == <NUM_LIT:1> : <EOL> assert output [ first + <NUM_LIT:1> ] == b"<STR_LIT>" <EOL> assert output [ first + <NUM_LIT:2> ] == b"<STR_LIT>" <EOL> else : <EOL> assert output [ first + <NUM_LIT:1> ] == b"<STR_LIT>" <EOL> assert output [ first + <NUM_LIT:2> ] == b"<STR_LIT>" <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> orig_output_location = Path ( '<STR_LIT>' ) . absolute ( ) <EOL> assert orig_output_location . is_file ( ) <EOL> with orig_output_location . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> orig_output_location . remove ( ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> conf = yaml . safe_load ( fp ) <EOL> other_files = set ( Path ( f ) . absolute ( ) for f in conf [ '<STR_LIT>' ] ) <EOL> expected = [ Path ( '<STR_LIT>' ) , ( tests / '<STR_LIT>' ) ] <EOL> assert other_files . issuperset ( [ f . resolve ( ) for f in expected ] ) <EOL> inputs_outputs = conf [ '<STR_LIT>' ] <EOL> found = <NUM_LIT:0> <EOL> for fdict in inputs_outputs : <EOL> if Path ( fdict [ '<STR_LIT:path>' ] ) . name == b'<STR_LIT>' : <EOL> assert fdict [ '<STR_LIT:name>' ] == '<STR_LIT>' <EOL> assert fdict [ '<STR_LIT>' ] == [ <NUM_LIT:0> ] <EOL> assert not fdict . get ( '<STR_LIT>' ) <EOL> found |= <NUM_LIT> <EOL> elif Path ( fdict [ '<STR_LIT:path>' ] ) . name == b'<STR_LIT>' : <EOL> assert fdict [ '<STR_LIT:name>' ] == '<STR_LIT>' <EOL> assert not fdict . get ( '<STR_LIT>' ) <EOL> assert fdict [ '<STR_LIT>' ] == [ <NUM_LIT:0> ] <EOL> found |= <NUM_LIT> <EOL> else : <EOL> assert not fdict . get ( '<STR_LIT>' ) <EOL> assert found == <NUM_LIT> <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> Path ( '<STR_LIT>' ) . remove ( ) <EOL> check_call ( rpuz + [ '<STR_LIT:info>' , '<STR_LIT>' ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> output_in_dir = join_root ( Path ( '<STR_LIT>' ) , orig_output_location ) <EOL> with output_in_dir . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> p = subprocess . Popen ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> stderr = subprocess . PIPE ) <EOL> out , err = p . communicate ( ) <EOL> assert p . poll ( ) != <NUM_LIT:0> <EOL> err = err . splitlines ( ) <EOL> assert b"<STR_LIT>" in err [ <NUM_LIT:0> ] <EOL> assert err [ <NUM_LIT:1> ] . startswith ( b"<STR_LIT>" ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> try : <EOL> output_in_chroot = join_root ( Path ( '<STR_LIT>' ) , <EOL> orig_output_location ) <EOL> check_simple ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> with output_in_chroot . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' % ( tests / '<STR_LIT>' ) ] ) <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_simple ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:2> ) <EOL> with output_in_chroot . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_simple ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> with output_in_chroot . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> p = subprocess . Popen ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> stderr = subprocess . PIPE ) <EOL> out , err = p . communicate ( ) <EOL> assert p . poll ( ) != <NUM_LIT:0> <EOL> err = err . splitlines ( ) <EOL> assert b"<STR_LIT>" in err [ <NUM_LIT:0> ] <EOL> assert err [ <NUM_LIT:1> ] . startswith ( b"<STR_LIT>" ) <EOL> finally : <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> try : <EOL> output_in_chroot = join_root ( Path ( '<STR_LIT>' ) , <EOL> orig_output_location ) <EOL> check_simple ( <EOL> sudo + rpuz_python + <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:1>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:0>' , <EOL> '<STR_LIT>' , '<STR_LIT>' % ( tests / '<STR_LIT>' ) , <EOL> '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' , <NUM_LIT:2> ) <EOL> with output_in_chroot . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> finally : <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if not ( tests / '<STR_LIT>' ) . exists ( ) : <EOL> check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:-c>' , <EOL> '<STR_LIT>' % { '<STR_LIT:d>' : tests / '<STR_LIT>' } ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] ) <EOL> print ( "<STR_LIT>" ) <EOL> try : <EOL> if run_vagrant : <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] , <EOL> '<STR_LIT>' ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' % ( tests / '<STR_LIT>' ) ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] , <EOL> '<STR_LIT>' , <NUM_LIT:2> ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] , <EOL> '<STR_LIT>' ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] ) <EOL> elif interactive : <EOL> print ( "<STR_LIT>" ) <EOL> sys . stdin . readline ( ) <EOL> finally : <EOL> if ( tests / '<STR_LIT>' ) . exists ( ) : <EOL> ( tests / '<STR_LIT>' ) . rmtree ( ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] ) <EOL> print ( "<STR_LIT>" ) <EOL> try : <EOL> if run_vagrant : <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] , <EOL> '<STR_LIT>' ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' % ( tests / '<STR_LIT>' ) ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] , <EOL> '<STR_LIT>' , <NUM_LIT:2> ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] , <EOL> '<STR_LIT>' ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> ( tests / '<STR_LIT>' ) . path ] ) <EOL> elif interactive : <EOL> print ( "<STR_LIT>" ) <EOL> sys . stdin . readline ( ) <EOL> finally : <EOL> if ( tests / '<STR_LIT>' ) . exists ( ) : <EOL> ( tests / '<STR_LIT>' ) . rmtree ( ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> print ( "<STR_LIT>" ) <EOL> try : <EOL> if run_docker : <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' % ( tests / '<STR_LIT>' ) ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:2> ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> elif interactive : <EOL> print ( "<STR_LIT>" ) <EOL> sys . stdin . readline ( ) <EOL> finally : <EOL> if Path ( '<STR_LIT>' ) . exists ( ) : <EOL> Path ( '<STR_LIT>' ) . rmtree ( ) <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> output = check_output ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert any ( b'<STR_LIT>' in l <EOL> for l in output . splitlines ( ) ) <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> output = check_output ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert any ( b'<STR_LIT>' in l <EOL> for l in output . splitlines ( ) ) <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> try : <EOL> output = check_output ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> assert output == b'<STR_LIT>' <EOL> output = check_output ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> assert any ( b'<STR_LIT>' == s . strip ( ) <EOL> for s in output . split ( b'<STR_LIT:\n>' ) ) <EOL> output = check_output ( sudo + rpuz + [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> assert output == b'<STR_LIT>' <EOL> finally : <EOL> check_call ( sudo + rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if sys . maxsize > <NUM_LIT:2> ** <NUM_LIT:32> : <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> err = check_output ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> err = err . split ( b'<STR_LIT:\n>' ) <EOL> assert not any ( b'<STR_LIT>' in l for l in err ) <EOL> assert any ( re . search ( br'<STR_LIT>' , l ) <EOL> for l in err ) <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> err = check_output ( rpz + [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> err = err . split ( b'<STR_LIT:\n>' ) <EOL> assert not any ( b'<STR_LIT>' in l for l in err ) <EOL> build ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> check_call ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> config = yaml . safe_load ( fp ) <EOL> database = Path . cwd ( ) / '<STR_LIT>' <EOL> if PY3 : <EOL> conn = sqlite3 . connect ( str ( database ) ) <EOL> else : <EOL> conn = sqlite3 . connect ( database . path ) <EOL> conn . row_factory = sqlite3 . Row <EOL> rows = conn . execute ( <EOL> '''<STR_LIT>''' ) <EOL> files = set ( Path ( r [ <NUM_LIT:0> ] ) for r in rows ) <EOL> for n in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if ( Path . cwd ( ) / n ) not in files : <EOL> raise AssertionError ( "<STR_LIT>" % ( Path . cwd ( ) / n ) ) <EOL> conn . close ( ) <EOL> for f in config . get ( '<STR_LIT>' ) : <EOL> if '<STR_LIT>' in Path ( f ) . parent . components : <EOL> raise AssertionError ( "<STR_LIT>" % <EOL> Path ( f ) ) <EOL> Path ( '<STR_LIT:a>' ) . symlink ( '<STR_LIT:b>' ) <EOL> with Path ( '<STR_LIT:b>' ) . open ( '<STR_LIT:w>' ) as fp : <EOL> fp . write ( '<STR_LIT>' % ( Path . cwd ( ) / '<STR_LIT:c>' ) ) <EOL> Path ( '<STR_LIT:b>' ) . chmod ( <NUM_LIT> ) <EOL> Path ( '<STR_LIT:c>' ) . symlink ( '<STR_LIT:d>' ) <EOL> with Path ( '<STR_LIT:d>' ) . open ( '<STR_LIT:w>' ) as fp : <EOL> fp . write ( '<STR_LIT>' ) <EOL> Path ( '<STR_LIT:d>' ) . chmod ( <NUM_LIT> ) <EOL> with Path ( '<STR_LIT:e>' ) . open ( '<STR_LIT:w>' ) as fp : <EOL> fp . write ( '<STR_LIT>' ) <EOL> Path ( '<STR_LIT:e>' ) . chmod ( <NUM_LIT> ) <EOL> out = check_output ( rpz + [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:1>' , '<STR_LIT:2>' ] ) <EOL> out = out . splitlines ( ) [ <NUM_LIT:0> ] <EOL> assert out == ( '<STR_LIT>' % ( Path . cwd ( ) / '<STR_LIT:c>' ) ) . encode ( '<STR_LIT:ascii>' ) <EOL> with Path ( '<STR_LIT>' ) . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> config = yaml . safe_load ( fp ) <EOL> other_files = set ( Path ( f ) for f in config [ '<STR_LIT>' ] <EOL> if f . startswith ( '<STR_LIT>' % Path . cwd ( ) ) ) <EOL> database = Path . cwd ( ) / '<STR_LIT>' <EOL> if PY3 : <EOL> conn = sqlite3 . connect ( str ( database ) ) <EOL> else : <EOL> conn = sqlite3 . connect ( database . path ) <EOL> conn . row_factory = sqlite3 . Row <EOL> rows = conn . execute ( <EOL> '''<STR_LIT>''' ) <EOL> opened = [ Path ( r [ <NUM_LIT:0> ] ) for r in rows <EOL> if r [ <NUM_LIT:0> ] . startswith ( '<STR_LIT>' % Path . cwd ( ) ) ] <EOL> rows = conn . execute ( <EOL> '''<STR_LIT>''' ) <EOL> executed = [ ( Path ( r [ <NUM_LIT:0> ] ) , r [ <NUM_LIT:1> ] ) for r in rows <EOL> if Path ( r [ <NUM_LIT:0> ] ) . lies_under ( Path . cwd ( ) ) ] <EOL> print ( "<STR_LIT>" % sorted ( other_files ) ) <EOL> print ( "<STR_LIT>" % opened ) <EOL> print ( "<STR_LIT>" % executed ) <EOL> assert other_files == set ( Path . cwd ( ) / p <EOL> for p in ( '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' , '<STR_LIT:e>' ) ) <EOL> assert opened == [ Path . cwd ( ) / '<STR_LIT:c>' , Path . cwd ( ) / '<STR_LIT:e>' ] <EOL> assert executed == [ ( Path . cwd ( ) / '<STR_LIT:a>' , '<STR_LIT>' ) ] <EOL> old_packages = [ <EOL> ( '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> for name , url in old_packages : <EOL> print ( "<STR_LIT>" % name ) <EOL> f = Path ( name ) <EOL> if not f . exists ( ) : <EOL> download_file ( url , f ) <EOL> check_call ( rpuz + [ '<STR_LIT:info>' , name ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , name ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , name ] ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , name , '<STR_LIT>' ] ) <EOL> check_simple ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> output_in_dir = Path ( '<STR_LIT>' ) <EOL> output_in_dir = output_in_dir . listdir ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> output_in_dir = output_in_dir / '<STR_LIT>' <EOL> with output_in_dir . open ( encoding = '<STR_LIT:utf-8>' ) as fp : <EOL> assert fp . read ( ) . strip ( ) == '<STR_LIT>' <EOL> p = subprocess . Popen ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> stderr = subprocess . PIPE ) <EOL> out , err = p . communicate ( ) <EOL> assert p . poll ( ) != <NUM_LIT:0> <EOL> err = err . splitlines ( ) <EOL> assert b"<STR_LIT>" in err [ <NUM_LIT:0> ] <EOL> assert err [ <NUM_LIT:1> ] . startswith ( b"<STR_LIT>" ) <EOL> check_call ( rpuz + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> coverage = Path ( '<STR_LIT>' ) <EOL> if coverage . exists ( ) : <EOL> coverage . copyfile ( tests . parent / '<STR_LIT>' ) </s>
