fxcss 0.22.0__tar.gz → 0.23.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.
- {fxcss-0.22.0 → fxcss-0.23.0}/PKG-INFO +53 -9
- {fxcss-0.22.0 → fxcss-0.23.0}/README.md +52 -8
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/__init__.py +1 -1
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/capture.py +5 -1
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/check.py +215 -26
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/cli.py +41 -10
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/compare.py +9 -5
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/complete.py +24 -2
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/core.py +37 -8
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/fetch.py +114 -14
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/scaffold.py +19 -2
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss.egg-info/PKG-INFO +53 -9
- {fxcss-0.22.0 → fxcss-0.23.0}/tests/test_capture_coverage.py +9 -2
- {fxcss-0.22.0 → fxcss-0.23.0}/tests/test_checks.py +124 -1
- {fxcss-0.22.0 → fxcss-0.23.0}/tests/test_units.py +242 -15
- {fxcss-0.22.0 → fxcss-0.23.0}/tests/test_workflows.py +49 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/LICENSE +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/__main__.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/adopt.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/audit.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/catalogue.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/install.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/omni.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/probe.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/sheets.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/firefox-watch.yml +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/pr-preview-cleanup.yml +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/pr-preview-publish.yml +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/pr-preview.yml +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/readme-previews.yml +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/showcase.yml +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/starter/chrome/userChrome.css +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/templates/starter/custom/accent-red.css +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss/tweaks.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss.egg-info/SOURCES.txt +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss.egg-info/dependency_links.txt +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss.egg-info/entry_points.txt +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss.egg-info/requires.txt +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/fxcss.egg-info/top_level.txt +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/pyproject.toml +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/setup.cfg +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/tests/test_patch_duplicates.py +0 -0
- {fxcss-0.22.0 → fxcss-0.23.0}/tests/test_profile_safety.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fxcss
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: Live-reload, inspect and screenshot-test Firefox userChrome.css themes
|
|
5
5
|
Author: AdamXweb
|
|
6
6
|
License: MIT
|
|
@@ -21,6 +21,7 @@ Provides-Extra: images
|
|
|
21
21
|
Requires-Dist: pillow>=10.1; extra == "images"
|
|
22
22
|
Dynamic: license-file
|
|
23
23
|
|
|
24
|
+
|
|
24
25
|
# fxcss
|
|
25
26
|
|
|
26
27
|
<p align="center">
|
|
@@ -60,6 +61,9 @@ For local development and testing, run commands from the theme's root (the
|
|
|
60
61
|
folder containing `chrome/`), or pass `--theme /path/to/theme`. Use
|
|
61
62
|
`fxcss <command> --help` for its options.
|
|
62
63
|
|
|
64
|
+
https://github.com/user-attachments/assets/83dc3c67-6cad-432a-b841-d602a135a396
|
|
65
|
+
|
|
66
|
+
|
|
63
67
|
## Explore the toolkit
|
|
64
68
|
|
|
65
69
|
| Section | What you can do |
|
|
@@ -94,6 +98,7 @@ repository to `fxcss try`.
|
|
|
94
98
|
fxcss try adamXweb/WhiteSurFirefoxThemeMacOS
|
|
95
99
|
fxcss try github.com/owner/theme --with compact-tabs
|
|
96
100
|
fxcss try owner/theme --info # report what's there, launch nothing
|
|
101
|
+
fxcss try ~/src/my-theme # a theme folder on this computer
|
|
97
102
|
```
|
|
98
103
|
|
|
99
104
|
**Test-drive a theme before committing to it.** Downloads it, installs it into a
|
|
@@ -130,6 +135,29 @@ a variant without hunting through install flags. `--shot dir` captures the
|
|
|
130
135
|
standard screenshots instead of opening a window, and `--keep dir` leaves the
|
|
131
136
|
download behind so you can start editing it with `watch`.
|
|
132
137
|
|
|
138
|
+
#### Private repositories and local folders
|
|
139
|
+
|
|
140
|
+
A private repository looks exactly like a missing one to anyone who cannot read
|
|
141
|
+
it. fxcss sends `GITHUB_TOKEN` or `GH_TOKEN` when either is set; otherwise, if a
|
|
142
|
+
repository is not publicly visible, it asks the GitHub CLI for its login
|
|
143
|
+
(`gh auth token`) and tries again. So after `gh auth login`, private themes your
|
|
144
|
+
account can read work like public ones. A token also raises GitHub's rate limit.
|
|
145
|
+
|
|
146
|
+
A theme that is not on GitHub, or not pushed yet, can be tried from its folder:
|
|
147
|
+
`fxcss try ~/src/my-theme`. The folder is read where it is and never modified;
|
|
148
|
+
`--with`, `--shot` and `--info` work as usual, while `--ref` and `--commit` do
|
|
149
|
+
not apply.
|
|
150
|
+
|
|
151
|
+
When a repository cannot be read, fxcss says why and what to try next rather
|
|
152
|
+
than printing a traceback:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
error: GitHub has no public repository owner/theme.
|
|
156
|
+
Check the name at https://github.com/owner/theme
|
|
157
|
+
If it is private, sign in with `gh auth login` or set GITHUB_TOKEN to a token that can read it.
|
|
158
|
+
For a theme on this computer, pass its folder instead, such as ~/src/my-theme
|
|
159
|
+
```
|
|
160
|
+
|
|
133
161
|
#### It does not run the theme's install script
|
|
134
162
|
|
|
135
163
|
fxcss installs the theme's files and supported preferences itself. It reports
|
|
@@ -351,8 +379,8 @@ fxcss profiles --json # machine-readable
|
|
|
351
379
|
```
|
|
352
380
|
|
|
353
381
|
Read-only. Firefox keeps its profiles in directories named after a hash, so
|
|
354
|
-
|
|
355
|
-
|
|
382
|
+
it can be hard to tell which profile has the theme by looking at folder
|
|
383
|
+
names:
|
|
356
384
|
|
|
357
385
|
```console
|
|
358
386
|
$ fxcss profiles --check
|
|
@@ -655,6 +683,17 @@ configuration file, it uses installed Stable, captures all optional
|
|
|
655
683
|
stylesheets and fails on actionable selector findings. Visual comparison is
|
|
656
684
|
enabled when you supply a baseline.
|
|
657
685
|
|
|
686
|
+
The terminal shows the current phase and each accounted-for view, including
|
|
687
|
+
views Firefox explicitly does not support, while the full details stay in the
|
|
688
|
+
run logs. The report links directly to each captured screenshot and distinguishes
|
|
689
|
+
a check with no visual baseline from one with advisory image changes. When
|
|
690
|
+
comparing captures, it shows the baseline and current Firefox environments so
|
|
691
|
+
you can spot version, OS, display-scale or window-size differences. If you
|
|
692
|
+
interrupt a run, `check` still writes a report pointing to completed captures;
|
|
693
|
+
views left unfinished are marked separately from failures. Rerun the
|
|
694
|
+
command to finish. If interruption occurs during a baseline update, inspect
|
|
695
|
+
the baseline directory before running another update.
|
|
696
|
+
|
|
658
697
|
Save settings in `.fxcss.json` at the theme's root to use the same checks
|
|
659
698
|
locally and in CI:
|
|
660
699
|
|
|
@@ -704,9 +743,9 @@ operating systems separate. `--firefox beta` overrides the list for one run.
|
|
|
704
743
|
| `--config FILE` | Read a different JSON settings file. Command-line options override saved values. |
|
|
705
744
|
|
|
706
745
|
Exit codes are **0** for completed checks within the configured policy,
|
|
707
|
-
**1** for findings, and **2** for configuration, browser,
|
|
708
|
-
errors. A configured baseline that is missing is an
|
|
709
|
-
result. Invalid settings fail before Firefox is started.
|
|
746
|
+
**1** for findings, and **2** for interruption or configuration, browser,
|
|
747
|
+
capture or comparison errors. A configured baseline that is missing is an
|
|
748
|
+
error, not an unchanged result. Invalid settings fail before Firefox is started.
|
|
710
749
|
|
|
711
750
|
For a custom GitHub workflow with Firefox and a display already available,
|
|
712
751
|
run `fxcss check` and upload `.fxcss/checks/` even when the check fails. Keep the
|
|
@@ -743,7 +782,7 @@ you want plain screenshots — `fxcss compare` writes a different shape, below.
|
|
|
743
782
|
fxcss shot --out shots --variants all
|
|
744
783
|
```
|
|
745
784
|
|
|
746
|
-
`--variants`
|
|
785
|
+
`--variants` also captures one view per optional stylesheet the theme
|
|
747
786
|
ships (`custom/`, `optional/`, `variants/`…), each loaded on its own and removed
|
|
748
787
|
again — so `tabs-swapclose` or `compact-tabs` are checked by CI without a
|
|
749
788
|
separate install. Name specific ones (`--variants a,b`) or take them all.
|
|
@@ -1107,7 +1146,7 @@ text.
|
|
|
1107
1146
|
For a custom workflow, the core capture-and-compare steps are:
|
|
1108
1147
|
|
|
1109
1148
|
```yaml
|
|
1110
|
-
- run: pip install "fxcss[images]==0.22.
|
|
1149
|
+
- run: pip install "fxcss[images]==0.22.1"
|
|
1111
1150
|
- run: fxcss shot --theme base --out shots/base
|
|
1112
1151
|
- run: fxcss shot --theme head --out shots/head
|
|
1113
1152
|
- run: fxcss compare --base shots/base --head shots/head --out out/ --platform ${{ runner.os }}
|
|
@@ -1262,7 +1301,7 @@ the [releases page](https://github.com/AdamXweb/fxcss/releases) has the latest.
|
|
|
1262
1301
|
CI runners' Pythons are not externally managed, so plain pip is fine there:
|
|
1263
1302
|
|
|
1264
1303
|
```bash
|
|
1265
|
-
pip install "fxcss[images]==0.22.
|
|
1304
|
+
pip install "fxcss[images]==0.22.1"
|
|
1266
1305
|
```
|
|
1267
1306
|
|
|
1268
1307
|
Upgrade an existing pipx installation with `pipx upgrade fxcss`.
|
|
@@ -1396,6 +1435,11 @@ Issues and pull requests welcome — particularly landmark definitions for UI
|
|
|
1396
1435
|
parts the catalogue doesn't cover yet, and reports of selectors that changed in
|
|
1397
1436
|
a new Firefox release.
|
|
1398
1437
|
|
|
1438
|
+
The fxcss.com website lives on the repository's
|
|
1439
|
+
[`website` branch](https://github.com/AdamXweb/fxcss/tree/website), with its
|
|
1440
|
+
own README and `just` commands; send website changes there. Its documentation
|
|
1441
|
+
pages are generated from this README.
|
|
1442
|
+
|
|
1399
1443
|
To work on fxcss itself, clone and install it in an editable environment:
|
|
1400
1444
|
|
|
1401
1445
|
```bash
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
# fxcss
|
|
2
3
|
|
|
3
4
|
<p align="center">
|
|
@@ -37,6 +38,9 @@ For local development and testing, run commands from the theme's root (the
|
|
|
37
38
|
folder containing `chrome/`), or pass `--theme /path/to/theme`. Use
|
|
38
39
|
`fxcss <command> --help` for its options.
|
|
39
40
|
|
|
41
|
+
https://github.com/user-attachments/assets/83dc3c67-6cad-432a-b841-d602a135a396
|
|
42
|
+
|
|
43
|
+
|
|
40
44
|
## Explore the toolkit
|
|
41
45
|
|
|
42
46
|
| Section | What you can do |
|
|
@@ -71,6 +75,7 @@ repository to `fxcss try`.
|
|
|
71
75
|
fxcss try adamXweb/WhiteSurFirefoxThemeMacOS
|
|
72
76
|
fxcss try github.com/owner/theme --with compact-tabs
|
|
73
77
|
fxcss try owner/theme --info # report what's there, launch nothing
|
|
78
|
+
fxcss try ~/src/my-theme # a theme folder on this computer
|
|
74
79
|
```
|
|
75
80
|
|
|
76
81
|
**Test-drive a theme before committing to it.** Downloads it, installs it into a
|
|
@@ -107,6 +112,29 @@ a variant without hunting through install flags. `--shot dir` captures the
|
|
|
107
112
|
standard screenshots instead of opening a window, and `--keep dir` leaves the
|
|
108
113
|
download behind so you can start editing it with `watch`.
|
|
109
114
|
|
|
115
|
+
#### Private repositories and local folders
|
|
116
|
+
|
|
117
|
+
A private repository looks exactly like a missing one to anyone who cannot read
|
|
118
|
+
it. fxcss sends `GITHUB_TOKEN` or `GH_TOKEN` when either is set; otherwise, if a
|
|
119
|
+
repository is not publicly visible, it asks the GitHub CLI for its login
|
|
120
|
+
(`gh auth token`) and tries again. So after `gh auth login`, private themes your
|
|
121
|
+
account can read work like public ones. A token also raises GitHub's rate limit.
|
|
122
|
+
|
|
123
|
+
A theme that is not on GitHub, or not pushed yet, can be tried from its folder:
|
|
124
|
+
`fxcss try ~/src/my-theme`. The folder is read where it is and never modified;
|
|
125
|
+
`--with`, `--shot` and `--info` work as usual, while `--ref` and `--commit` do
|
|
126
|
+
not apply.
|
|
127
|
+
|
|
128
|
+
When a repository cannot be read, fxcss says why and what to try next rather
|
|
129
|
+
than printing a traceback:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
error: GitHub has no public repository owner/theme.
|
|
133
|
+
Check the name at https://github.com/owner/theme
|
|
134
|
+
If it is private, sign in with `gh auth login` or set GITHUB_TOKEN to a token that can read it.
|
|
135
|
+
For a theme on this computer, pass its folder instead, such as ~/src/my-theme
|
|
136
|
+
```
|
|
137
|
+
|
|
110
138
|
#### It does not run the theme's install script
|
|
111
139
|
|
|
112
140
|
fxcss installs the theme's files and supported preferences itself. It reports
|
|
@@ -328,8 +356,8 @@ fxcss profiles --json # machine-readable
|
|
|
328
356
|
```
|
|
329
357
|
|
|
330
358
|
Read-only. Firefox keeps its profiles in directories named after a hash, so
|
|
331
|
-
|
|
332
|
-
|
|
359
|
+
it can be hard to tell which profile has the theme by looking at folder
|
|
360
|
+
names:
|
|
333
361
|
|
|
334
362
|
```console
|
|
335
363
|
$ fxcss profiles --check
|
|
@@ -632,6 +660,17 @@ configuration file, it uses installed Stable, captures all optional
|
|
|
632
660
|
stylesheets and fails on actionable selector findings. Visual comparison is
|
|
633
661
|
enabled when you supply a baseline.
|
|
634
662
|
|
|
663
|
+
The terminal shows the current phase and each accounted-for view, including
|
|
664
|
+
views Firefox explicitly does not support, while the full details stay in the
|
|
665
|
+
run logs. The report links directly to each captured screenshot and distinguishes
|
|
666
|
+
a check with no visual baseline from one with advisory image changes. When
|
|
667
|
+
comparing captures, it shows the baseline and current Firefox environments so
|
|
668
|
+
you can spot version, OS, display-scale or window-size differences. If you
|
|
669
|
+
interrupt a run, `check` still writes a report pointing to completed captures;
|
|
670
|
+
views left unfinished are marked separately from failures. Rerun the
|
|
671
|
+
command to finish. If interruption occurs during a baseline update, inspect
|
|
672
|
+
the baseline directory before running another update.
|
|
673
|
+
|
|
635
674
|
Save settings in `.fxcss.json` at the theme's root to use the same checks
|
|
636
675
|
locally and in CI:
|
|
637
676
|
|
|
@@ -681,9 +720,9 @@ operating systems separate. `--firefox beta` overrides the list for one run.
|
|
|
681
720
|
| `--config FILE` | Read a different JSON settings file. Command-line options override saved values. |
|
|
682
721
|
|
|
683
722
|
Exit codes are **0** for completed checks within the configured policy,
|
|
684
|
-
**1** for findings, and **2** for configuration, browser,
|
|
685
|
-
errors. A configured baseline that is missing is an
|
|
686
|
-
result. Invalid settings fail before Firefox is started.
|
|
723
|
+
**1** for findings, and **2** for interruption or configuration, browser,
|
|
724
|
+
capture or comparison errors. A configured baseline that is missing is an
|
|
725
|
+
error, not an unchanged result. Invalid settings fail before Firefox is started.
|
|
687
726
|
|
|
688
727
|
For a custom GitHub workflow with Firefox and a display already available,
|
|
689
728
|
run `fxcss check` and upload `.fxcss/checks/` even when the check fails. Keep the
|
|
@@ -720,7 +759,7 @@ you want plain screenshots — `fxcss compare` writes a different shape, below.
|
|
|
720
759
|
fxcss shot --out shots --variants all
|
|
721
760
|
```
|
|
722
761
|
|
|
723
|
-
`--variants`
|
|
762
|
+
`--variants` also captures one view per optional stylesheet the theme
|
|
724
763
|
ships (`custom/`, `optional/`, `variants/`…), each loaded on its own and removed
|
|
725
764
|
again — so `tabs-swapclose` or `compact-tabs` are checked by CI without a
|
|
726
765
|
separate install. Name specific ones (`--variants a,b`) or take them all.
|
|
@@ -1084,7 +1123,7 @@ text.
|
|
|
1084
1123
|
For a custom workflow, the core capture-and-compare steps are:
|
|
1085
1124
|
|
|
1086
1125
|
```yaml
|
|
1087
|
-
- run: pip install "fxcss[images]==0.22.
|
|
1126
|
+
- run: pip install "fxcss[images]==0.22.1"
|
|
1088
1127
|
- run: fxcss shot --theme base --out shots/base
|
|
1089
1128
|
- run: fxcss shot --theme head --out shots/head
|
|
1090
1129
|
- run: fxcss compare --base shots/base --head shots/head --out out/ --platform ${{ runner.os }}
|
|
@@ -1239,7 +1278,7 @@ the [releases page](https://github.com/AdamXweb/fxcss/releases) has the latest.
|
|
|
1239
1278
|
CI runners' Pythons are not externally managed, so plain pip is fine there:
|
|
1240
1279
|
|
|
1241
1280
|
```bash
|
|
1242
|
-
pip install "fxcss[images]==0.22.
|
|
1281
|
+
pip install "fxcss[images]==0.22.1"
|
|
1243
1282
|
```
|
|
1244
1283
|
|
|
1245
1284
|
Upgrade an existing pipx installation with `pipx upgrade fxcss`.
|
|
@@ -1373,6 +1412,11 @@ Issues and pull requests welcome — particularly landmark definitions for UI
|
|
|
1373
1412
|
parts the catalogue doesn't cover yet, and reports of selectors that changed in
|
|
1374
1413
|
a new Firefox release.
|
|
1375
1414
|
|
|
1415
|
+
The fxcss.com website lives on the repository's
|
|
1416
|
+
[`website` branch](https://github.com/AdamXweb/fxcss/tree/website), with its
|
|
1417
|
+
own README and `just` commands; send website changes there. Its documentation
|
|
1418
|
+
pages are generated from this README.
|
|
1419
|
+
|
|
1376
1420
|
To work on fxcss itself, clone and install it in an editable environment:
|
|
1377
1421
|
|
|
1378
1422
|
```bash
|
|
@@ -18,7 +18,8 @@ def expected_views(variants=(), modes=("light", "dark")):
|
|
|
18
18
|
+ [f"variant-{slug}" for slug in sorted(variants)])
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def write_coverage(directory, info, expected, unsupported=None, failed=None
|
|
21
|
+
def write_coverage(directory, info, expected, unsupported=None, failed=None,
|
|
22
|
+
interrupted=False):
|
|
22
23
|
unsupported, failed = unsupported or {}, failed or {}
|
|
23
24
|
views = {}
|
|
24
25
|
for name in expected:
|
|
@@ -28,6 +29,9 @@ def write_coverage(directory, info, expected, unsupported=None, failed=None):
|
|
|
28
29
|
views[name] = {"status": "captured"}
|
|
29
30
|
elif name in unsupported:
|
|
30
31
|
views[name] = {"status": "unsupported", "reason": unsupported[name]}
|
|
32
|
+
elif interrupted:
|
|
33
|
+
views[name] = {"status": "not_completed",
|
|
34
|
+
"reason": "capture stopped before this view completed"}
|
|
31
35
|
else:
|
|
32
36
|
views[name] = {"status": "failed", "reason": "expected view was not captured"}
|
|
33
37
|
report = {"format": 1, "browser": info, "views": views}
|
|
@@ -6,10 +6,11 @@ import hashlib
|
|
|
6
6
|
import json
|
|
7
7
|
import math
|
|
8
8
|
import shutil
|
|
9
|
+
import sys
|
|
9
10
|
import tempfile
|
|
10
11
|
from pathlib import Path
|
|
11
12
|
|
|
12
|
-
from . import capture, core, __version__
|
|
13
|
+
from . import capture, compare, core, __version__
|
|
13
14
|
from .fetch import VARIANT_DIRS
|
|
14
15
|
|
|
15
16
|
|
|
@@ -110,6 +111,93 @@ def comparison_status(summary, threshold):
|
|
|
110
111
|
return 0
|
|
111
112
|
|
|
112
113
|
|
|
114
|
+
class CaptureProgress:
|
|
115
|
+
"""Keep the full capture log while showing completed views in the terminal."""
|
|
116
|
+
|
|
117
|
+
def __init__(self, log, terminal, total):
|
|
118
|
+
self.log, self.terminal, self.total = log, terminal, total
|
|
119
|
+
self.count = 0
|
|
120
|
+
self.pending = ""
|
|
121
|
+
|
|
122
|
+
def write(self, data):
|
|
123
|
+
written = self.log.write(data)
|
|
124
|
+
self.pending += data
|
|
125
|
+
while "\n" in self.pending:
|
|
126
|
+
line, self.pending = self.pending.split("\n", 1)
|
|
127
|
+
if line.startswith(" captured "):
|
|
128
|
+
self.count += 1
|
|
129
|
+
name = line.removeprefix(" captured ").split(".png", 1)[0]
|
|
130
|
+
print(f" view {self.count}/{self.total}: {name} captured",
|
|
131
|
+
file=self.terminal, flush=True)
|
|
132
|
+
elif line.startswith(" unsupported "):
|
|
133
|
+
self.count += 1
|
|
134
|
+
name, _, reason = line.removeprefix(" unsupported ").partition(": ")
|
|
135
|
+
print(f" view {self.count}/{self.total}: {name} unsupported ({reason})",
|
|
136
|
+
file=self.terminal, flush=True)
|
|
137
|
+
elif line.startswith((" note:", " warning:")):
|
|
138
|
+
print(line, file=self.terminal, flush=True)
|
|
139
|
+
return written
|
|
140
|
+
|
|
141
|
+
def flush(self):
|
|
142
|
+
self.log.flush()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def read_coverage(path):
|
|
146
|
+
if not path.is_file():
|
|
147
|
+
return None
|
|
148
|
+
try:
|
|
149
|
+
report = json.loads(path.read_text(encoding="utf-8"))
|
|
150
|
+
except (OSError, ValueError):
|
|
151
|
+
return None
|
|
152
|
+
return report if isinstance(report, dict) and isinstance(report.get("views"), dict) else None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def last_capture_error(path):
|
|
156
|
+
if not path.is_file():
|
|
157
|
+
return None
|
|
158
|
+
for line in reversed(path.read_text(encoding="utf-8", errors="replace").splitlines()):
|
|
159
|
+
if line.strip().startswith("error:"):
|
|
160
|
+
return line.strip().removeprefix("error:").strip()
|
|
161
|
+
return None
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def result_label(result):
|
|
165
|
+
if result.get("interrupted"):
|
|
166
|
+
return "interrupted"
|
|
167
|
+
status = result["exit_code"]
|
|
168
|
+
if status:
|
|
169
|
+
return ("findings", "error")[status - 1]
|
|
170
|
+
if result.get("comparison", {}).get("any_change"):
|
|
171
|
+
return "passed; visual changes to review"
|
|
172
|
+
if result.get("comparison_note") == "no baseline configured":
|
|
173
|
+
return "passed; visual comparison not run"
|
|
174
|
+
return "passed"
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def environment_label(info):
|
|
178
|
+
"""Describe a capture with the fields that explain visual differences."""
|
|
179
|
+
if not isinstance(info, dict):
|
|
180
|
+
return "unknown environment"
|
|
181
|
+
label = f"Firefox {info.get('version', 'unknown')} on {info.get('os', 'unknown')}"
|
|
182
|
+
details = []
|
|
183
|
+
if info.get("dpr") is not None:
|
|
184
|
+
details.append(f"DPR {info['dpr']}")
|
|
185
|
+
outer = info.get("outer")
|
|
186
|
+
if isinstance(outer, (list, tuple)) and len(outer) == 2:
|
|
187
|
+
details.append(f"window {outer[0]}×{outer[1]}")
|
|
188
|
+
return label + (f" ({', '.join(details)})" if details else "")
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def environment_differences(baseline, current):
|
|
192
|
+
if not isinstance(baseline, dict) or not isinstance(current, dict):
|
|
193
|
+
return []
|
|
194
|
+
fields = (("version", "Firefox version"), ("os", "OS"),
|
|
195
|
+
("dpr", "DPR"), ("outer", "window size"))
|
|
196
|
+
return [label for key, label in fields
|
|
197
|
+
if baseline.get(key) is not None and current.get(key) is not None
|
|
198
|
+
and baseline[key] != current[key]]
|
|
199
|
+
|
|
200
|
+
|
|
113
201
|
BASELINE_MARKER = ".fxcss-baseline.json"
|
|
114
202
|
|
|
115
203
|
|
|
@@ -155,52 +243,119 @@ def update_baseline(baseline, captures):
|
|
|
155
243
|
|
|
156
244
|
|
|
157
245
|
def write_report(directory, settings, results, status, baseline_updated):
|
|
246
|
+
interrupted = any(result.get("interrupted") for result in results)
|
|
158
247
|
report = {
|
|
159
248
|
"fxcss": __version__, "exit_code": status,
|
|
160
249
|
"baseline_updated": baseline_updated,
|
|
250
|
+
"interrupted": interrupted,
|
|
161
251
|
"settings": {k: str(v) if isinstance(v, Path) else v for k, v in settings.items()},
|
|
162
252
|
"browsers": results,
|
|
163
253
|
}
|
|
164
254
|
(directory / "summary.json").write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
|
|
165
|
-
|
|
255
|
+
if interrupted:
|
|
256
|
+
overall = "interrupted"
|
|
257
|
+
elif status == 0 and any(r.get("comparison", {}).get("any_change") for r in results):
|
|
258
|
+
overall = "passed; visual changes to review"
|
|
259
|
+
elif status == 0 and baseline_updated:
|
|
260
|
+
overall = "passed; baseline updated"
|
|
261
|
+
elif status == 0 and settings["baseline"] is None:
|
|
262
|
+
overall = "passed; visual comparison not run"
|
|
263
|
+
else:
|
|
264
|
+
overall = ("passed", "findings", "error")[status]
|
|
265
|
+
lines = ["# Theme check", "", f"Result: **{overall}**", ""]
|
|
166
266
|
for result in results:
|
|
167
267
|
label = result["firefox"].replace("|", "\\|").replace("<", "<")
|
|
168
|
-
lines += [f"## {label}", "", f"Result: **{(
|
|
169
|
-
info = result.get("render_info", {})
|
|
170
|
-
if info:
|
|
171
|
-
lines += [f"Firefox {info.get('version', 'unknown')} on {info.get('os', 'unknown')}", ""]
|
|
268
|
+
lines += [f"## {label}", "", f"Result: **{result_label(result)}**", ""]
|
|
172
269
|
key = result["key"]
|
|
270
|
+
audit_code = result.get("audit_exit_code")
|
|
271
|
+
audit_state = "not completed" if audit_code is None else ("passed", "findings", "error")[audit_code]
|
|
272
|
+
coverage = result.get("coverage", {}).get("views", {})
|
|
273
|
+
info = result.get("render_info") or result.get("coverage", {}).get("browser", {})
|
|
274
|
+
baseline_info = result.get("baseline_info")
|
|
275
|
+
if baseline_info is not None:
|
|
276
|
+
lines += [f"Baseline: {environment_label(baseline_info)} ",
|
|
277
|
+
f"Current: {environment_label(info)}", ""]
|
|
278
|
+
differences = environment_differences(baseline_info, info or {})
|
|
279
|
+
if differences:
|
|
280
|
+
lines += ["Capture environments differ in " + ", ".join(differences)
|
|
281
|
+
+ "; consider this when reviewing visual changes.", ""]
|
|
282
|
+
elif info:
|
|
283
|
+
lines += [environment_label(info), ""]
|
|
284
|
+
captured_count = sum(isinstance(v, dict) and v.get("status") == "captured"
|
|
285
|
+
for v in coverage.values())
|
|
286
|
+
unfinished_count = sum(isinstance(v, dict) and v.get("status") == "not_completed"
|
|
287
|
+
for v in coverage.values())
|
|
288
|
+
partial_counts = [f"{captured_count} captured"]
|
|
289
|
+
if unfinished_count:
|
|
290
|
+
partial_counts.append(f"{unfinished_count} unfinished")
|
|
291
|
+
capture_state = "complete" if result.get("captured") else (
|
|
292
|
+
f"partial ({', '.join(partial_counts)})"
|
|
293
|
+
if captured_count or unfinished_count else "not completed")
|
|
294
|
+
lines += [f"Selector audit: **{audit_state}**", "",
|
|
295
|
+
f"Screenshot capture: **{capture_state}**", ""]
|
|
296
|
+
if result.get("error"):
|
|
297
|
+
lines += ["Error: " + result["error"].replace("<", "<"), ""]
|
|
298
|
+
if unfinished_count:
|
|
299
|
+
lines += [f"{unfinished_count} views did not finish before the interruption.", ""]
|
|
173
300
|
coverage_path = directory / key / "shots" / capture.REPORT
|
|
174
301
|
if coverage_path.is_file():
|
|
175
302
|
lines += [f"- [Screenshot coverage]({key}/shots/{capture.REPORT})"]
|
|
176
|
-
for name, view in
|
|
177
|
-
if view
|
|
178
|
-
lines += [f"-
|
|
303
|
+
for name, view in coverage.items():
|
|
304
|
+
if isinstance(view, dict) and view.get("status") in ("unsupported", "failed"):
|
|
305
|
+
lines += [f"- {view['status'].capitalize()} view `{name}`: "
|
|
306
|
+
f"{view.get('reason', 'no reason recorded')}"]
|
|
179
307
|
for name in ("audit.txt", "capture.txt", "comparison.txt"):
|
|
180
308
|
if (directory / key / name).exists():
|
|
181
309
|
lines.append(f"- [{name}]({key}/{name})")
|
|
182
310
|
if (directory / key / "fix.diff").exists():
|
|
183
311
|
lines.append(f"- [Suggested selector patch]({key}/fix.diff)")
|
|
184
|
-
|
|
312
|
+
image_paths = {path.stem: path for path in (directory / key / "shots").glob("*.png")}
|
|
313
|
+
images = [image_paths.pop(name) for name in coverage if name in image_paths]
|
|
314
|
+
images += sorted(image_paths.values())
|
|
315
|
+
if images:
|
|
316
|
+
partial = ", partial run" if not result.get("captured") else ""
|
|
317
|
+
lines += [f"Captured views ({len(images)}{partial}):", ""]
|
|
318
|
+
for path in images:
|
|
319
|
+
title, mode = compare.title_for(path.stem)
|
|
320
|
+
label = f"{title} ({mode})" if mode in ("light", "dark") else title
|
|
321
|
+
lines += [f"- [{label} (`{path.stem}`)]({key}/shots/{path.name})"]
|
|
322
|
+
lines.append("")
|
|
185
323
|
if "comparison" in result:
|
|
186
324
|
summary = result["comparison"]
|
|
187
|
-
|
|
188
|
-
|
|
325
|
+
advisory = (summary["any_change"] and result["exit_code"] == 0)
|
|
326
|
+
note = " (advisory; no configured limit was exceeded)" if advisory else ""
|
|
327
|
+
lines += [f"Visual comparison: **{len(summary['changed_views'])} changed "
|
|
328
|
+
f"of {len(summary['views'])} shared views{note}**.", ""]
|
|
189
329
|
for heading, field in (("Added", "only_in_head"), ("Missing", "only_in_base")):
|
|
190
330
|
if summary[field]:
|
|
191
331
|
lines += [f"{heading} views: " + ", ".join(f"`{v}`" for v in summary[field]), ""]
|
|
192
332
|
for view in summary["changed_views"]:
|
|
193
|
-
|
|
333
|
+
title = view.get("title") or view["view"]
|
|
334
|
+
lines += [f"- [{title} (`{view['view']}`): {view['percent']:.3f}% changed]"
|
|
194
335
|
f"({key}/diff/{view['image']})"]
|
|
195
336
|
lines.append("")
|
|
196
337
|
else:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
338
|
+
note = result.get("comparison_note", "not completed")
|
|
339
|
+
if note in ("no baseline configured", "baseline update requested"):
|
|
340
|
+
note = f"not run ({note})"
|
|
341
|
+
lines += ["Visual comparison: **" + note + "**.", ""]
|
|
200
342
|
if baseline_updated:
|
|
201
343
|
lines += ["Baseline updated from this run's captures.", ""]
|
|
202
344
|
elif settings["baseline"]:
|
|
203
|
-
|
|
345
|
+
if any(r.get("error") == "check interrupted during baseline update" for r in results):
|
|
346
|
+
lines += ["The baseline update was interrupted. Inspect the baseline directory "
|
|
347
|
+
"before running another update.", ""]
|
|
348
|
+
elif interrupted:
|
|
349
|
+
lines += ["The baseline was left unchanged. Run `fxcss check` again to finish the check.", ""]
|
|
350
|
+
elif status == 2 and any("capture-coverage.json" in r.get("error", "")
|
|
351
|
+
and str(settings["baseline"]) in r.get("error", "")
|
|
352
|
+
for r in results):
|
|
353
|
+
lines += ["The baseline was left unchanged. Create it with "
|
|
354
|
+
"`fxcss check --update-baseline` after reviewing these captures.", ""]
|
|
355
|
+
elif status:
|
|
356
|
+
lines += ["The baseline was left unchanged. Resolve the reported issue before updating it.", ""]
|
|
357
|
+
else:
|
|
358
|
+
lines += ["The baseline was left unchanged. Use `--update-baseline` to accept a successful capture run.", ""]
|
|
204
359
|
(directory / "report.md").write_text("\n".join(lines), encoding="utf-8")
|
|
205
360
|
|
|
206
361
|
|
|
@@ -211,6 +366,8 @@ def run(args):
|
|
|
211
366
|
settings["out"].mkdir(parents=True, exist_ok=True)
|
|
212
367
|
directory = Path(tempfile.mkdtemp(prefix="run-", dir=settings["out"]))
|
|
213
368
|
results, captures = [], {}
|
|
369
|
+
expected = capture.expected_views(core.parse_variant_spec(
|
|
370
|
+
settings["variants"], core.find_variant_sheets(theme)))
|
|
214
371
|
for browser in settings["firefox"]:
|
|
215
372
|
key = browser_key(browser)
|
|
216
373
|
dest = directory / key
|
|
@@ -218,12 +375,15 @@ def run(args):
|
|
|
218
375
|
result = {"firefox": browser, "key": key, "exit_code": 0}
|
|
219
376
|
results.append(result)
|
|
220
377
|
print(f"Checking {browser}…", flush=True)
|
|
378
|
+
phase = "browser setup"
|
|
221
379
|
try:
|
|
222
380
|
selected = browser
|
|
223
381
|
if "/" in browser or "\\" in browser or browser.startswith("~"):
|
|
224
382
|
selected = str((theme / Path(browser).expanduser()).resolve())
|
|
225
383
|
binary = core.find_firefox(selected)
|
|
226
384
|
result["binary"] = str(binary)
|
|
385
|
+
phase = "selector audit"
|
|
386
|
+
print(" selector audit: running", flush=True)
|
|
227
387
|
with (dest / "audit.txt").open("w", encoding="utf-8") as log:
|
|
228
388
|
with contextlib.redirect_stdout(log), contextlib.redirect_stderr(log):
|
|
229
389
|
result["audit_exit_code"] = cli.cmd_audit(argparse.Namespace(
|
|
@@ -231,20 +391,33 @@ def run(args):
|
|
|
231
391
|
no_colour=True, patch=dest / "fix.diff", strict=settings["strict"],
|
|
232
392
|
strict_vars=settings["strict_vars"]))
|
|
233
393
|
result["exit_code"] = result["audit_exit_code"]
|
|
394
|
+
print(f" selector audit: {('passed', 'findings', 'error')[result['audit_exit_code']]}",
|
|
395
|
+
flush=True)
|
|
396
|
+
phase = "screenshot capture"
|
|
397
|
+
print(f" screenshot capture: {len(expected)} views requested", flush=True)
|
|
234
398
|
with (dest / "capture.txt").open("w", encoding="utf-8") as log:
|
|
235
|
-
|
|
399
|
+
progress = CaptureProgress(log, sys.stdout, len(expected))
|
|
400
|
+
with contextlib.redirect_stdout(progress), contextlib.redirect_stderr(log):
|
|
236
401
|
code = cli.cmd_shot(argparse.Namespace(
|
|
237
402
|
theme=theme, firefox=str(binary), out=dest / "shots", url=[],
|
|
238
403
|
only_live=False, variants=settings["variants"], toolbar=settings["toolbar"]))
|
|
404
|
+
coverage_path = dest / "shots" / capture.REPORT
|
|
405
|
+
available_coverage = read_coverage(coverage_path)
|
|
406
|
+
if available_coverage:
|
|
407
|
+
result["coverage"] = available_coverage
|
|
239
408
|
if code:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
raise RuntimeError("capture failed; see capture.txt")
|
|
244
|
-
result["coverage"] = capture.validate_coverage(dest / "shots", capture.expected_views(
|
|
245
|
-
core.parse_variant_spec(settings["variants"], core.find_variant_sheets(theme))))
|
|
409
|
+
cause = last_capture_error(dest / "capture.txt")
|
|
410
|
+
raise RuntimeError("capture failed: " + (cause or "see capture.txt"))
|
|
411
|
+
result["coverage"] = capture.validate_coverage(dest / "shots", expected)
|
|
246
412
|
compare._captures(dest / "shots")
|
|
247
413
|
result["captured"] = True
|
|
414
|
+
view_states = [view["status"] for view in result["coverage"]["views"].values()]
|
|
415
|
+
captured_count = view_states.count("captured")
|
|
416
|
+
unsupported_count = view_states.count("unsupported")
|
|
417
|
+
summary = f"{len(view_states)}/{len(expected)} views accounted for; {captured_count} captured"
|
|
418
|
+
if unsupported_count:
|
|
419
|
+
summary += f", {unsupported_count} unsupported"
|
|
420
|
+
print(f" screenshot capture: complete ({summary})", flush=True)
|
|
248
421
|
info = dest / "shots/render-info.json"
|
|
249
422
|
if info.exists():
|
|
250
423
|
result["render_info"] = json.loads(info.read_text(encoding="utf-8"))
|
|
@@ -255,7 +428,9 @@ def run(args):
|
|
|
255
428
|
elif baseline is None:
|
|
256
429
|
result["comparison_note"] = "no baseline configured"
|
|
257
430
|
else:
|
|
258
|
-
|
|
431
|
+
phase = "visual comparison"
|
|
432
|
+
print(" visual comparison: running", flush=True)
|
|
433
|
+
result["baseline_info"] = capture.validate_coverage(baseline / key)["browser"]
|
|
259
434
|
with (dest / "comparison.txt").open("w", encoding="utf-8") as log:
|
|
260
435
|
with contextlib.redirect_stdout(log), contextlib.redirect_stderr(log):
|
|
261
436
|
code = compare.run(baseline / key, dest / "shots", dest / "diff", browser)
|
|
@@ -266,17 +441,31 @@ def run(args):
|
|
|
266
441
|
result["comparison"] = summary
|
|
267
442
|
result["exit_code"] = max(result["exit_code"], comparison_status(
|
|
268
443
|
summary, settings["max_changed_percent"]))
|
|
444
|
+
print(f" visual comparison: {len(summary['changed_views'])} shared views changed",
|
|
445
|
+
flush=True)
|
|
446
|
+
except KeyboardInterrupt:
|
|
447
|
+
available_coverage = read_coverage(dest / "shots" / capture.REPORT)
|
|
448
|
+
if available_coverage:
|
|
449
|
+
result["coverage"] = available_coverage
|
|
450
|
+
result.update(exit_code=2, interrupted=True,
|
|
451
|
+
error=f"check interrupted during {phase}; completed files are retained")
|
|
269
452
|
except (OSError, ValueError, RuntimeError, SystemExit) as exc:
|
|
270
453
|
result.update(exit_code=2, error=str(exc))
|
|
271
|
-
print(f" {browser}: {(
|
|
454
|
+
print(f" {browser}: {result_label(result)}", flush=True)
|
|
272
455
|
if result.get("error"):
|
|
273
456
|
print(f" {result['error']}", flush=True)
|
|
457
|
+
if result.get("interrupted"):
|
|
458
|
+
break
|
|
274
459
|
status = max(r["exit_code"] for r in results)
|
|
275
460
|
updated = False
|
|
276
461
|
if args.update_baseline and status == 0:
|
|
277
462
|
try:
|
|
278
463
|
update_baseline(settings["baseline"], captures)
|
|
279
464
|
updated = True
|
|
465
|
+
except KeyboardInterrupt:
|
|
466
|
+
status = 2
|
|
467
|
+
results[-1].update(exit_code=2, interrupted=True,
|
|
468
|
+
error="check interrupted during baseline update")
|
|
280
469
|
except (OSError, ValueError, RuntimeError) as exc:
|
|
281
470
|
status = 2
|
|
282
471
|
results[-1].update(exit_code=2, error=f"baseline update failed: {exc}")
|