forked from Mirror/pmbootstrap
Cease merging pmbootstrap.cfg into args, implement a Context type to let us pull globals out of thin air (as an intermediate workaround) and rip args out of a lot of the codebase. This is just a first pass, after this we can split all the state that leaked over into Context into types with narrower scopes (like a BuildContext(), etc). Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
# Copyright 2023 Oliver Smith
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
import os
|
|
from pmb.types import PmbArgs
|
|
import pytest
|
|
import shutil
|
|
import sys
|
|
|
|
import pmb_test
|
|
import pmb_test.const
|
|
import pmb.helpers.lint
|
|
import pmb.helpers.run
|
|
|
|
|
|
@pytest.fixture
|
|
def args(request):
|
|
import pmb.parse
|
|
sys.argv = ["pmbootstrap", "lint"]
|
|
args = pmb.parse.arguments()
|
|
args.log = get_context().config.work / "log_testsuite.txt"
|
|
pmb.helpers.logging.init(args)
|
|
request.addfinalizer(pmb.helpers.logging.logfd.close)
|
|
return args
|
|
|
|
|
|
def test_pmbootstrap_lint(args: PmbArgs, tmpdir):
|
|
args.aports = tmpdir = str(tmpdir)
|
|
|
|
# Create hello-world pmaport in tmpdir
|
|
apkbuild_orig = f"{pmb_test.const.testdata}/apkbuild/APKBUILD.lint"
|
|
apkbuild_tmp = f"{tmpdir}/hello-world/APKBUILD"
|
|
os.makedirs(f"{tmpdir}/hello-world")
|
|
shutil.copyfile(apkbuild_orig, apkbuild_tmp)
|
|
|
|
# Lint passes
|
|
assert pmb.helpers.lint.check(args, ["hello-world"]) == ""
|
|
|
|
# Change "pmb:cross-native" to non-existing "pmb:invalid-opt"
|
|
pmb.helpers.run.user(["sed", "s/pmb:cross-native/pmb:invalid-opt/g",
|
|
"-i", apkbuild_tmp])
|
|
|
|
# Lint error
|
|
err_str = "invalid option 'pmb:invalid-opt'"
|
|
assert err_str in pmb.helpers.lint.check(args, ["hello-world"])
|