pkgmgr-kunrunic 0.1.0.dev9__tar.gz → 0.1.1.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pkgmgr_kunrunic-0.1.0.dev9/pkgmgr_kunrunic.egg-info → pkgmgr_kunrunic-0.1.1.dev1}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/__init__.py +1 -1
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/cli.py +20 -3
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/config.py +5 -1
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/shell_integration.py +37 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/snapshot.py +98 -9
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1/pkgmgr_kunrunic.egg-info}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/SOURCES.txt +2 -0
- pkgmgr_kunrunic-0.1.1.dev1/tests/test_cli_install.py +66 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/tests/test_config.py +13 -1
- pkgmgr_kunrunic-0.1.1.dev1/tests/test_progress.py +32 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/LICENSE +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/README.md +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/__main__.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/collectors/__init__.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/collectors/base.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/collectors/checksums.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/gitcollect.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/points.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/release.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/templates/pkg.yaml.sample +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/templates/pkgmgr.yaml.sample +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/watch.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/top_level.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pyproject.toml +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/setup.cfg +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/tests/test_release.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/tests/test_snapshot.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import print_function
|
|
2
2
|
"""CLI entrypoint scaffold for the pkg manager."""
|
|
3
3
|
|
|
4
|
+
import os
|
|
4
5
|
import sys
|
|
5
6
|
|
|
6
7
|
try:
|
|
@@ -186,14 +187,30 @@ def build_parser():
|
|
|
186
187
|
|
|
187
188
|
|
|
188
189
|
def _handle_make_config(args):
|
|
189
|
-
config.write_template(args.output)
|
|
190
|
-
return 0
|
|
190
|
+
wrote = config.write_template(args.output)
|
|
191
|
+
return 0 if wrote else 1
|
|
191
192
|
|
|
192
193
|
|
|
193
194
|
def _handle_install(args):
|
|
194
195
|
cfg = config.load_main(args.config)
|
|
196
|
+
existing = []
|
|
197
|
+
readme_path = os.path.join(config.BASE_DIR, "README.txt")
|
|
198
|
+
baseline_path = os.path.join(snapshot.STATE_DIR, "baseline.json")
|
|
199
|
+
if os.path.exists(readme_path):
|
|
200
|
+
existing.append(readme_path)
|
|
201
|
+
if os.path.exists(baseline_path):
|
|
202
|
+
existing.append(baseline_path)
|
|
203
|
+
if existing:
|
|
204
|
+
print("[install] existing install artifacts found:")
|
|
205
|
+
for path in existing:
|
|
206
|
+
print(" - %s" % path)
|
|
207
|
+
print("[install] remove these files to re-run install")
|
|
208
|
+
return 1
|
|
209
|
+
print("[install] step 1/2: shell integration")
|
|
195
210
|
release.ensure_environment()
|
|
196
|
-
|
|
211
|
+
print("[install] step 2/2: baseline snapshot")
|
|
212
|
+
progress = snapshot.ProgressReporter("scan")
|
|
213
|
+
snapshot.create_baseline(cfg, prompt_overwrite=True, progress=progress)
|
|
197
214
|
return 0
|
|
198
215
|
|
|
199
216
|
|
|
@@ -215,9 +215,12 @@ def _load_template_file(filename, fallback):
|
|
|
215
215
|
|
|
216
216
|
|
|
217
217
|
def write_template(path=None):
|
|
218
|
-
"""Write the main pkgmgr.yaml template."""
|
|
218
|
+
"""Write the main pkgmgr.yaml template. Returns True if written."""
|
|
219
219
|
path = path or DEFAULT_MAIN_CONFIG
|
|
220
220
|
target = os.path.realpath(os.path.abspath(os.path.expanduser(path)))
|
|
221
|
+
if os.path.exists(target):
|
|
222
|
+
print("[make-config] config already exists at %s; remove it and re-run" % target)
|
|
223
|
+
return False
|
|
221
224
|
parent = os.path.dirname(target)
|
|
222
225
|
if parent and not os.path.exists(parent):
|
|
223
226
|
os.makedirs(parent)
|
|
@@ -225,6 +228,7 @@ def write_template(path=None):
|
|
|
225
228
|
with open(target, "w") as f:
|
|
226
229
|
f.write(content)
|
|
227
230
|
print("[make-config] wrote template to %s" % target)
|
|
231
|
+
return True
|
|
228
232
|
|
|
229
233
|
|
|
230
234
|
def write_pkg_template(path, pkg_id=None, pkg_root=None, include_releases=None, git_cfg=None, collectors_enabled=None):
|
|
@@ -27,6 +27,12 @@ def ensure_path_and_alias(script_dir, alias_name="pkg", command="pkgmgr"):
|
|
|
27
27
|
print("[install] unknown shell '%s'; skipping rc update" % (shell_name or ""))
|
|
28
28
|
return
|
|
29
29
|
|
|
30
|
+
if not _path_contains_dir(script_dir):
|
|
31
|
+
print("[install] PATH missing: %s" % script_dir)
|
|
32
|
+
print("[install] add to PATH, for example:")
|
|
33
|
+
for line in _path_only_instructions(shell_name, script_dir):
|
|
34
|
+
print(" " + line)
|
|
35
|
+
|
|
30
36
|
header = "[install] To use pkgmgr, add these lines to your shell rc:"
|
|
31
37
|
for line in _emit_lines_with_header(header, lines):
|
|
32
38
|
print(line)
|
|
@@ -63,6 +69,37 @@ def _instructions_for_shell(shell_name, script_dir, alias_name, command):
|
|
|
63
69
|
return None
|
|
64
70
|
|
|
65
71
|
|
|
72
|
+
def _path_only_instructions(shell_name, script_dir):
|
|
73
|
+
if shell_name == "bash":
|
|
74
|
+
return ['export PATH="%s:$PATH"' % script_dir]
|
|
75
|
+
if shell_name == "zsh":
|
|
76
|
+
return ['export PATH="%s:$PATH"' % script_dir]
|
|
77
|
+
if shell_name in ("csh", "tcsh"):
|
|
78
|
+
return ["set path = (%s $path)" % script_dir]
|
|
79
|
+
if shell_name == "fish":
|
|
80
|
+
return ["set -U fish_user_paths %s $fish_user_paths" % script_dir]
|
|
81
|
+
return ['export PATH="%s:$PATH"' % script_dir]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _path_contains_dir(path):
|
|
85
|
+
if not path:
|
|
86
|
+
return False
|
|
87
|
+
try:
|
|
88
|
+
target = os.path.realpath(os.path.abspath(os.path.expanduser(path)))
|
|
89
|
+
except Exception:
|
|
90
|
+
target = path
|
|
91
|
+
for entry in os.environ.get("PATH", "").split(os.pathsep):
|
|
92
|
+
if not entry:
|
|
93
|
+
continue
|
|
94
|
+
try:
|
|
95
|
+
entry_path = os.path.realpath(os.path.abspath(os.path.expanduser(entry)))
|
|
96
|
+
except Exception:
|
|
97
|
+
entry_path = entry
|
|
98
|
+
if entry_path == target:
|
|
99
|
+
return True
|
|
100
|
+
return False
|
|
101
|
+
|
|
102
|
+
|
|
66
103
|
def _emit_lines_with_header(header, lines):
|
|
67
104
|
out = [header]
|
|
68
105
|
out.extend(lines)
|
|
@@ -17,6 +17,69 @@ class DuplicateBaselineError(RuntimeError):
|
|
|
17
17
|
"""Raised when attempting to create a baseline that already exists."""
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
class ProgressReporter(object):
|
|
21
|
+
"""TTY-friendly one-line progress reporter (no-op when stdout is not a TTY)."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, prefix):
|
|
24
|
+
self.prefix = prefix
|
|
25
|
+
self._is_tty = sys.stdout.isatty()
|
|
26
|
+
self._last_len = 0
|
|
27
|
+
self._label = None
|
|
28
|
+
self._total = 0
|
|
29
|
+
self._current = 0
|
|
30
|
+
|
|
31
|
+
def start(self, label, total):
|
|
32
|
+
if not self._is_tty:
|
|
33
|
+
return
|
|
34
|
+
self._label = label
|
|
35
|
+
self._total = int(total or 0)
|
|
36
|
+
self._current = 0
|
|
37
|
+
self._render()
|
|
38
|
+
|
|
39
|
+
def advance(self, step=1):
|
|
40
|
+
if not self._is_tty:
|
|
41
|
+
return
|
|
42
|
+
self._current += int(step or 0)
|
|
43
|
+
if self._current > self._total:
|
|
44
|
+
self._current = self._total
|
|
45
|
+
self._render()
|
|
46
|
+
|
|
47
|
+
def finish(self):
|
|
48
|
+
if not self._is_tty:
|
|
49
|
+
return
|
|
50
|
+
if self._total == 0:
|
|
51
|
+
self._current = 0
|
|
52
|
+
else:
|
|
53
|
+
self._current = self._total
|
|
54
|
+
self._render(final=True)
|
|
55
|
+
sys.stdout.write("\n")
|
|
56
|
+
sys.stdout.flush()
|
|
57
|
+
|
|
58
|
+
def _render(self, final=False):
|
|
59
|
+
total = self._total
|
|
60
|
+
current = self._current
|
|
61
|
+
denom = total if total > 0 else 1
|
|
62
|
+
pct = int((float(current) / float(denom)) * 100)
|
|
63
|
+
if total == 0 and final:
|
|
64
|
+
pct = 100
|
|
65
|
+
bar_len = 30
|
|
66
|
+
filled = int((float(current) / float(denom)) * bar_len)
|
|
67
|
+
bar = "#" * filled + "-" * (bar_len - filled)
|
|
68
|
+
label = self._label or ""
|
|
69
|
+
line = "[%s] %s %d/%d %3d%% [%s]" % (
|
|
70
|
+
self.prefix,
|
|
71
|
+
label,
|
|
72
|
+
current,
|
|
73
|
+
total,
|
|
74
|
+
pct,
|
|
75
|
+
bar,
|
|
76
|
+
)
|
|
77
|
+
pad = " " * max(0, self._last_len - len(line))
|
|
78
|
+
sys.stdout.write("\r" + line + pad)
|
|
79
|
+
sys.stdout.flush()
|
|
80
|
+
self._last_len = len(line)
|
|
81
|
+
|
|
82
|
+
|
|
20
83
|
def _ensure_state_dir():
|
|
21
84
|
if not os.path.exists(STATE_DIR):
|
|
22
85
|
os.makedirs(STATE_DIR)
|
|
@@ -43,12 +106,27 @@ def _should_skip(relpath, patterns):
|
|
|
43
106
|
return False
|
|
44
107
|
|
|
45
108
|
|
|
46
|
-
def
|
|
109
|
+
def _count_files(root_abs, exclude):
|
|
110
|
+
total = 0
|
|
111
|
+
for base, _, files in os.walk(root_abs):
|
|
112
|
+
for name in files:
|
|
113
|
+
abspath = os.path.join(base, name)
|
|
114
|
+
rel = os.path.relpath(abspath, root_abs).replace("\\", "/")
|
|
115
|
+
if _should_skip(rel, exclude):
|
|
116
|
+
continue
|
|
117
|
+
total += 1
|
|
118
|
+
return total
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _scan(root, exclude, progress=None, label=None):
|
|
47
122
|
res = {}
|
|
48
123
|
root_abs = os.path.abspath(os.path.expanduser(root))
|
|
49
124
|
if not os.path.exists(root_abs):
|
|
50
125
|
print("[snap] skip missing root: %s" % root_abs)
|
|
51
126
|
return res
|
|
127
|
+
if progress and label:
|
|
128
|
+
total = _count_files(root_abs, exclude)
|
|
129
|
+
progress.start(label, total)
|
|
52
130
|
for base, _, files in os.walk(root_abs):
|
|
53
131
|
for name in files:
|
|
54
132
|
abspath = os.path.join(base, name)
|
|
@@ -64,6 +142,10 @@ def _scan(root, exclude):
|
|
|
64
142
|
}
|
|
65
143
|
except Exception as e:
|
|
66
144
|
print("[snap] warn skip %s: %s" % (abspath, str(e)))
|
|
145
|
+
if progress:
|
|
146
|
+
progress.advance()
|
|
147
|
+
if progress and label:
|
|
148
|
+
progress.finish()
|
|
67
149
|
return res
|
|
68
150
|
|
|
69
151
|
|
|
@@ -88,7 +170,7 @@ def _maybe_keep_existing_baseline(path, prompt_overwrite):
|
|
|
88
170
|
return None
|
|
89
171
|
|
|
90
172
|
|
|
91
|
-
def _scan_artifacts(cfg):
|
|
173
|
+
def _scan_artifacts(cfg, progress=None):
|
|
92
174
|
"""
|
|
93
175
|
Scan artifact roots/targets similar to sources.
|
|
94
176
|
artifacts.root: base path (optional)
|
|
@@ -109,11 +191,12 @@ def _scan_artifacts(cfg):
|
|
|
109
191
|
else:
|
|
110
192
|
target_path = target_str
|
|
111
193
|
target_path = os.path.abspath(os.path.expanduser(target_path))
|
|
112
|
-
|
|
194
|
+
label = "artifact %s" % target_path
|
|
195
|
+
result[target_path] = _scan(target_path, art_exclude, progress=progress, label=label)
|
|
113
196
|
return result
|
|
114
197
|
|
|
115
198
|
|
|
116
|
-
def create_baseline(cfg, prompt_overwrite=False):
|
|
199
|
+
def create_baseline(cfg, prompt_overwrite=False, progress=None):
|
|
117
200
|
"""
|
|
118
201
|
Collect initial baseline snapshot.
|
|
119
202
|
Scans sources and artifacts (if configured).
|
|
@@ -132,9 +215,12 @@ def create_baseline(cfg, prompt_overwrite=False):
|
|
|
132
215
|
}
|
|
133
216
|
|
|
134
217
|
for root in sources:
|
|
135
|
-
|
|
218
|
+
label = "source %s" % root
|
|
219
|
+
snapshot_data["sources"][root] = _scan(
|
|
220
|
+
root, src_exclude, progress=progress, label=label
|
|
221
|
+
)
|
|
136
222
|
|
|
137
|
-
snapshot_data["artifacts"] = _scan_artifacts(cfg)
|
|
223
|
+
snapshot_data["artifacts"] = _scan_artifacts(cfg, progress=progress)
|
|
138
224
|
|
|
139
225
|
path = os.path.join(STATE_DIR, "baseline.json")
|
|
140
226
|
existing = _maybe_keep_existing_baseline(path, prompt_overwrite)
|
|
@@ -150,7 +236,7 @@ def create_baseline(cfg, prompt_overwrite=False):
|
|
|
150
236
|
return snapshot_data
|
|
151
237
|
|
|
152
238
|
|
|
153
|
-
def create_snapshot(cfg):
|
|
239
|
+
def create_snapshot(cfg, progress=None):
|
|
154
240
|
"""
|
|
155
241
|
Collect a fresh snapshot (for updates).
|
|
156
242
|
"""
|
|
@@ -168,9 +254,12 @@ def create_snapshot(cfg):
|
|
|
168
254
|
}
|
|
169
255
|
|
|
170
256
|
for root in sources:
|
|
171
|
-
|
|
257
|
+
label = "source %s" % root
|
|
258
|
+
snapshot_data["sources"][root] = _scan(
|
|
259
|
+
root, src_exclude, progress=progress, label=label
|
|
260
|
+
)
|
|
172
261
|
|
|
173
|
-
snapshot_data["artifacts"] = _scan_artifacts(cfg)
|
|
262
|
+
snapshot_data["artifacts"] = _scan_artifacts(cfg, progress=progress)
|
|
174
263
|
|
|
175
264
|
path = os.path.join(STATE_DIR, "snapshot.json")
|
|
176
265
|
f = open(path, "w")
|
{pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/SOURCES.txt
RENAMED
|
@@ -23,6 +23,8 @@ pkgmgr_kunrunic.egg-info/entry_points.txt
|
|
|
23
23
|
pkgmgr_kunrunic.egg-info/not-zip-safe
|
|
24
24
|
pkgmgr_kunrunic.egg-info/requires.txt
|
|
25
25
|
pkgmgr_kunrunic.egg-info/top_level.txt
|
|
26
|
+
tests/test_cli_install.py
|
|
26
27
|
tests/test_config.py
|
|
28
|
+
tests/test_progress.py
|
|
27
29
|
tests/test_release.py
|
|
28
30
|
tests/test_snapshot.py
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import tempfile
|
|
4
|
+
from importlib import import_module, reload
|
|
5
|
+
from types import SimpleNamespace
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
9
|
+
if str(ROOT) not in sys.path:
|
|
10
|
+
sys.path.insert(0, str(ROOT))
|
|
11
|
+
|
|
12
|
+
cli = import_module("pkgmgr.cli")
|
|
13
|
+
config = import_module("pkgmgr.config")
|
|
14
|
+
release = import_module("pkgmgr.release")
|
|
15
|
+
snapshot = import_module("pkgmgr.snapshot")
|
|
16
|
+
reload(cli)
|
|
17
|
+
reload(config)
|
|
18
|
+
reload(release)
|
|
19
|
+
reload(snapshot)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _setup_paths(monkeypatch, base):
|
|
23
|
+
monkeypatch.setattr(config, "BASE_DIR", str(base))
|
|
24
|
+
state_dir = os.path.join(str(base), "local", "state")
|
|
25
|
+
monkeypatch.setattr(config, "DEFAULT_STATE_DIR", state_dir)
|
|
26
|
+
monkeypatch.setattr(snapshot, "STATE_DIR", state_dir)
|
|
27
|
+
return state_dir
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_install_aborts_when_readme_exists(monkeypatch):
|
|
31
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
32
|
+
base = Path(tmp)
|
|
33
|
+
_setup_paths(monkeypatch, base)
|
|
34
|
+
readme = base / "README.txt"
|
|
35
|
+
readme.write_text("existing")
|
|
36
|
+
|
|
37
|
+
calls = {"env": 0, "baseline": 0}
|
|
38
|
+
monkeypatch.setattr(config, "load_main", lambda *_args, **_kwargs: {})
|
|
39
|
+
monkeypatch.setattr(release, "ensure_environment", lambda: calls.__setitem__("env", 1))
|
|
40
|
+
monkeypatch.setattr(snapshot, "create_baseline", lambda *_a, **_k: calls.__setitem__("baseline", 1))
|
|
41
|
+
|
|
42
|
+
rc = cli._handle_install(SimpleNamespace(config=None))
|
|
43
|
+
|
|
44
|
+
assert rc == 1
|
|
45
|
+
assert calls["env"] == 0
|
|
46
|
+
assert calls["baseline"] == 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_install_aborts_when_baseline_exists(monkeypatch):
|
|
50
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
51
|
+
base = Path(tmp)
|
|
52
|
+
state_dir = _setup_paths(monkeypatch, base)
|
|
53
|
+
Path(state_dir).mkdir(parents=True, exist_ok=True)
|
|
54
|
+
baseline = Path(state_dir) / "baseline.json"
|
|
55
|
+
baseline.write_text("{}")
|
|
56
|
+
|
|
57
|
+
calls = {"env": 0, "baseline": 0}
|
|
58
|
+
monkeypatch.setattr(config, "load_main", lambda *_args, **_kwargs: {})
|
|
59
|
+
monkeypatch.setattr(release, "ensure_environment", lambda: calls.__setitem__("env", 1))
|
|
60
|
+
monkeypatch.setattr(snapshot, "create_baseline", lambda *_a, **_k: calls.__setitem__("baseline", 1))
|
|
61
|
+
|
|
62
|
+
rc = cli._handle_install(SimpleNamespace(config=None))
|
|
63
|
+
|
|
64
|
+
assert rc == 1
|
|
65
|
+
assert calls["env"] == 0
|
|
66
|
+
assert calls["baseline"] == 0
|
|
@@ -73,7 +73,19 @@ def test_write_template_respects_overridden_default_path(monkeypatch):
|
|
|
73
73
|
|
|
74
74
|
assert target.exists()
|
|
75
75
|
content = target.read_text()
|
|
76
|
-
|
|
76
|
+
assert "pkg_release_root" in content
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_write_template_skips_when_existing(monkeypatch):
|
|
80
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
81
|
+
target = Path(tmp) / "pkgmgr.yaml"
|
|
82
|
+
target.write_text("keep: true\n")
|
|
83
|
+
monkeypatch.setattr(config, "DEFAULT_MAIN_CONFIG", str(target))
|
|
84
|
+
|
|
85
|
+
wrote = config.write_template()
|
|
86
|
+
|
|
87
|
+
assert wrote is False
|
|
88
|
+
assert target.read_text() == "keep: true\n"
|
|
77
89
|
|
|
78
90
|
|
|
79
91
|
def test_load_main_applies_defaults_and_validation():
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from importlib import import_module, reload
|
|
3
|
+
|
|
4
|
+
snapshot = import_module("pkgmgr.snapshot")
|
|
5
|
+
reload(snapshot)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_progress_reporter_tty_outputs_single_line(capsys, monkeypatch):
|
|
9
|
+
monkeypatch.setattr(sys.stdout, "isatty", lambda: True)
|
|
10
|
+
reporter = snapshot.ProgressReporter("scan")
|
|
11
|
+
|
|
12
|
+
reporter.start("source /tmp", 3)
|
|
13
|
+
reporter.advance()
|
|
14
|
+
reporter.advance()
|
|
15
|
+
reporter.finish()
|
|
16
|
+
|
|
17
|
+
out = capsys.readouterr().out
|
|
18
|
+
assert "\r[scan]" in out
|
|
19
|
+
assert "source /tmp" in out
|
|
20
|
+
assert out.endswith("\n")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_progress_reporter_non_tty_is_silent(capsys, monkeypatch):
|
|
24
|
+
monkeypatch.setattr(sys.stdout, "isatty", lambda: False)
|
|
25
|
+
reporter = snapshot.ProgressReporter("scan")
|
|
26
|
+
|
|
27
|
+
reporter.start("source /tmp", 3)
|
|
28
|
+
reporter.advance()
|
|
29
|
+
reporter.finish()
|
|
30
|
+
|
|
31
|
+
out = capsys.readouterr().out
|
|
32
|
+
assert out == ""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/templates/pkgmgr.yaml.sample
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/requires.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev9 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|