Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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:]
Ejemplo n.º 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
Ejemplo n.º 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:]
Ejemplo n.º 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:]
Ejemplo n.º 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:]
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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:]
Ejemplo n.º 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:]
Ejemplo n.º 13
0
def test_verb_build(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        args = mkosi.parse_args(["build"])
        assert args["default"].verb == "build"
Ejemplo n.º 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']
Ejemplo n.º 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
Ejemplo n.º 16
0
def test_verb_build(tmpdir):
    with ChangeCwd(tmpdir.strpath):
        args = mkosi.parse_args(['build'])
        assert args['default'].verb == 'build'
Ejemplo n.º 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:]
Ejemplo n.º 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"]
Ejemplo n.º 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
Ejemplo n.º 20
0
def parse(argv: Optional[List[str]] = None) -> MkosiArgs:
    return mkosi.load_args(mkosi.parse_args(argv)["default"])
Ejemplo n.º 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
Ejemplo n.º 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:]
Ejemplo n.º 23
0
def test_verb_build(tmpdir: Path) -> None:
    with change_cwd(tmpdir):
        args = mkosi.parse_args(["build"])
        assert args["default"].verb == Verb.build
Ejemplo n.º 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:]
Ejemplo n.º 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
Ejemplo n.º 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"]
Ejemplo n.º 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
Ejemplo n.º 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"]