@@ -63,29 +63,27 @@ To re-create your development container from the latest image, run:
6363## Working on Cockpit's session pages
6464
6565Most contributors want to work on the web (HTML, JavaScript, CSS) parts of Cockpit.
66+
67+ ### Install Cockpit
68+
6669First, install Cockpit on your local machine as described in:
6770
6871< https://cockpit-project.org/running.html >
6972
73+ ### Build session pages
74+
7075Next, run this command from your top level Cockpit checkout directory, and make
7176sure to run it as the same user that you'll use to log into Cockpit below.
7277
7378 mkdir -p ~/.local/share/
7479 ln -s $(pwd)/dist ~/.local/share/cockpit
7580
76- This will cause cockpit to read JavaScript, HTML, and CSS files directly from the
81+ This will cause Cockpit to read JavaScript, HTML, and CSS files directly from the
7782locally built package output directory instead of using the system-installed Cockpit
7883files.
7984
80- Now you can log into Cockpit on your local Linux machine at the following
81- address. Use the same user and password that you used to log into your Linux
82- desktop.
83-
84- < http://localhost:9090 >
85-
86- After every change to the source files, bundles need to be rebuilt. The
87- recommended and fastest way is to do that is using the "watch" mode (` -w ` or
88- ` --watch ` ) on the page that you are working on. For example, if you want to
85+ The recommended way to build bundles is to use the "watch" mode
86+ (` -w ` or` --watch ` ) on the page you are working on. For example, if you want to
8987work on anything in [ pkg/systemd] ( https://github.com/cockpit-project/cockpit/tree/main/pkg/systemd/ ) , run:
9088
9189 ./build.js -w systemd
@@ -97,8 +95,16 @@ pkg/lib/), you can also build all pages:
9795
9896 ./build.js -w
9997
100- Reload cockpit in your browser after page is built. Press ` Ctrl ` -` C ` to
101- stop watch mode once you are done with changing the code.
98+ Now you can log into Cockpit on your local Linux machine at the following
99+ address, using the same username and password as your desktop login:
100+
101+ < http://localhost:9090 >
102+
103+ Watch mode automatically rebuilds when source files are modified. Once it
104+ finishes building, refresh your browser to see the changes in Cockpit.
105+ Press ` Ctrl-C ` to stop watch mode when you are done changing the code.
106+
107+ ### Testing
102108
103109You often need to test code changes in a VM. You can set the ` $RSYNC ` env
104110variable to copy the built page into the given SSH target's
@@ -109,6 +115,8 @@ one of these commands:
109115 RSYNC=c ./build.js -w kdump
110116 RSYNC=c ./build.js -w
111117
118+ ### Returning to system packages
119+
112120To make Cockpit use system packages again, instead of your checkout directory,
113121remove the symlink with the following command and log back into Cockpit:
114122
@@ -152,10 +160,26 @@ which will output a URL to connect to with a browser, such as
152160< http://localhost:8765/qunit/base1/test-dbus.html > . Adjust the path for different
153161tests and inspect the results there.
154162
155- You can also run individual tests by specifying the ` TESTS ` environment
156- variable:
163+ QUnit tests are run as part of a pytest test called ` test_browser ` . You can
164+ run individual tests via ` pytest -k ` , like so:
165+
166+ pytest -k test-fsinfo.html
167+
168+ You can see JavaScript code coverage information for QUnit tests. For a
169+ summary table:
170+
171+ pytest -k test_browser --js-cov
172+
173+ And for detailed output on uncovered sections in a specific file, something
174+ like:
175+
176+ pytest -k test-fsinfo.html --js-cov-files='*/fsinfo.ts'
177+
178+ Coverage information is gathered into the pytest tmpdir, regardless of which
179+ coverage-related commandline flags are given, so it's also possible to drill
180+ down after the fact — without re-running tests — using something like:
157181
158- make check TESTS=qunit/base1/test-chan.html
182+ test/common/js_coverage.py -m '*/fsinfo.ts' /tmp/pytest-of-*/pytest-current/js-coverage/*
159183
160184There are also static code and syntax checks which you should run often:
161185
@@ -199,7 +223,7 @@ The Python bridge can be used interactively on a local machine:
199223To make it easy to test out channels without having to write out messages
200224manually, ` cockpit.misc.print ` can be used:
201225
202- PYTHONPATH=src python3 -m cockpit.misc.print open fslist1 path=/etc watch=False | PYTHONPATH=src python3 -m cockpit.bridge
226+ PYTHONPATH=src python3 -m cockpit.misc.print open fsinfo path=/etc 'attrs=["type", "entries"]' | PYTHONPATH=src python3 -m cockpit.bridge
203227
204228These shell aliases might be useful when experimenting with the protocol:
205229
0 commit comments