diff options
author | Michael Weiss <dev.primeos@gmail.com> | 2021-01-20 20:00:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 20:00:58 +0100 |
commit | 88637a1c33a5c901a4f5b63b2f218a5017a952a2 (patch) | |
tree | bd2225297cec10bdac62d1762039bff988efa284 | |
parent | 7a865aa59c21addf0e2cf5ea8741c6314d5322a2 (diff) | |
parent | 70206c3be4265ec7b1651c4e61b6145560a0464d (diff) |
Merge pull request #110198 from primeos/chromium-vm-test
nixos/tests/chromium: Add ungoogled-chromium and Google Chrome
-rw-r--r-- | nixos/tests/chromium.nix | 36 | ||||
-rw-r--r-- | pkgs/applications/networking/browsers/chromium/README.md | 15 |
2 files changed, 45 insertions, 6 deletions
diff --git a/nixos/tests/chromium.nix b/nixos/tests/chromium.nix index d4085bebac0f..4d6b726d9e4c 100644 --- a/nixos/tests/chromium.nix +++ b/nixos/tests/chromium.nix @@ -1,10 +1,14 @@ { system ? builtins.currentSystem , config ? {} , pkgs ? import ../.. { inherit system config; } -, channelMap ? { - stable = pkgs.chromium; - beta = pkgs.chromiumBeta; - dev = pkgs.chromiumDev; +, channelMap ? { # Maps "channels" to packages + stable = pkgs.chromium; + beta = pkgs.chromiumBeta; + dev = pkgs.chromiumDev; + ungoogled = pkgs.ungoogled-chromium; + chrome-stable = pkgs.google-chrome; + chrome-beta = pkgs.google-chrome-beta; + chrome-dev = pkgs.google-chrome-dev; } }: @@ -14,7 +18,7 @@ with pkgs.lib; mapAttrs (channel: chromiumPkg: makeTest rec { name = "chromium-${channel}"; meta = { - maintainers = with maintainers; [ aszlig ]; + maintainers = with maintainers; [ aszlig primeos ]; # https://github.com/NixOS/hydra/issues/591#issuecomment-435125621 inherit (chromiumPkg.meta) timeout; }; @@ -58,6 +62,19 @@ mapAttrs (channel: chromiumPkg: makeTest rec { return "su - ${user} -c " + shlex.quote(cmd) + def get_browser_binary(): + """Returns the name of the browser binary.""" + pname = "${getName chromiumPkg.name}" + if pname.find("chromium") != -1: + return "chromium" # Same name for all channels and ungoogled-chromium + if pname == "google-chrome": + return "google-chrome-stable" + if pname == "google-chrome-dev": + return "google-chrome-unstable" + # For google-chrome-beta and as fallback: + return pname + + def create_new_win(): with machine.nested("Creating a new Chromium window"): machine.execute( @@ -153,7 +170,14 @@ mapAttrs (channel: chromiumPkg: makeTest rec { machine.wait_for_x() url = "file://${startupHTML}" - machine.succeed(ru(f'ulimit -c unlimited; chromium "{url}" & disown')) + machine.succeed(ru(f'ulimit -c unlimited; "{get_browser_binary()}" "{url}" & disown')) + + if get_browser_binary().startswith("google-chrome"): + # Need to click away the first window: + machine.wait_for_text("Make Google Chrome the default browser") + machine.screenshot("google_chrome_default_browser_prompt") + machine.send_key("ret") + machine.wait_for_text("startup done") machine.wait_until_succeeds( ru( diff --git a/pkgs/applications/networking/browsers/chromium/README.md b/pkgs/applications/networking/browsers/chromium/README.md index 5b7c9fe55040..9d23e3143c60 100644 --- a/pkgs/applications/networking/browsers/chromium/README.md +++ b/pkgs/applications/networking/browsers/chromium/README.md @@ -36,6 +36,21 @@ update `upstream-info.json`. After updates it is important to test at least `nixosTests.chromium` (or basic manual testing) and `google-chrome` (which reuses `upstream-info.json`). +To run all automated NixOS VM tests for Chromium, ungoogled-chromium, +and Google Chrome (not recommended, currently 6x tests!): +``` +nix-build nixos/tests/chromium.nix +``` + +A single test can be selected, e.g. to test `ungoogled-chromium` (see +`channelMap` in `nixos/tests/chromium.nix` for all available options): +``` +nix-build nixos/tests/chromium.nix -A ungoogled +``` +(Note: Testing Google Chrome requires `export NIXPKGS_ALLOW_UNFREE=1`.) + +For custom builds it's possible to "override" `channelMap`. + ## Backports All updates are considered security critical and should be ported to the stable |