mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
playwright-test: Add PLAYWRIGHT_BROWSERS_PATH to build environment (#368391)
This commit is contained in:
commit
87b95e65c2
4 changed files with 53 additions and 0 deletions
|
@ -13,6 +13,9 @@
|
||||||
setuptools-scm,
|
setuptools-scm,
|
||||||
playwright-driver,
|
playwright-driver,
|
||||||
nixosTests,
|
nixosTests,
|
||||||
|
writeText,
|
||||||
|
runCommand,
|
||||||
|
pythonPackages,
|
||||||
nodejs,
|
nodejs,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -81,6 +84,16 @@ buildPythonPackage rec {
|
||||||
pyee
|
pyee
|
||||||
];
|
];
|
||||||
|
|
||||||
|
setupHook = writeText "setupHook.sh" ''
|
||||||
|
addBrowsersPath () {
|
||||||
|
if [[ ! -v PLAYWRIGHT_BROWSERS_PATH ]] ; then
|
||||||
|
export PLAYWRIGHT_BROWSERS_PATH="${playwright-driver.browsers}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
addEnvHooks "$targetOffset" addBrowsersPath
|
||||||
|
'';
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
ln -s ${driver} $out/${python.sitePackages}/playwright/driver
|
ln -s ${driver} $out/${python.sitePackages}/playwright/driver
|
||||||
'';
|
'';
|
||||||
|
@ -96,6 +109,9 @@ buildPythonPackage rec {
|
||||||
{
|
{
|
||||||
driver = playwright-driver;
|
driver = playwright-driver;
|
||||||
browsers = playwright-driver.browsers;
|
browsers = playwright-driver.browsers;
|
||||||
|
env = runCommand "playwright-env-test" {
|
||||||
|
buildInputs = [ pythonPackages.playwright ];
|
||||||
|
} "python ${./test.py}";
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
|
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
|
||||||
inherit (nixosTests) playwright-python;
|
inherit (nixosTests) playwright-python;
|
||||||
|
|
10
pkgs/development/python-modules/playwright/test.py
Normal file
10
pkgs/development/python-modules/playwright/test.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
|
with sync_playwright() as p:
|
||||||
|
browser = p.chromium.launch()
|
||||||
|
context = browser.new_context()
|
||||||
|
with open(os.environ["out"], "w") as f:
|
||||||
|
f.write("OK")
|
|
@ -12,6 +12,7 @@
|
||||||
makeFontsConf,
|
makeFontsConf,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
runCommand,
|
runCommand,
|
||||||
|
writeText,
|
||||||
cacert,
|
cacert,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
@ -188,9 +189,27 @@ let
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
setupHook = writeText "setupHook.sh" ''
|
||||||
|
addBrowsersPath () {
|
||||||
|
if [[ ! -v PLAYWRIGHT_BROWSERS_PATH ]] ; then
|
||||||
|
export PLAYWRIGHT_BROWSERS_PATH="${playwright-core.passthru.browsers}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
addEnvHooks "$targetOffset" addBrowsersPath
|
||||||
|
'';
|
||||||
|
|
||||||
meta = playwright.meta // {
|
meta = playwright.meta // {
|
||||||
mainProgram = "playwright";
|
mainProgram = "playwright";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
passthru.tests.env = runCommand "playwright-core-env-test" {
|
||||||
|
buildInputs = [
|
||||||
|
nodejs
|
||||||
|
playwright-core
|
||||||
|
playwright-test
|
||||||
|
];
|
||||||
|
} "node ${./test.js}";
|
||||||
});
|
});
|
||||||
|
|
||||||
browsers = lib.makeOverridable (
|
browsers = lib.makeOverridable (
|
||||||
|
|
8
pkgs/development/web/playwright/test.js
Normal file
8
pkgs/development/web/playwright/test.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
const playwright = require('playwright');
|
||||||
|
const fs = require('fs');
|
||||||
|
playwright.chromium.launch()
|
||||||
|
.then((browser) => {
|
||||||
|
console.log('OK');
|
||||||
|
fs.writeFileSync(process.env.out, '');
|
||||||
|
process.exit(0);
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue