Exemplo n.º 1
0
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()
Exemplo n.º 2
0
def dokas(tmpdir):
    tdir = str(tmpdir.mkdir('test_layers'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_layers', tdir)
    os.chdir(tdir)
    kas.kas(['shell', 'test.yml', '-c', 'true'])
    yield
    os.chdir(os.path.join(os.path.dirname(__file__), '..'))
Exemplo n.º 3
0
def test_patch(changedir, tmpdir):
    tdir = str(tmpdir.mkdir('test_patch'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_patch', tdir)
    os.chdir(tdir)
    kas.kas(['shell', 'test.yml', '-c', 'true'])
    for f in ['kas/tests/test_patch/hello.sh', 'hello/hello.sh']:
        assert os.stat(f)[stat.ST_MODE] & stat.S_IXUSR
    kas.kas(['shell', 'test.yml', '-c', 'true'])
Exemplo n.º 4
0
def test_build_dir_is_placed_inside_work_dir_by_default(changedir, tmpdir):
    conf_dir = str(tmpdir.mkdir('test_env_variables'))
    shutil.rmtree(conf_dir, ignore_errors=True)
    shutil.copytree('tests/test_environment_variables', conf_dir)

    os.chdir(conf_dir)

    kas.kas(['checkout', 'test.yml'])

    assert (os.path.exists(os.path.join(os.getcwd(), 'build', 'conf')))
Exemplo n.º 5
0
def test_url_no_refspec(changedir, tmpdir):
    """
        Test that a repository with url but no refspec raises an error.
    """
    tdir = str(tmpdir.mkdir('test_url_no_refspec'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_refspec', tdir)
    os.chdir(tdir)
    with pytest.raises(SystemExit):
        kas.kas(['shell', 'test4.yml', '-c', 'true'])
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
def test_build_dir_can_be_specified_by_environment_variable(changedir, tmpdir):
    conf_dir = str(tmpdir.mkdir('test_env_variables'))
    build_dir = str(tmpdir.mkdir('test_build_dir'))
    shutil.rmtree(conf_dir, ignore_errors=True)
    shutil.copytree('tests/test_environment_variables', conf_dir)
    shutil.rmtree(build_dir, ignore_errors=True)
    os.chdir(conf_dir)

    os.environ['KAS_BUILD_DIR'] = build_dir
    kas.kas(['checkout', 'test.yml'])
    del os.environ['KAS_BUILD_DIR']

    assert (os.path.exists(os.path.join(build_dir, 'conf')))
Exemplo n.º 8
0
def test_patch_update(changedir, tmpdir):
    """
        Test that patches are applied correctly after switching refspec from
        a branch to a commit hash and vice-versa with both git and mercurial
        repositories.
    """
    tdir = str(tmpdir.mkdir('test_patch_update'))
    shutil.rmtree(tdir, ignore_errors=True)
    print(os.getcwd())
    shutil.copytree('tests/test_patch', tdir)
    os.chdir(tdir)
    kas.kas(['shell', 'test.yml', '-c', 'true'])
    kas.kas(['shell', 'test2.yml', '-c', 'true'])
    for f in ['kas/tests/test_patch/hello.sh', 'hello/hello.sh']:
        assert os.stat(f)[stat.ST_MODE] & stat.S_IXUSR
Exemplo n.º 9
0
def test_checkout(changedir, tmpdir):
    tdir = str(tmpdir.mkdir('test_commands'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_commands', tdir)
    os.chdir(tdir)
    kas.kas(['checkout', 'test.yml'])

    # Ensure that local.conf and bblayers.conf are populated, check that no
    # build has been executed by ensuring that no tmp, sstate-cache or
    # downloads directories are present.
    assert (os.path.exists('build/conf/local.conf'))
    assert (os.path.exists('build/conf/bblayers.conf'))
    assert (not glob.glob('build/tmp*'))
    assert (not os.path.exists('build/downloads'))
    assert (not os.path.exists('build/sstate-cache'))
Exemplo n.º 10
0
def test_for_all_repos(changedir, tmpdir):
    tdir = str(tmpdir.mkdir('test_commands'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_commands', tdir)
    os.chdir(tdir)
    kas.kas([
        'for-all-repos', 'test.yml',
        'git rev-parse HEAD >> %s/ref_${KAS_REPO_NAME}' % (tdir)
    ])

    with open('ref_kas_1.0', 'r') as f:
        assert (
            f.readline().strip() == '907816a5c4094b59a36aec12226e71c461c05b77')
    with open('ref_kas_1.1', 'r') as f:
        assert (
            f.readline().strip() == 'e9ca55a239caa1a2098e1d48773a29ea53c6cab2')
Exemplo n.º 11
0
def test_menu(monkeypatch, tmpdir):
    tdir = str(tmpdir.mkdir('test_menu'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_menu', tdir)
    cwd = os.getcwd()
    os.chdir(tdir)

    monkeypatch.setattr('snack.GridFormHelp.runOnce', mock_runOnce)
    monkeypatch.setattr('snack.ButtonBar.buttonPressed', mock_buttonPressed)
    monkeypatch.setattr('snack.Listbox.current', mock_current)

    # select opt1 & build
    kas.kas(['menu'])
    assert file_contains('build/conf/local.conf', 'OPT1 = "1"\n')
    assert file_contains('.config.yaml', 'build_system: openembedded\n')
    assert check_bitbake_options('-c build target1\n')

    # rebuild test
    kas.kas(['build'])
    assert file_contains('build/conf/local.conf', 'OPT1 = "1"\n')
    assert check_bitbake_options('-c build target1\n')

    # select alternative target & build
    kas.kas(['menu'])
    assert file_contains('build/conf/local.conf', 'OPT1 = "1"\n')
    assert check_bitbake_options('-c build target2\n')

    os.chdir(cwd)
Exemplo n.º 12
0
def test_build_system(changedir, tmpdir):
    tdir = str(tmpdir.mkdir('test_build_system'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_build_system', tdir)
    os.chdir(tdir)

    kas.kas(['shell', 'test-oe.yml', '-c', 'true'])
    with open('build-env', 'r') as f:
        assert (f.readline().strip() == 'openembedded')

    kas.kas(['shell', 'test-isar.yml', '-c', 'true'])
    with open('build-env', 'r') as f:
        assert (f.readline().strip() == 'isar')

    kas.kas(['shell', 'test-openembedded.yml', '-c', 'true'])
    with open('build-env', 'r') as f:
        assert (f.readline().strip() == 'openembedded')
Exemplo n.º 13
0
def test_repo_includes(changedir, tmpdir):
    tdir = str(tmpdir.mkdir('test_commands'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_repo_includes', tdir)
    os.chdir(tdir)
    kas.kas(['checkout', 'test.yml'])