def test_simple_broken_build(): clean() initial_output = invoke_drkns('failingdependenciescase/project1', 'run --force-success') ls_output = sh('ls /tmp', capture=True) assert('dependency1.neverranbuild.drknsdemo.out' not in ls_output) assert('dependency1.cleanup.drknsdemo.out' in ls_output) assert('project1.check.drknsdemo.out' in ls_output) assert('project1.failedbuildbecausedep1failed.drknsdemo.out' not in ls_output) assert ('project1.cleanup.drknsdemo.out' in ls_output) invoke_drkns('failingdependenciescase/project1', 'run --force-success') ls_output = sh('ls /tmp', capture=True) # previously observed bug assert('dependency1.neverranbuild.drknsdemo.out' not in ls_output) limited_output = invoke_drkns('failingdependenciescase/project1', 'run --force-success --limit-output') assert (len(limited_output) < len(initial_output)) summary_output = invoke_drkns('failingdependenciescase/project1', 'run --force-success --summary') assert(len(summary_output) < len(initial_output))
def test_run_no_multi_dependencies_execution(): clean() invoke_drkns('nominalcase', 'run') dependency_output_file = '/tmp/dependency1.drknsdemo.out' line_count = 0 with open(dependency_output_file, 'r') as f: for _ in f: line_count += 1 assert(line_count == 1)
def test_run_partial(): clean() invoke_drkns('nominalcase', 'run project1.run') ls_output = sh('ls /tmp', capture=True) assert('project1.drknsdemo.out' in ls_output) assert('project2.drknsdemo.out' not in ls_output) clean() invoke_drkns('nominalcase', 'run project1') ls_output = sh('ls /tmp', capture=True) assert ('project1.drknsdemo.out' in ls_output)
def test_list(): clean() output = invoke_drkns('nominalcase', 'list') assert(len(output) > 6) assert('project1.run' in output) assert('project1.dependency1.hello' in output) assert('project2.dependency1WithAnotherKey.run' not in output)
def test_working_project_build(): """ Project 2 and project 3 have no failing dependencies. They should build without problems. Project 3 check step have an error but it should not prevent the execution of the other cleanup step :return: """ clean() invoke_drkns('failingdependenciescase', 'run --force-success') ls_output = sh('ls /tmp', capture=True) assert('project2.check.drknsdemo.out' in ls_output) assert('project2.built.drknsdemo.out' in ls_output) assert('project2.built.drknsdemo.out' in ls_output) assert('project3.succesbecausedep2failedatbuild.drknsdemo.out' in ls_output) assert('project3.cleanup1.drknsdemo.out' not in ls_output) assert('project3.cleanup2.drknsdemo.out' in ls_output)
def test_run_complete(): clean() t0 = time.time() drkns_output = invoke_drkns('nominalcase', 'run') ls_output = sh('ls /tmp', capture=True) t1 = time.time() execution_time = t1 - t0 assert(execution_time < 10) assert('dummyCleanup' in drkns_output) assert('project1.drknsdemo.out' in ls_output) assert('project2.drknsdemo.out' in ls_output) assert('project2built.drknsdemo.out' in ls_output)
def test_broken_full_build(): """ The full build should fail, and thus the build steps of the main element should never be run, but the check steps should be ran. :return: """ clean() output = invoke_drkns('failingdependenciescase', 'run --force-success') ls_output = sh('ls /tmp', capture=True) assert('main.neverRanBuildStep1.drknsdemo.out' not in ls_output) assert('main.neverRanBuildStep2.drknsdemo.out' not in ls_output) assert('main.checkStep1.drknsdemo.out' in ls_output) assert('dependency1.neverranbuild.drknsdemo.out' not in ls_output) assert('dependency1.cleanup.drknsdemo.out' in ls_output) assert('project1.check.drknsdemo.out' in ls_output) assert('project1.failedbuildbecausedep1failed.drknsdemo.out' not in ls_output)
def test_check(): clean() output = invoke_drkns('nominalcase', 'check') assert (len(output) == 0)
def test_run_cache(): clean() invoke_drkns('nominalcase', 'run') ls_output = sh('ls /tmp', capture=True) assert('project1.drknsdemo.out' in ls_output) assert('project2.drknsdemo.out' in ls_output) sh('rm /tmp/project*.out') invoke_drkns('nominalcase', 'run') ls_output = sh('ls /tmp', capture=True) # the hash hasn't changed the build should not have generated output assert('project1.drknsdemo.out' not in ls_output) assert('project2.drknsdemo.out' not in ls_output) project_file = 'testprojects/nominalcase/project1/main.py' sh('echo "# for test" >> ' + project_file, capture=True) invoke_drkns('nominalcase', 'run') ls_output = sh('ls /tmp', capture=True) assert('project1.drknsdemo.out' in ls_output) assert('project2.drknsdemo.out' not in ls_output) sh('cat ' + project_file + ' | grep -v test > ' + project_file + '.mod') sh('rm ' + project_file) sh('mv ' + project_file + '.mod ' + project_file) ignored_file_1 = 'testprojects/nominalcase/project1/main.py.tmp' sh('rm -rf /tmp/project*.drknsdemo.out', capture=True) sh('echo "something that should not trigger a build" >> ' + ignored_file_1) ignored_directory = 'testprojects/nominalcase/project1/ignoreddirectory' sh('mkdir ' + ignored_directory) ignored_file_2 = ignored_directory + '/somefile' sh('echo "some other thing that should not trigger a build either" >> ' +\ ignored_file_2) invoke_drkns('nominalcase', 'run') ls_output = sh('ls /tmp', capture=True) assert('project1.drknsdemo.out' not in ls_output) assert('project2.drknsdemo.out' not in ls_output) sh('rm -rf ' + ignored_file_1 + ' ' + ignored_directory) invoke_drkns('nominalcase', 'forget project1') invoke_drkns('nominalcase', 'run') ls_output = sh('ls /tmp', capture=True) assert('project1.drknsdemo.out' in ls_output)
def test_generate(): output = invoke_drkns('nominalcase', 'generate') data = yaml.safe_load(output) assert('drkns-check' in data['jobs']['project1']['needs']) assert('dependency1' in data['jobs']['project1']['needs'])
def test_debug(): clean() output = invoke_drkns('nominalcase', 'debug') assert(len(output) > 6)