godot-visual-smoke-test-kit 0.1.0__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.
Files changed (24) hide show
  1. godot_visual_smoke_test_kit-0.1.0/LICENSE +21 -0
  2. godot_visual_smoke_test_kit-0.1.0/PKG-INFO +79 -0
  3. godot_visual_smoke_test_kit-0.1.0/README.md +56 -0
  4. godot_visual_smoke_test_kit-0.1.0/pyproject.toml +41 -0
  5. godot_visual_smoke_test_kit-0.1.0/setup.cfg +4 -0
  6. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/__init__.py +3 -0
  7. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/__main__.py +5 -0
  8. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/approve.py +9 -0
  9. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/cli.py +118 -0
  10. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/config.py +26 -0
  11. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/diff.py +67 -0
  12. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/models.py +54 -0
  13. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/reporting.py +21 -0
  14. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke/runner.py +28 -0
  15. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke_test_kit.egg-info/PKG-INFO +79 -0
  16. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke_test_kit.egg-info/SOURCES.txt +22 -0
  17. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke_test_kit.egg-info/dependency_links.txt +1 -0
  18. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke_test_kit.egg-info/entry_points.txt +2 -0
  19. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke_test_kit.egg-info/requires.txt +1 -0
  20. godot_visual_smoke_test_kit-0.1.0/src/godot_visual_smoke_test_kit.egg-info/top_level.txt +1 -0
  21. godot_visual_smoke_test_kit-0.1.0/tests/test_approve_runner.py +71 -0
  22. godot_visual_smoke_test_kit-0.1.0/tests/test_cli.py +50 -0
  23. godot_visual_smoke_test_kit-0.1.0/tests/test_config.py +39 -0
  24. godot_visual_smoke_test_kit-0.1.0/tests/test_diff.py +44 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Godot Visual Smoke Test Kit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: godot-visual-smoke-test-kit
3
+ Version: 0.1.0
4
+ Summary: Screenshot diff and baseline helpers for Godot visual smoke tests.
5
+ Author: Godot Visual Smoke Test Kit contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/NonniGB/godot-production-toolkit/tree/main/godot-visual-smoke-test-kit
8
+ Project-URL: Issues, https://github.com/NonniGB/godot-production-toolkit/issues
9
+ Keywords: godot,screenshot,visual-regression,ci,gamedev
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Multimedia :: Graphics
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: Pillow>=10
22
+ Dynamic: license-file
23
+
24
+ # Godot Visual Smoke Test Kit
25
+
26
+ Screenshot diff and baseline helpers for Godot visual smoke tests. It reads scene/viewport config, compares PNG screenshots, writes diff images, approves baselines, and prints planned Godot capture commands.
27
+
28
+ The first release keeps Godot execution out of unit tests, so the package is easy to run in CI and safe to develop without a specific engine install.
29
+
30
+ ## Install
31
+
32
+ ```powershell
33
+ python -m pip install -e .
34
+ ```
35
+
36
+ When published:
37
+
38
+ ```powershell
39
+ python -m pip install godot-visual-smoke-test-kit
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```powershell
45
+ godot-visual-smoke plan visual-smoke.toml --project . --godot C:\Tools\Godot.exe
46
+ godot-visual-smoke plan visual-smoke.toml --project . --format json
47
+ godot-visual-smoke compare baselines\menu.png current\menu.png --diff diffs\menu.png
48
+ godot-visual-smoke approve current\menu.png baselines\menu.png
49
+ godot-visual-smoke compare baselines\menu.png current\menu.png --format json --output visual-report.json
50
+ ```
51
+
52
+ ## What It Does
53
+
54
+ - Parses `visual-smoke.toml`.
55
+ - Supports named viewport presets.
56
+ - Compares baseline and current PNG screenshots.
57
+ - Applies per-channel pixel tolerance.
58
+ - Fails when changed pixel percentage exceeds the configured threshold.
59
+ - Writes red diff images.
60
+ - Copies approved screenshots into baseline paths.
61
+ - Prints Godot capture commands for a project-owned helper script.
62
+
63
+ ## Documentation
64
+
65
+ - [Configuration](docs/CONFIGURATION.md)
66
+ - [Baseline workflow](docs/BASELINES.md)
67
+ - [Godot capture integration](docs/GODOT_CAPTURE.md)
68
+ - [CI usage](docs/CI.md)
69
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
70
+
71
+ ## Development
72
+
73
+ ```powershell
74
+ python -m pip install -e .
75
+ python -m unittest discover -s tests -v
76
+ godot-visual-smoke plan examples\visual-smoke.toml --project examples\tiny-godot-project
77
+ ```
78
+
79
+ Examples are generic. Do not publish screenshots from private projects unless they have been reviewed.
@@ -0,0 +1,56 @@
1
+ # Godot Visual Smoke Test Kit
2
+
3
+ Screenshot diff and baseline helpers for Godot visual smoke tests. It reads scene/viewport config, compares PNG screenshots, writes diff images, approves baselines, and prints planned Godot capture commands.
4
+
5
+ The first release keeps Godot execution out of unit tests, so the package is easy to run in CI and safe to develop without a specific engine install.
6
+
7
+ ## Install
8
+
9
+ ```powershell
10
+ python -m pip install -e .
11
+ ```
12
+
13
+ When published:
14
+
15
+ ```powershell
16
+ python -m pip install godot-visual-smoke-test-kit
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```powershell
22
+ godot-visual-smoke plan visual-smoke.toml --project . --godot C:\Tools\Godot.exe
23
+ godot-visual-smoke plan visual-smoke.toml --project . --format json
24
+ godot-visual-smoke compare baselines\menu.png current\menu.png --diff diffs\menu.png
25
+ godot-visual-smoke approve current\menu.png baselines\menu.png
26
+ godot-visual-smoke compare baselines\menu.png current\menu.png --format json --output visual-report.json
27
+ ```
28
+
29
+ ## What It Does
30
+
31
+ - Parses `visual-smoke.toml`.
32
+ - Supports named viewport presets.
33
+ - Compares baseline and current PNG screenshots.
34
+ - Applies per-channel pixel tolerance.
35
+ - Fails when changed pixel percentage exceeds the configured threshold.
36
+ - Writes red diff images.
37
+ - Copies approved screenshots into baseline paths.
38
+ - Prints Godot capture commands for a project-owned helper script.
39
+
40
+ ## Documentation
41
+
42
+ - [Configuration](docs/CONFIGURATION.md)
43
+ - [Baseline workflow](docs/BASELINES.md)
44
+ - [Godot capture integration](docs/GODOT_CAPTURE.md)
45
+ - [CI usage](docs/CI.md)
46
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
47
+
48
+ ## Development
49
+
50
+ ```powershell
51
+ python -m pip install -e .
52
+ python -m unittest discover -s tests -v
53
+ godot-visual-smoke plan examples\visual-smoke.toml --project examples\tiny-godot-project
54
+ ```
55
+
56
+ Examples are generic. Do not publish screenshots from private projects unless they have been reviewed.
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "godot-visual-smoke-test-kit"
7
+ version = "0.1.0"
8
+ description = "Screenshot diff and baseline helpers for Godot visual smoke tests."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ authors = [{ name = "Godot Visual Smoke Test Kit contributors" }]
13
+ keywords = ["godot", "screenshot", "visual-regression", "ci", "gamedev"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Multimedia :: Graphics",
22
+ "Topic :: Software Development :: Quality Assurance"
23
+ ]
24
+ dependencies = ["Pillow>=10"]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/NonniGB/godot-production-toolkit/tree/main/godot-visual-smoke-test-kit"
28
+ Issues = "https://github.com/NonniGB/godot-production-toolkit/issues"
29
+
30
+ [project.scripts]
31
+ godot-visual-smoke = "godot_visual_smoke.cli:entrypoint"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
35
+
36
+ [tool.ruff]
37
+ line-length = 100
38
+ target-version = "py311"
39
+
40
+ [tool.ruff.lint]
41
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Godot visual smoke testing helpers."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ from .cli import entrypoint
2
+
3
+
4
+ if __name__ == "__main__":
5
+ entrypoint()
@@ -0,0 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ import shutil
4
+ from pathlib import Path
5
+
6
+
7
+ def approve_baseline(current: Path, baseline: Path) -> None:
8
+ baseline.parent.mkdir(parents=True, exist_ok=True)
9
+ shutil.copyfile(current, baseline)
@@ -0,0 +1,118 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ from .approve import approve_baseline
9
+ from .config import load_config
10
+ from .diff import compare_images
11
+ from .reporting import render_json_result, render_text_result
12
+ from .runner import build_godot_command
13
+
14
+
15
+ def main(argv: list[str] | None = None) -> int:
16
+ parser = _build_parser()
17
+ args = parser.parse_args(argv)
18
+ if args.command == "compare":
19
+ return _compare(args)
20
+ if args.command == "approve":
21
+ approve_baseline(Path(args.current), Path(args.baseline))
22
+ return 0
23
+ if args.command == "plan":
24
+ return _plan(args)
25
+ parser.print_help()
26
+ return 2
27
+
28
+
29
+ def entrypoint() -> None:
30
+ raise SystemExit(main())
31
+
32
+
33
+ def _build_parser() -> argparse.ArgumentParser:
34
+ parser = argparse.ArgumentParser(
35
+ prog="godot-visual-smoke",
36
+ description="Compare and approve Godot visual smoke screenshots.",
37
+ )
38
+ parser.add_argument("--version", action="version", version="godot-visual-smoke 0.1.0")
39
+ subparsers = parser.add_subparsers(dest="command")
40
+
41
+ compare = subparsers.add_parser("compare", help="Compare baseline and current screenshots.")
42
+ compare.add_argument("baseline")
43
+ compare.add_argument("current")
44
+ compare.add_argument("--diff", help="Optional diff image path.")
45
+ compare.add_argument("--pixel-tolerance", type=int, default=0)
46
+ compare.add_argument("--max-changed-percent", type=float, default=0.0)
47
+ compare.add_argument("--format", choices=["text", "json"], default="text")
48
+ compare.add_argument("--output")
49
+ compare.add_argument("--fail-on", choices=["diff", "none"], default="diff")
50
+
51
+ approve = subparsers.add_parser("approve", help="Copy current screenshot to baseline.")
52
+ approve.add_argument("current")
53
+ approve.add_argument("baseline")
54
+
55
+ plan = subparsers.add_parser("plan", help="Print Godot capture commands from visual-smoke.toml.")
56
+ plan.add_argument("config")
57
+ plan.add_argument("--project", required=True)
58
+ plan.add_argument("--godot", default="godot")
59
+ plan.add_argument("--format", choices=["text", "json"], default="text")
60
+ return parser
61
+
62
+
63
+ def _compare(args: argparse.Namespace) -> int:
64
+ result = compare_images(
65
+ Path(args.baseline),
66
+ Path(args.current),
67
+ diff_path=Path(args.diff) if args.diff else None,
68
+ pixel_tolerance=args.pixel_tolerance,
69
+ max_changed_percent=args.max_changed_percent,
70
+ )
71
+ rendered = render_json_result(result) if args.format == "json" else render_text_result(result)
72
+ if args.output:
73
+ output = Path(args.output)
74
+ output.parent.mkdir(parents=True, exist_ok=True)
75
+ output.write_text(rendered + "\n", encoding="utf-8")
76
+ else:
77
+ print(rendered)
78
+ return 1 if args.fail_on == "diff" and not result.passed else 0
79
+
80
+
81
+ def _plan(args: argparse.Namespace) -> int:
82
+ config = load_config(Path(args.config))
83
+ planned_commands = []
84
+ for scene in config.scenes:
85
+ viewport = config.viewports[scene.viewport]
86
+ output = Path(config.output_dir) / f"{scene.name}.png"
87
+ command = build_godot_command(
88
+ godot=Path(args.godot),
89
+ project=Path(args.project),
90
+ scene=scene.path,
91
+ width=viewport.width,
92
+ height=viewport.height,
93
+ output=output,
94
+ )
95
+ planned_commands.append(
96
+ {
97
+ "name": scene.name,
98
+ "scene": scene.path,
99
+ "viewport": {
100
+ "name": viewport.name,
101
+ "width": viewport.width,
102
+ "height": viewport.height,
103
+ },
104
+ "output": str(output),
105
+ "command": command,
106
+ "shell": " ".join(command),
107
+ }
108
+ )
109
+ if args.format == "json":
110
+ print(json.dumps({"commands": planned_commands}, indent=2, sort_keys=True))
111
+ else:
112
+ for planned in planned_commands:
113
+ print(planned["shell"])
114
+ return 0
115
+
116
+
117
+ if __name__ == "__main__":
118
+ sys.exit(main())
@@ -0,0 +1,26 @@
1
+ from __future__ import annotations
2
+
3
+ import tomllib
4
+ from pathlib import Path
5
+
6
+ from .models import SceneSpec, SmokeConfig, Viewport
7
+
8
+
9
+ def load_config(path: Path) -> SmokeConfig:
10
+ data = tomllib.loads(path.read_text(encoding="utf-8"))
11
+ settings = data.get("settings", {})
12
+ viewports = {
13
+ name: Viewport(name=name, width=int(values["width"]), height=int(values["height"]))
14
+ for name, values in data.get("viewports", {}).items()
15
+ }
16
+ scenes = [
17
+ SceneSpec(name=str(scene["name"]), path=str(scene["path"]), viewport=str(scene["viewport"]))
18
+ for scene in data.get("scenes", [])
19
+ ]
20
+ return SmokeConfig(
21
+ pixel_tolerance=int(settings.get("pixel_tolerance", 0)),
22
+ max_changed_percent=float(settings.get("max_changed_percent", 0.0)),
23
+ output_dir=str(settings.get("output_dir", "visual-smoke-output")),
24
+ viewports=viewports,
25
+ scenes=scenes,
26
+ )
@@ -0,0 +1,67 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from PIL import Image
6
+
7
+ from .models import DiffResult
8
+
9
+
10
+ def compare_images(
11
+ baseline: Path,
12
+ current: Path,
13
+ *,
14
+ diff_path: Path | None = None,
15
+ pixel_tolerance: int = 0,
16
+ max_changed_percent: float = 0.0,
17
+ ) -> DiffResult:
18
+ with Image.open(baseline) as baseline_image, Image.open(current) as current_image:
19
+ base = baseline_image.convert("RGBA")
20
+ curr = current_image.convert("RGBA")
21
+ if base.size != curr.size:
22
+ width, height = curr.size
23
+ total = width * height
24
+ return DiffResult(
25
+ str(baseline),
26
+ str(current),
27
+ width,
28
+ height,
29
+ total,
30
+ total,
31
+ 100.0,
32
+ 255,
33
+ False,
34
+ reason=f"Image size differs: baseline {base.size}, current {curr.size}.",
35
+ )
36
+
37
+ width, height = base.size
38
+ diff_image = Image.new("RGBA", base.size, (0, 0, 0, 0))
39
+ changed = 0
40
+ max_delta = 0
41
+ for y in range(height):
42
+ for x in range(width):
43
+ base_pixel = base.getpixel((x, y))
44
+ curr_pixel = curr.getpixel((x, y))
45
+ delta = max(abs(base_pixel[index] - curr_pixel[index]) for index in range(4))
46
+ max_delta = max(max_delta, delta)
47
+ if delta > pixel_tolerance:
48
+ changed += 1
49
+ diff_image.putpixel((x, y), (255, 0, 0, 255))
50
+
51
+ total = width * height
52
+ changed_percent = round((changed / total) * 100, 4) if total else 0.0
53
+ passed = changed_percent <= max_changed_percent
54
+ if diff_path:
55
+ diff_path.parent.mkdir(parents=True, exist_ok=True)
56
+ diff_image.save(diff_path)
57
+ return DiffResult(
58
+ str(baseline),
59
+ str(current),
60
+ width,
61
+ height,
62
+ changed,
63
+ total,
64
+ changed_percent,
65
+ max_delta,
66
+ passed,
67
+ )
@@ -0,0 +1,54 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+
5
+
6
+ @dataclass(frozen=True)
7
+ class Viewport:
8
+ name: str
9
+ width: int
10
+ height: int
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class SceneSpec:
15
+ name: str
16
+ path: str
17
+ viewport: str
18
+
19
+
20
+ @dataclass(frozen=True)
21
+ class SmokeConfig:
22
+ pixel_tolerance: int = 0
23
+ max_changed_percent: float = 0.0
24
+ output_dir: str = "visual-smoke-output"
25
+ viewports: dict[str, Viewport] = field(default_factory=dict)
26
+ scenes: list[SceneSpec] = field(default_factory=list)
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class DiffResult:
31
+ baseline: str
32
+ current: str
33
+ width: int
34
+ height: int
35
+ changed_pixels: int
36
+ total_pixels: int
37
+ changed_percent: float
38
+ max_delta: int
39
+ passed: bool
40
+ reason: str = ""
41
+
42
+ def to_dict(self) -> dict[str, object]:
43
+ return {
44
+ "baseline": self.baseline,
45
+ "current": self.current,
46
+ "width": self.width,
47
+ "height": self.height,
48
+ "changed_pixels": self.changed_pixels,
49
+ "total_pixels": self.total_pixels,
50
+ "changed_percent": self.changed_percent,
51
+ "max_delta": self.max_delta,
52
+ "passed": self.passed,
53
+ "reason": self.reason,
54
+ }
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+
5
+ from .models import DiffResult
6
+
7
+
8
+ def render_text_result(result: DiffResult) -> str:
9
+ status = "PASS" if result.passed else "FAIL"
10
+ lines = [
11
+ f"Visual smoke diff: {status}",
12
+ f"Changed pixels: {result.changed_pixels}/{result.total_pixels} ({result.changed_percent:.4f}%).",
13
+ f"Max delta: {result.max_delta}.",
14
+ ]
15
+ if result.reason:
16
+ lines.append(result.reason)
17
+ return "\n".join(lines)
18
+
19
+
20
+ def render_json_result(result: DiffResult) -> str:
21
+ return json.dumps(result.to_dict(), indent=2, sort_keys=True)
@@ -0,0 +1,28 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+
6
+ def build_godot_command(
7
+ *,
8
+ godot: Path,
9
+ project: Path,
10
+ scene: str,
11
+ width: int,
12
+ height: int,
13
+ output: Path,
14
+ ) -> list[str]:
15
+ return [
16
+ str(godot),
17
+ "--headless",
18
+ "--path",
19
+ str(project),
20
+ "--resolution",
21
+ f"{width}x{height}",
22
+ "--script",
23
+ "res://addons/visual_smoke/capture_scene.gd",
24
+ "--scene",
25
+ scene,
26
+ "--output",
27
+ str(output),
28
+ ]
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: godot-visual-smoke-test-kit
3
+ Version: 0.1.0
4
+ Summary: Screenshot diff and baseline helpers for Godot visual smoke tests.
5
+ Author: Godot Visual Smoke Test Kit contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/NonniGB/godot-production-toolkit/tree/main/godot-visual-smoke-test-kit
8
+ Project-URL: Issues, https://github.com/NonniGB/godot-production-toolkit/issues
9
+ Keywords: godot,screenshot,visual-regression,ci,gamedev
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Multimedia :: Graphics
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: Pillow>=10
22
+ Dynamic: license-file
23
+
24
+ # Godot Visual Smoke Test Kit
25
+
26
+ Screenshot diff and baseline helpers for Godot visual smoke tests. It reads scene/viewport config, compares PNG screenshots, writes diff images, approves baselines, and prints planned Godot capture commands.
27
+
28
+ The first release keeps Godot execution out of unit tests, so the package is easy to run in CI and safe to develop without a specific engine install.
29
+
30
+ ## Install
31
+
32
+ ```powershell
33
+ python -m pip install -e .
34
+ ```
35
+
36
+ When published:
37
+
38
+ ```powershell
39
+ python -m pip install godot-visual-smoke-test-kit
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```powershell
45
+ godot-visual-smoke plan visual-smoke.toml --project . --godot C:\Tools\Godot.exe
46
+ godot-visual-smoke plan visual-smoke.toml --project . --format json
47
+ godot-visual-smoke compare baselines\menu.png current\menu.png --diff diffs\menu.png
48
+ godot-visual-smoke approve current\menu.png baselines\menu.png
49
+ godot-visual-smoke compare baselines\menu.png current\menu.png --format json --output visual-report.json
50
+ ```
51
+
52
+ ## What It Does
53
+
54
+ - Parses `visual-smoke.toml`.
55
+ - Supports named viewport presets.
56
+ - Compares baseline and current PNG screenshots.
57
+ - Applies per-channel pixel tolerance.
58
+ - Fails when changed pixel percentage exceeds the configured threshold.
59
+ - Writes red diff images.
60
+ - Copies approved screenshots into baseline paths.
61
+ - Prints Godot capture commands for a project-owned helper script.
62
+
63
+ ## Documentation
64
+
65
+ - [Configuration](docs/CONFIGURATION.md)
66
+ - [Baseline workflow](docs/BASELINES.md)
67
+ - [Godot capture integration](docs/GODOT_CAPTURE.md)
68
+ - [CI usage](docs/CI.md)
69
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
70
+
71
+ ## Development
72
+
73
+ ```powershell
74
+ python -m pip install -e .
75
+ python -m unittest discover -s tests -v
76
+ godot-visual-smoke plan examples\visual-smoke.toml --project examples\tiny-godot-project
77
+ ```
78
+
79
+ Examples are generic. Do not publish screenshots from private projects unless they have been reviewed.
@@ -0,0 +1,22 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/godot_visual_smoke/__init__.py
5
+ src/godot_visual_smoke/__main__.py
6
+ src/godot_visual_smoke/approve.py
7
+ src/godot_visual_smoke/cli.py
8
+ src/godot_visual_smoke/config.py
9
+ src/godot_visual_smoke/diff.py
10
+ src/godot_visual_smoke/models.py
11
+ src/godot_visual_smoke/reporting.py
12
+ src/godot_visual_smoke/runner.py
13
+ src/godot_visual_smoke_test_kit.egg-info/PKG-INFO
14
+ src/godot_visual_smoke_test_kit.egg-info/SOURCES.txt
15
+ src/godot_visual_smoke_test_kit.egg-info/dependency_links.txt
16
+ src/godot_visual_smoke_test_kit.egg-info/entry_points.txt
17
+ src/godot_visual_smoke_test_kit.egg-info/requires.txt
18
+ src/godot_visual_smoke_test_kit.egg-info/top_level.txt
19
+ tests/test_approve_runner.py
20
+ tests/test_cli.py
21
+ tests/test_config.py
22
+ tests/test_diff.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ godot-visual-smoke = godot_visual_smoke.cli:entrypoint
@@ -0,0 +1,71 @@
1
+ import tempfile
2
+ import unittest
3
+ import json
4
+ from contextlib import redirect_stdout
5
+ from io import StringIO
6
+ from pathlib import Path
7
+
8
+ from godot_visual_smoke.cli import main
9
+ from godot_visual_smoke.approve import approve_baseline
10
+ from godot_visual_smoke.runner import build_godot_command
11
+
12
+
13
+ class ApproveRunnerTests(unittest.TestCase):
14
+ def test_approve_copies_current_to_baseline(self) -> None:
15
+ with tempfile.TemporaryDirectory() as tmp:
16
+ root = Path(tmp)
17
+ current = root / "current.png"
18
+ baseline = root / "baselines" / "menu.png"
19
+ current.write_bytes(b"png-data")
20
+
21
+ approve_baseline(current, baseline)
22
+
23
+ self.assertEqual(baseline.read_bytes(), b"png-data")
24
+
25
+ def test_builds_godot_command(self) -> None:
26
+ command = build_godot_command(
27
+ godot=Path("Godot.exe"),
28
+ project=Path("project"),
29
+ scene="res://scenes/menu.tscn",
30
+ width=720,
31
+ height=1280,
32
+ output=Path("out/menu.png"),
33
+ )
34
+
35
+ self.assertIn("--path", command)
36
+ self.assertIn("project", command)
37
+ self.assertIn("--resolution", command)
38
+ self.assertIn("720x1280", command)
39
+
40
+ def test_plan_cli_can_emit_json_for_automation(self) -> None:
41
+ with tempfile.TemporaryDirectory() as tmp:
42
+ root = Path(tmp)
43
+ config = root / "visual-smoke.toml"
44
+ project = root / "project"
45
+ project.mkdir()
46
+ config.write_text(
47
+ """
48
+ [viewports.phone]
49
+ width = 720
50
+ height = 1280
51
+
52
+ [[scenes]]
53
+ name = "menu"
54
+ path = "res://scenes/menu.tscn"
55
+ viewport = "phone"
56
+ """,
57
+ encoding="utf-8",
58
+ )
59
+ stdout = StringIO()
60
+
61
+ with redirect_stdout(stdout):
62
+ exit_code = main(["plan", str(config), "--project", str(project), "--format", "json"])
63
+
64
+ payload = json.loads(stdout.getvalue())
65
+ self.assertEqual(exit_code, 0)
66
+ self.assertEqual(payload["commands"][0]["scene"], "res://scenes/menu.tscn")
67
+ self.assertEqual(payload["commands"][0]["viewport"]["width"], 720)
68
+
69
+
70
+ if __name__ == "__main__":
71
+ unittest.main()
@@ -0,0 +1,50 @@
1
+ from contextlib import redirect_stdout
2
+ from io import StringIO
3
+ import json
4
+ import tempfile
5
+ import unittest
6
+ from pathlib import Path
7
+
8
+ from PIL import Image
9
+
10
+ from godot_visual_smoke.cli import main
11
+
12
+
13
+ class CliTests(unittest.TestCase):
14
+ def test_cli_prints_version(self) -> None:
15
+ stdout = StringIO()
16
+
17
+ with self.assertRaises(SystemExit) as raised:
18
+ with redirect_stdout(stdout):
19
+ main(["--version"])
20
+
21
+ self.assertEqual(raised.exception.code, 0)
22
+ self.assertIn("godot-visual-smoke 0.1.0", stdout.getvalue())
23
+
24
+ def test_compare_cli_writes_json_report(self) -> None:
25
+ with tempfile.TemporaryDirectory() as tmp:
26
+ root = Path(tmp)
27
+ baseline = root / "baseline.png"
28
+ current = root / "current.png"
29
+ output = root / "report.json"
30
+ Image.new("RGBA", (1, 1), (0, 0, 0, 255)).save(baseline)
31
+ Image.new("RGBA", (1, 1), (255, 255, 255, 255)).save(current)
32
+
33
+ exit_code = main(
34
+ [
35
+ "compare",
36
+ str(baseline),
37
+ str(current),
38
+ "--format",
39
+ "json",
40
+ "--output",
41
+ str(output),
42
+ ]
43
+ )
44
+
45
+ self.assertEqual(exit_code, 1)
46
+ self.assertEqual(json.loads(output.read_text(encoding="utf-8"))["changed_pixels"], 1)
47
+
48
+
49
+ if __name__ == "__main__":
50
+ unittest.main()
@@ -0,0 +1,39 @@
1
+ import tempfile
2
+ import unittest
3
+ from pathlib import Path
4
+
5
+ from godot_visual_smoke.config import load_config
6
+
7
+
8
+ class ConfigTests(unittest.TestCase):
9
+ def test_loads_scene_and_viewport_config(self) -> None:
10
+ with tempfile.TemporaryDirectory() as tmp:
11
+ path = Path(tmp) / "visual-smoke.toml"
12
+ path.write_text(
13
+ """
14
+ [settings]
15
+ pixel_tolerance = 2
16
+ max_changed_percent = 0.5
17
+
18
+ [viewports.portrait_phone]
19
+ width = 720
20
+ height = 1280
21
+
22
+ [[scenes]]
23
+ name = "menu"
24
+ path = "res://scenes/menu.tscn"
25
+ viewport = "portrait_phone"
26
+ """,
27
+ encoding="utf-8",
28
+ )
29
+
30
+ config = load_config(path)
31
+
32
+ self.assertEqual(config.pixel_tolerance, 2)
33
+ self.assertEqual(config.max_changed_percent, 0.5)
34
+ self.assertEqual(config.viewports["portrait_phone"].width, 720)
35
+ self.assertEqual(config.scenes[0].path, "res://scenes/menu.tscn")
36
+
37
+
38
+ if __name__ == "__main__":
39
+ unittest.main()
@@ -0,0 +1,44 @@
1
+ import tempfile
2
+ import unittest
3
+ from pathlib import Path
4
+
5
+ from PIL import Image
6
+
7
+ from godot_visual_smoke.diff import compare_images
8
+
9
+
10
+ class DiffTests(unittest.TestCase):
11
+ def test_compare_images_counts_changed_pixels_and_writes_diff(self) -> None:
12
+ with tempfile.TemporaryDirectory() as tmp:
13
+ root = Path(tmp)
14
+ baseline = root / "baseline.png"
15
+ current = root / "current.png"
16
+ diff = root / "diff.png"
17
+ Image.new("RGBA", (2, 2), (0, 0, 0, 255)).save(baseline)
18
+ image = Image.new("RGBA", (2, 2), (0, 0, 0, 255))
19
+ image.putpixel((1, 1), (255, 0, 0, 255))
20
+ image.save(current)
21
+
22
+ result = compare_images(baseline, current, diff_path=diff, pixel_tolerance=0, max_changed_percent=0)
23
+
24
+ self.assertFalse(result.passed)
25
+ self.assertEqual(result.changed_pixels, 1)
26
+ self.assertAlmostEqual(result.changed_percent, 25.0)
27
+ self.assertTrue(diff.exists())
28
+
29
+ def test_compare_images_passes_with_pixel_tolerance(self) -> None:
30
+ with tempfile.TemporaryDirectory() as tmp:
31
+ root = Path(tmp)
32
+ baseline = root / "baseline.png"
33
+ current = root / "current.png"
34
+ Image.new("RGBA", (1, 1), (10, 10, 10, 255)).save(baseline)
35
+ Image.new("RGBA", (1, 1), (11, 10, 10, 255)).save(current)
36
+
37
+ result = compare_images(baseline, current, pixel_tolerance=1, max_changed_percent=0)
38
+
39
+ self.assertTrue(result.passed)
40
+ self.assertEqual(result.changed_pixels, 0)
41
+
42
+
43
+ if __name__ == "__main__":
44
+ unittest.main()