sweet_test/native/run_e2e.rs
1use crate::prelude::TestRunnerConfig;
2use anyhow::Result;
3use std::env;
4use std::path::PathBuf;
5use std::process::Child;
6use std::process::Command;
7use sweet_utils::utils::PipelineTarget;
8
9
10/// if the e2e flag is set, start the chromedriver
11/// and return the child process
12///
13/// TODO install if doesnt exist
14pub fn try_run_e2e(config: &TestRunnerConfig) -> Result<Option<Child>> {
15 if config.e2e {
16 let home_dir = env::var("HOME")
17 .map_err(|e| anyhow::anyhow!("Failed to get HOME: {e}"))?;
18 let chromedriver_path = PathBuf::from(home_dir)
19 .join("chrome-for-testing/chromedriver-linux64/chromedriver");
20 Command::new(chromedriver_path)
21 .arg("--port=4444")
22 .arg("--silent")
23 // .arg("--verbose")
24 .spawn()
25 .map_err(|e| anyhow::anyhow!("Failed to start chromedriver: {e}"))?
26 .xsome()
27 .xok()
28 } else {
29 Ok(None)
30 }
31}
32
33
34/*
35Options
36--port=PORT port to listen on
37--adb-port=PORT adb server port
38--log-path=FILE write server log to file instead of stderr, increases log level to INFO
39--log-level=LEVEL set log level: ALL, DEBUG, INFO, WARNING, SEVERE, OFF
40--verbose log verbosely (equivalent to --log-level=ALL)
41--silent log nothing (equivalent to --log-level=OFF)
42--append-log append log file instead of rewriting
43--replayable (experimental) log verbosely and don't truncate long strings so that the log can be replayed.
44--version print the version number and exit
45--url-base base URL path prefix for commands, e.g. wd/url
46--readable-timestamp add readable timestamps to log
47--enable-chrome-logs show logs from the browser (overrides other logging options)
48--bidi-mapper-path custom bidi mapper path
49--disable-dev-shm-usage do not use /dev/shm (add this switch if seeing errors related to shared memory)
50--ignore-explicit-port (experimental) ignore the port specified explicitly, find a free port instead
51--allowed-ips=LIST comma-separated allowlist of remote IP addresses which are allowed to connect to ChromeDriver
52--allowed-origins=LIST comma-separated allowlist of request origins which are allowed to connect to ChromeDriver. Using `*` to allow any host origin is dangerous!
53*/