forked from Mirror/pmbootstrap
If you want to build a package without changing the version number, please use `--force` from now on. For example: pmbootstrap build --force hello-world Prior to this commit, changes were detected automatically (timestamp based rebuilds). However, that feature does not work as expected with the binary package repository we have now, and depending on how you use git, it has never worked. Close #1167, close #1156, close #1023 and close #985. This commit also mentions --force when a package is up to date, but the user requested to build it.
80 lines
2.6 KiB
Python
80 lines
2.6 KiB
Python
"""
|
|
Copyright 2018 Oliver Smith
|
|
|
|
This file is part of pmbootstrap.
|
|
|
|
pmbootstrap is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
pmbootstrap is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|
"""
|
|
import os
|
|
import sys
|
|
import pytest
|
|
|
|
# Import from parent directory
|
|
sys.path.append(os.path.realpath(
|
|
os.path.join(os.path.dirname(__file__) + "/..")))
|
|
import pmb.aportgen
|
|
import pmb.config
|
|
import pmb.helpers.frontend
|
|
import pmb.helpers.logging
|
|
|
|
|
|
@pytest.fixture
|
|
def args(tmpdir, request):
|
|
import pmb.parse
|
|
sys.argv = ["pmbootstrap.py", "chroot"]
|
|
args = pmb.parse.arguments()
|
|
args.log = args.work + "/log_testsuite.txt"
|
|
pmb.helpers.logging.init(args)
|
|
request.addfinalizer(args.logfd.close)
|
|
return args
|
|
|
|
|
|
def change_config(monkeypatch, path_config, key, value):
|
|
args = args_patched(monkeypatch, ["pmbootstrap.py", "-c", path_config, "config",
|
|
key, value])
|
|
pmb.helpers.frontend.config(args)
|
|
|
|
|
|
def args_patched(monkeypatch, argv):
|
|
monkeypatch.setattr(sys, "argv", argv)
|
|
return pmb.parse.arguments()
|
|
|
|
|
|
def test_config_user(args, tmpdir, monkeypatch):
|
|
# Temporary paths
|
|
tmpdir = str(tmpdir)
|
|
path_work = tmpdir + "/work"
|
|
path_config = tmpdir + "/pmbootstrap.cfg"
|
|
|
|
# Generate default config (only uses tmpdir)
|
|
os.chdir(pmb.config.pmb_src)
|
|
pmb.helpers.run.user(args, ["sh", "-c", "yes '' | ./pmbootstrap.py -c '" +
|
|
path_config + "' -w '" + path_work + "' init"])
|
|
|
|
# Load and verify default config
|
|
argv = ["pmbootstrap.py", "-c", path_config, "config"]
|
|
args_default = args_patched(monkeypatch, argv)
|
|
assert args_default.work == path_work
|
|
|
|
# Modify jobs count
|
|
change_config(monkeypatch, path_config, "jobs", "9000")
|
|
assert args_patched(monkeypatch, argv).jobs == "9000"
|
|
|
|
# Override jobs count via commandline (-j)
|
|
argv_jobs = ["pmbootstrap.py", "-c", path_config, "-j", "1000", "config"]
|
|
assert args_patched(monkeypatch, argv_jobs).jobs == "1000"
|
|
|
|
# Override a config option with something that evaluates to false
|
|
argv_empty = ["pmbootstrap.py", "-c", path_config, "-w", "", "config"]
|
|
assert args_patched(monkeypatch, argv_empty).work == ""
|