示例#1
0
def test_builtin(tested_config, tmpdir):
    """Test if builtin config and reference config match"""
    with ChangeCwd(tmpdir.strpath):
        if '--all' in tested_config.cli_arguments:
            with pytest.raises(mkosi.MkosiParseException):
                args = mkosi.parse_args(tested_config.cli_arguments)
        else:
            args = mkosi.parse_args(tested_config.cli_arguments)
            assert tested_config == args
示例#2
0
def test_builtin(tested_config: Any, tmpdir: Path) -> None:
    """Test if builtin config and reference config match"""
    with change_cwd(tmpdir):
        if "--all" in tested_config.cli_arguments:
            with pytest.raises(MkosiException):
                args = mkosi.parse_args(tested_config.cli_arguments)
        else:
            args = mkosi.parse_args(tested_config.cli_arguments)
            assert tested_config == args
示例#3
0
def test_def_2(tested_config: Any, tmpdir: Path) -> None:
    """Generate the mkosi.default file plus another config file"""
    with change_cwd(tmpdir):
        tested_config.prepare_mkosi_default(tmpdir)
        tested_config.prepare_mkosi_default_d_2(tmpdir)
        args = mkosi.parse_args(tested_config.cli_arguments)
        assert tested_config == args
示例#4
0
def test_verb_shell_cli_args5(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ['-pa-package', '-p', 'another-package', 'shell', 'python3 -foo -bar;', 'ls --inode']
        args = mkosi.parse_args(cmdline_ref)
        assert args['default'].verb == 'shell'
        assert args['default'].packages == ['a-package', 'another-package']
        assert args['default'].cmdline == cmdline_ref[4:]
示例#5
0
def test_def_2(tested_config, tmpdir):
    """Generate the mkosi.default file plus another config file"""
    with ChangeCwd(tmpdir.strpath):
        tested_config.prepare_mkosi_default(tmpdir.strpath)
        tested_config.prepare_mkosi_default_d_2(tmpdir.strpath)
        args = mkosi.parse_args(tested_config.cli_arguments)
        assert tested_config == args
示例#6
0
def test_verb_shell_cli_args5(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ["-pa-package", "-p", "another-package", "shell", "python3 -foo -bar;", "ls --inode"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == "shell"
        assert args["default"].packages == ["a-package", "another-package"]
        assert args["default"].cmdline == cmdline_ref[4:]
示例#7
0
def test_verb_boot_no_cli_args2(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ["-pa-package", "boot", "--par-for-sub", "--popenssl", "--for_sub", "1234"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == "boot"
        assert "a-package" in args["default"].packages
        assert args["default"].cmdline == cmdline_ref[2:]
示例#8
0
def test_verb_boot_no_cli_args2(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ['-pa-package', 'boot', '--par-for-sub', '--popenssl', '--for_sub', '1234']
        args = mkosi.parse_args(cmdline_ref)
        assert args['default'].verb == 'boot'
        assert 'a-package' in args['default'].packages
        assert args['default'].cmdline == cmdline_ref[2:]
示例#9
0
def test_def_1_args(tested_config, tmpdir):
    """Generate the mkosi.default plus a config file plus command line arguments"""
    with ChangeCwd(tmpdir.strpath):
        tested_config.prepare_mkosi_default(tmpdir.strpath)
        tested_config.prepare_mkosi_default_d_1(tmpdir.strpath)
        tested_config.prepare_args()
        args = mkosi.parse_args(tested_config.cli_arguments)
        assert tested_config == args
示例#10
0
def test_def_1_args(tested_config: Any, tmpdir: Path) -> None:
    """Generate the mkosi.default plus a config file plus command line arguments"""
    with change_cwd(tmpdir):
        tested_config.prepare_mkosi_default(tmpdir)
        tested_config.prepare_mkosi_default_d_1(tmpdir)
        tested_config.prepare_args()
        args = mkosi.parse_args(tested_config.cli_arguments)
        assert tested_config == args
示例#11
0
def test_verb_boot_no_cli_args2(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        cmdline_ref = [
            "-pa-package", "boot", "--par-for-sub", "--popenssl", "--for_sub",
            "1234"
        ]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == Verb.boot
        assert "a-package" in args["default"].packages
        assert args["default"].cmdline == cmdline_ref[2:]
示例#12
0
def test_verb_shell_cli_args5(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        cmdline_ref = [
            "-pa-package", "-p", "another-package", "shell",
            "python3 -foo -bar;", "ls --inode"
        ]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == Verb.shell
        assert args["default"].packages == ["a-package", "another-package"]
        assert args["default"].cmdline == cmdline_ref[4:]
示例#13
0
def test_verb_build(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        args = mkosi.parse_args(["build"])
        assert args["default"].verb == "build"
示例#14
0
def test_verb_summary_no_cli_args4(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ['-pa-package', '-p', 'another-package', 'summary']
        args = mkosi.parse_args(cmdline_ref)
        assert args['default'].verb == 'summary'
        assert args['default'].packages == ['a-package', 'another-package']
示例#15
0
def test_verb_shell_cli_args7(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ['-i', 'summary']
        args = mkosi.parse_args(cmdline_ref)
        assert args['default'].verb == 'summary'
        assert args['default'].incremental == True
示例#16
0
def test_verb_build(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        args = mkosi.parse_args(['build'])
        assert args['default'].verb == 'build'
示例#17
0
def test_verb_boot_no_cli_args1(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ['boot', '--par-for-sub', '--pom', '--for_sub', '1234']
        args = mkosi.parse_args(cmdline_ref)
        assert args['default'].verb == 'boot'
        assert args['default'].cmdline == cmdline_ref[1:]
示例#18
0
def test_verb_summary_no_cli_args4(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        cmdline_ref = ["-pa-package", "-p", "another-package", "summary"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == Verb.summary
        assert args["default"].packages == ["a-package", "another-package"]
示例#19
0
def test_all_1(tested_config_all, tmpdir):
    """Generate the mkosi.default plus two config files plus short command line arguments"""
    with ChangeCwd(tmpdir.strpath):
        tested_config_all.prepare_mkosi_files(tmpdir.strpath)
        args = mkosi.parse_args(tested_config_all.cli_arguments)
        assert tested_config_all == args
示例#20
0
def parse(argv: Optional[List[str]] = None) -> MkosiArgs:
    return mkosi.load_args(mkosi.parse_args(argv)["default"])
示例#21
0
def test_verb_shell_cli_args7(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        cmdline_ref = ["-i", "summary"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == Verb.summary
        assert args["default"].incremental == True
示例#22
0
def test_verb_boot_no_cli_args1(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        cmdline_ref = ["boot", "--par-for-sub", "--pom", "--for_sub", "1234"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == Verb.boot
        assert args["default"].cmdline == cmdline_ref[1:]
示例#23
0
def test_verb_build(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        args = mkosi.parse_args(["build"])
        assert args["default"].verb == Verb.build
示例#24
0
def test_verb_boot_no_cli_args1(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ["boot", "--par-for-sub", "--pom", "--for_sub", "1234"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == "boot"
        assert args["default"].cmdline == cmdline_ref[1:]
示例#25
0
def test_verb_shell_cli_args7(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ["-i", "summary"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == "summary"
        assert args["default"].incremental == True
示例#26
0
def test_verb_summary_no_cli_args4(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        cmdline_ref = ["-pa-package", "-p", "another-package", "summary"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == "summary"
        assert args["default"].packages == ["a-package", "another-package"]
示例#27
0
def test_all_1(tested_config_all: Any, tmpdir: Path) -> None:
    """Generate the mkosi.default plus two config files plus short command line arguments"""
    with change_cwd(tmpdir):
        tested_config_all.prepare_mkosi_files(tmpdir)
        args = mkosi.parse_args(tested_config_all.cli_arguments)
        assert tested_config_all == args
示例#28
0
def test_verb_boot_no_cli_args3(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        cmdline_ref = ["-pa-package", "-p", "another-package", "build"]
        args = mkosi.parse_args(cmdline_ref)
        assert args["default"].verb == Verb.build
        assert args["default"].packages == ["a-package", "another-package"]