def test_refspec_absolute(changedir, tmpdir): """ Test that the local git clone works when a absolute refspec is given. """ tdir = str(tmpdir.mkdir('test_refspec_absolute')) shutil.rmtree(tdir, ignore_errors=True) shutil.copytree('tests/test_refspec', tdir) os.chdir(tdir) kas.kas(['shell', 'test3.yml', '-c', 'true']) (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas_abs', fail=False, liveupdate=False) assert rc != 0 assert output.strip() == '' (rc, output_kas_abs) = run_cmd(['git', 'rev-parse', 'HEAD'], cwd='kas_abs', fail=False, liveupdate=False) assert rc == 0 (rc, output_kas_rel) = run_cmd(['git', 'rev-parse', 'HEAD'], cwd='kas_rel', fail=False, liveupdate=False) assert rc == 0 assert output_kas_abs.strip() == output_kas_rel.strip()
def execute(self, ctx): """ Executes the bitbake build command. """ # Start bitbake build of image bitbake = find_program(ctx.environ['PATH'], 'bitbake') cmd = [bitbake, '-k', '-c', ctx.config.get_bitbake_task()] \ + self.extra_bitbake_args + ctx.config.get_bitbake_targets() if sys.stdout.isatty(): logging.info('%s$ %s', ctx.build_dir, ' '.join(cmd)) ret = subprocess.call(cmd, env=ctx.environ, cwd=ctx.build_dir) if ret != 0: logging.error('Command returned non-zero exit status %d', ret) sys.exit(ret) else: run_cmd(cmd, cwd=ctx.build_dir)
def test_refspec_switch(tmpdir): """ Test that the local git clone is correctly updated when switching between a commit hash refspec and a branch refspec. """ tdir = str(tmpdir.mkdir('test_refspec_switch')) shutil.rmtree(tdir, ignore_errors=True) shutil.copytree('tests/test_refspec', tdir) prev_dir = os.path.realpath(os.getcwd()) os.chdir(tdir) kas.kas(['shell', 'test.yml', '-c', 'true']) (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas', fail=False, liveupdate=False) assert rc != 0 assert output.strip() == '' (rc, output) = run_cmd(['git', 'rev-parse', '-q', 'HEAD'], cwd='kas', fail=False, liveupdate=False) assert rc == 0 assert output.strip() == '907816a5c4094b59a36aec12226e71c461c05b77' (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas2', fail=False, liveupdate=False) assert rc == 0 assert output.strip() == 'refs/heads/master' kas.kas(['shell', 'test2.yml', '-c', 'true']) (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas', fail=False, liveupdate=False) assert rc == 0 assert output.strip() == 'refs/heads/master' (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas2', fail=False, liveupdate=False) assert rc != 0 assert output.strip() == '' (rc, output) = run_cmd(['git', 'rev-parse', '-q', 'HEAD'], cwd='kas2', fail=False, liveupdate=False) assert rc == 0 assert output.strip() == '907816a5c4094b59a36aec12226e71c461c05b77' os.chdir(prev_dir)