Exemplo n.º 1
0
def ctx(
):  ## create a context for all the tests - you could potentially use this to pass an obj to all test fns
    if not ctx.ran:  ## prevents reinit before each and every test fn in this module
        ## generate cfg (have to 'cd' there, because mabe '-s' ignores 'GLOBAL-outputDirectory' setting)
        ## and run mabe with defaults
        dirs = [dirname_baseline, dirname_testline]
        for eachdir in dirs:  ## loop through each of baseline and testline and generate the files for later diffing
            cd(this_repo_path)
            cd(eachdir)
            runCmdAndSaveOutput("{exe} -s".format(exe=dotSlashMabe),
                                filename='screen-settings')
            runCmdAndSaveOutput("{exe} -h".format(exe=dotSlashMabe),
                                filename='screen-help')
            runCmdAndSaveOutput("{exe} -l".format(exe=dotSlashMabe),
                                filename='screen-poploader')
            runCmdAndSaveOutput("{exe} -v".format(exe=dotSlashMabe),
                                filename='screen-version')
            runCmdAndSaveOutput("{exe}".format(exe=dotSlashMabe),
                                filename='screen-simulation')
            cd('..')  ## could also have done cd(thisdotSlashMrepo_path)
        ## FYI, could have done it the following waydotSlashMif we were up one dir in mabe_testing
        #runCmdAndSaveOutput( "{exe} -p GLOBAL-outpudotSlashMDirectory {path}".format(exe=path_baseline_exe, path=dirname_baseline), filename=dirname_baseline+'screen-simulation' )
        ctx.ran = True

    yield None  ## could have actually passed a context object here to all the test fns
    ##
    ## teardown happens after the last test in the module finishes
    ##
    return
Exemplo n.º 2
0
def test_screen_loading(ctx):
    for eachdir in [dirname_baseline, dirname_testline]: ## loop through each of baseline and testline and generate the files for later diffing
        cd(eachdir)
        runStr = brainTestStringWithSaving.format(
                 brainT="CGP",
                 initPop="'snapshot_organisms_0.csv'",
                 updates="1"
                 )
        runCmdAndSaveOutput(runStr, filename='screen-poploading') ## generate snapshot_organisms_0.csv
        cd('..') ## could also have done cd(this_repo_path)
    repoDiffForSimilarity('screen-poploading')
Exemplo n.º 3
0
def ctx(
):  ## create a context for all the tests - you could potentially use this to pass an obj to all test fns
    if not ctx.ran:  ## prevents reinit before each and every test fn in this module
        ## generate cfg (have to 'cd' there, because mabe '-s' ignores 'GLOBAL-outputDirectory' setting)
        ## and run mabe with defaults
        runStr = dotSlashMabe + " -p GLOBAL-randomSeed {seed} GLOBAL-updates 1 ARCHIVIST_LODWAP-terminateAfter 0"
        dirs = [dirname_baseline, dirname_testline]
        for eachdir in dirs:  ## loop through each of baseline and testline and generate the files for later diffing
            cd(this_repo_path)
            cd(eachdir)
            ## Create 2 files both with random seed
            runCmdAndSaveOutput(runStr.format(seed='-1'),
                                filename='screen-settings-randseed-random-A')
            runCmdAndSaveOutput(runStr.format(seed='-1'),
                                filename='screen-settings-randseed-random-B')
            ## Create 2 files both with identical seed
            runCmdAndSaveOutput(
                runStr.format(seed='101'),
                filename='screen-settings-randseed-nonrandom-A')
            runCmdAndSaveOutput(
                runStr.format(seed='101'),
                filename='screen-settings-randseed-nonrandom-B')
            cd('..')  ## could also have done cd(this_repo_path)
        ## FYI, could have done it the following way if we were up one dir in mabe_testing
        #runCmdAndSaveOutput( "{exe} -p GLOBAL-outputDirectory {path}".format(exe=path_baseline_exe, path=dirname_baseline), filename=dirname_baseline+'screen-simulation' )
        ctx.ran = True

    yield None  ## could have actually passed a context object here to all the test fns
    ##
    ## teardown happens after the last test in the module finishes
    ##
    return
Exemplo n.º 4
0
def test_reload_most_byid_error(ctx,numToLoad,mostCommand,dirToTest):
    errorMessage = buildMessageErrorExpectedWithArgs( dirToTest,mostCommand,numToLoad ) ## returns this fn name, the args, and that error was expected
    with pytest.raises(subprocess.CalledProcessError, message=errorMessage):
        cd(this_repo_path) ## reset after possible error
        cd(dirToTest)
        initPop = "{most} {amount} by ID from {{'snapshot_organisms_10.csv'}}".format(
                  most=mostCommand,
                  amount=str(numToLoad)
                  )
        runStr = brainTestString.format(
                 brainT='CGP',
                 initPop=initPop,
                 updates="1"
                 )
        runCmdAndSaveOutput(runStr,'tempfile') ## must 'Show' output for error sig to be inspected
Exemplo n.º 5
0
def test_reload_most_byid_noerror(ctx,numToLoad,mostCommand):
    outputFilename = 'screen-reload-{most}-byid-{num}'.format(
                      most=mostCommand, num=str(numToLoad)
                      )
    for eachdir in [dirname_baseline, dirname_testline]: ## loop through each of baseline and testline and generate the files for later diffing
        cd(this_repo_path) ## ensures clean state
        cd(eachdir)
        initPop = "{most} {amount} by ID from {{'snapshot_organisms_10.csv'}}".format(
                  most=mostCommand,
                  amount=str(numToLoad)
                  )
        runStr = brainTestString.format(
                 brainT='CGP',
                 initPop=initPop,
                 updates="1"
                 )
        runCmdAndSaveOutput(runStr, filename=outputFilename) ## normalize ID
        cd('..')
    repoDiffForSimilarity(outputFilename)
Exemplo n.º 6
0
def ctx(): ## create a context for all the tests - you could potentially use this to pass an obj to all test fns
    if not ctx.ran: ## prevents reinit before each and every test fn in this module
        ## generate cfg (have to 'cd' there, because mabe '-s' ignores 'GLOBAL-outputDirectory' setting)
        ## and run mabe with defaults
        dirs = [dirname_baseline, dirname_testline]
        for eachdir in dirs: ## loop through each of baseline and testline and generate the files for later diffing
            cd(this_repo_path)
            cd(eachdir)
            runCmdAndSaveOutput( "{exe} -l".format(exe=dotSlashMabe), filename='screen-plf' )
            runCmdAndHideOutput( brainTestStringWithSaving.format( brainT='CGP', initPop='default 100', updates='10' ) ) ## generate large snapshot_organisms_10.csv
            runCmdAndHideOutput( brainTestStringWithSaving.format( brainT='CGP', initPop='default 1', updates='1' ) ) ## generate small snapshot_organisms_0.csv
            cd('..') ## could also have done cd(this_repo_path)
        ctx.ran = True

    yield None ## could have actually passed a context object here to all the test fns
    ##
    ## teardown happens after the last test in the module finishes
    ##
    return
Exemplo n.º 7
0
def ctx(
):  ## create a context for all the tests - you could potentially use this to pass an obj to all test fns
    if not ctx.ran:
        ## generate cfg (have to 'cd' there, because mabe '-s' ignores 'GLOBAL-outputDirectory' setting)
        ## and run mabe with defaults
        dirs = [dirname_baseline, dirname_testline]
        for eachdir in dirs:  ## loop through each of baseline and testline and generate the files for later diffing
            cd(this_repo_path)
            cd(eachdir)
            runStr = dotSlashMabe + " -s"
            runCmdAndSaveOutput(
                runStr, filename='screen-settings')  ## save settings to file
            for eachfile in [
                    "settings.cfg", "settings_organism.cfg",
                    "settings_world.cfg"
            ]:  ## make a backup of the settings files
                copyfileAndPermissions(eachfile, eachfile + ".bak")
            runStr = dotSlashMabe + " -f settings*.cfg -s"
            runCmdAndSaveOutput(runStr, filename='screen-settings-reload'
                                )  ## load and save settings to file
            for eachfile in [
                    "settings.cfg", "settings_organism.cfg",
                    "settings_world.cfg"
            ]:  ## make a backup of the settings files
                copyfileAndPermissions(eachfile, eachfile + ".bak")
            ##
            ## MORE GENERATION OF FILES OR BEHAVIOR HERE
            ##
            cd('..')  ## could also have done cd(this_repo_path)
        ## FYI, could have done it the following way if we were up one dir in mabe_testing
        #runCmdAndSaveOutput( "{exe} -p GLOBAL-outputDirectory {path}".format(exe=path_baseline_exe, path=dirname_baseline), filename=dirname_baseline+'screen-simulation' )
        ctx.ran = True

    yield None  ## could have actually passed a context object here to all the test fns
    ##
    ## teardown happens after the last test in the module finishes
    ##
    return