<s> __author__ = '<STR_LIT>' <EOL> __copyright__ = '<STR_LIT>' <EOL> __license__ = '<STR_LIT>' <EOL> import os <EOL> import shutil <EOL> from glob import glob <EOL> from os . path import exists , join as pjoin , dirname , basename <EOL> from nose . tools import ok_ , eq_ <EOL> from numpy . testing import assert_array_equal <EOL> def test_benchmarkrunner ( ) : <EOL> from vbench . api import BenchmarkRunner <EOL> from suite import * <EOL> shutil . rmtree ( TMP_DIR ) <EOL> if exists ( DB_PATH ) : <EOL> os . unlink ( DB_PATH ) <EOL> ok_ ( not exists ( DB_PATH ) ) <EOL> runner = BenchmarkRunner ( benchmarks , REPO_PATH , REPO_URL , <EOL> BUILD , DB_PATH , TMP_DIR , PREPARE , <EOL> clean_cmd = CLEAN , <EOL> run_option = '<STR_LIT:all>' , run_order = '<STR_LIT>' , <EOL> start_date = START_DATE , <EOL> module_dependencies = DEPENDENCIES ) <EOL> revisions_to_run = runner . _get_revisions_to_run ( ) <EOL> eq_ ( len ( revisions_to_run ) , <NUM_LIT:4> ) <EOL> revisions_ran = runner . run ( ) <EOL> assert_array_equal ( [ x [ <NUM_LIT:0> ] for x in revisions_ran ] , <EOL> revisions_to_run ) <EOL> eq_ ( revisions_ran [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , ( False , <NUM_LIT:3> ) ) <EOL> eq_ ( revisions_ran [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , ( True , <NUM_LIT:3> ) ) <EOL> ok_ ( exists ( TMP_DIR ) ) <EOL> ok_ ( exists ( DB_PATH ) ) <EOL> eq_ ( len ( runner . blacklist ) , <NUM_LIT:0> ) <EOL> revisions_ran = runner . run ( ) <EOL> for rev , v in revisions_ran : <EOL> eq_ ( v , ( False , <NUM_LIT:0> ) ) <EOL> runner . benchmarks = collect_benchmarks ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> revisions_ran = runner . run ( ) <EOL> eq_ ( revisions_ran [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , ( False , <NUM_LIT:1> ) ) <EOL> for rev , v in revisions_ran [ <NUM_LIT:1> : ] : <EOL> eq_ ( v , ( True , <NUM_LIT:1> ) ) <EOL> revisions_ran = runner . run ( ) <EOL> for rev , v in revisions_ran : <EOL> eq_ ( v , ( False , <NUM_LIT:0> ) ) <EOL> from vbench . reports import generate_rst_files <EOL> rstdir = pjoin ( TMP_DIR , '<STR_LIT>' ) <EOL> generate_rst_files ( runner . benchmarks , DB_PATH , rstdir , """<STR_LIT>""" ) <EOL> image_files = [ basename ( x ) for x in glob ( pjoin ( rstdir , '<STR_LIT>' ) ) ] <EOL> target_image_files = [ b . name + '<STR_LIT>' for b in runner . benchmarks ] <EOL> eq_ ( set ( image_files ) , set ( target_image_files ) ) <EOL> rst_files = [ basename ( x ) for x in glob ( pjoin ( rstdir , '<STR_LIT>' ) ) ] <EOL> target_rst_files = [ b . name + '<STR_LIT>' for b in runner . benchmarks ] <EOL> eq_ ( set ( rst_files ) , set ( target_rst_files ) ) <EOL> module_files = [ basename ( x ) for x in glob ( pjoin ( rstdir , '<STR_LIT>' ) ) ] <EOL> target_module_files = list ( set ( [ '<STR_LIT>' + b . module_name + '<STR_LIT>' for b in runner . benchmarks ] ) ) <EOL> eq_ ( set ( module_files ) , set ( target_module_files + [ '<STR_LIT>' ] ) ) <EOL> shutil . rmtree ( TMP_DIR ) <EOL> shutil . rmtree ( dirname ( DB_PATH ) ) </s>
