There is a functional call after ok_or() which is called and
evaluated before escape_char is converted due to RHS evaluation.
We can avoid this by employing a closure with ok_or_else().
It is considered more idiomatic to dereference the match expression
than to peek at each variant through a reference.
This silences a clippy lint warning.
It is considered more idiomatic Rust to loop over references to
containers rather than calling the iteration protocol's x.iter()
or x.into_iter() explicitly.
io::Write::write() is not guaranteed to process the entire buffer.
It returns how many bytes were processed, which may be smaller than the
given buffer's length. mozprofile does not need to deal with partial
writes, so all the calls to ::write() may be replaced with ::write_all().
Where string literals contain only ASCII characters, it is considered
better style to define byte strings using b"foo" rather than calling
"foo".as_bytes().
Allow i8, u8, i16, u64, i32, and u32 to be implicitly converted into
PrefValue::Int. u64 is not supported because it would overflow,
so this still needs to be handled manually.
geckodriver stores the port number as u8 and this will allow it to
implicitly convert it to PrefValue::Int without using the unsafe
"as i64" coercion.
Start Firefox with -foreground and -no-remote arguments if they
have not already been given by the user.
-foreground will ensure the application window gets focus when
Firefox is started, and -no-remote will prevent remote commands to
this instance of Firefox and also ensure we always start a new instance.
MozReview-Commit-ID: LGEqgyHYapc
--HG--
extra : rebase_source : 50054e89106421dc6b43bc1f109dc75db37dfd2d
The std::process::Command's stdout and stderr is configured earlier in
::start(), and resetting it to a static value below would invalidate the
configured stdout and stderr stored in FirefoxRunner::stdout and ::stderr.
We did not notice this bug because geckodriver does not
yet use this feature. It was added as a precursor for
https://bugzilla.mozilla.org/show_bug.cgi?id=1466573.
MozReview-Commit-ID: CmwqCZpEMqq
--HG--
extra : rebase_source : 209d7cdde8b05db9b7e6f02b221c32a436f2ecdf
Bug 1464995 broke mozrunner on macOS, but we did not notice because
geckodriver is not compiled on macOS. This fixes the build.
MozReview-Commit-ID: GnvZTT30wHG
--HG--
extra : rebase_source : 6e5b5b37d0c962c75a2a4b41c004f9cf47c2e8a2
mozrunner fails to locate the correct binary if Firefox is found
under a "firefox" or "firefox-bin" (depending on the system)
because it thinks the parent directory is the executable.
On Unix systems, mozrunner also falsely reports non-executable
files as valid binaries.
This patch introduces a new mozrunner::path module that provides
two functions: one for searching the system path for a binary by a
given name, and another for checking whether a path is an executable
binary file.
MozReview-Commit-ID: 6N06CXZZWqd
--HG--
extra : rebase_source : dbcb4d6d8478bafc23c1aa2a3081589074908bbc
Removes an unnecessary as_ref() cast, a path coercion, and replaces
try!() with ?.
MozReview-Commit-ID: ASd9kNxDZ3n
--HG--
extra : rebase_source : fa88def64fc3c7ea4520403bfc7b5c391d7f83da
The method we use to find the Firefox binary varies from platform
to platform. It can be useful to document how each of the system
specific implementations are meant to work.
MozReview-Commit-ID: 4SrNmlp3AdS
--HG--
extra : rebase_source : f1d54548edb416912af3a0a6d41188d0640a3ffb
Following the move to use cargo worktrees in central, the .gitignore
file for mozversion is not used anymore since we no longer generate
testing/mozbase/rust/mozversion/target on building.
MozReview-Commit-ID: 72geBjNxjZl
--HG--
extra : rebase_source : d7f11b33c91407e97416344ca1a2d0f06aa573d3
One change since 0.6.0, which is a regression fix for a fallout
from bug 1443853.
MozReview-Commit-ID: 56GbEV4HM4v
--HG--
extra : rebase_source : 0e14fa63f00f1661cae01a10c76c2813d349ba1b
std::process::Child::kill() will return Err if the process has
already exited. The assumption in bug 1443853 was that calling
::kill() would consistently return the std::process::ExitStatus
was the process already dead.
This patches the regression from bug 1443853 by employing
Child::try_wait() in a loop. When the process gives some exit status,
this is return directly without relying on Child::kill() as before.
If the process has not exited and the timeout has elapsed, we kill
the process and return its return value. If the process has not
exited but the timeout duration has not elapsed, we wait 100 ms as before.
MozReview-Commit-ID: 4VENbrKtcEh
--HG--
extra : rebase_source : 7f27ed057da740306367ef2b6a87f8ac6a242541
This moves the shutdown monitor for the Firefox process from
geckodriver to mozrunner, which is a more suitable home for it.
We will likely need specialised versions of this in the future with
products such as GeckoView and Fennec.
In addition to the move it also cleans up the polling loop by
employing std::time::SystemTime which lets us match on the elapsed
time since its construction. This seems nicer than having to perform
division operations on integers, which in Rust are inherently unsafe
(there is no guard against SIGFPE).
This change should be functionally equivalent to the existing code.
MozReview-Commit-ID: 1asnFbixhcY
--HG--
extra : rebase_source : f21f734862bfbbc1ed665dc9c9f611c5968d662f
This renames RunnerProcess::status() to ::try_wait() for symmetry
with std::process::Child::try_wait() in the standard library.
The patch also makes an attempt at cleaning up its usage in geckodriver,
however this can be further improved.
MozReview-Commit-ID: 14ihT7MpM7l
--HG--
extra : rebase_source : 4e96c79c6ebbb256c4a08cb4dd86c99aacaa13ac
We can pick up std::io::Result and std::io::Error directly from
the std::io namespace without having to rename them.
MozReview-Commit-ID: 9Xz92HvcFpO
--HG--
extra : rebase_source : 89a006c40e11d9e7fc5706d3a6612f916e00f919
This renames RunnerProcess::stop() to ::kill() for symmetry with
the standard library's std::process::Child.
MozReview-Commit-ID: 20vSni9bA0X
--HG--
extra : rebase_source : 112b29249563154b50d9a72c141034e5cdf7f19b
The ideom for getters in Rust is to not prefix them with "is_".
Setters should, however, have the "set_" prefix.
MozReview-Commit-ID: 9kXHBYGK7aL
--HG--
extra : rebase_source : 6c2591771646c8b7c5b0e6b1af5427455938b4cf