testing/mozbase/rust/mozrunner/src/bin/firefox-default-path.rs
author Andreas Tolfsen <ato@sny.no>
Fri, 12 Jan 2018 15:31:20 +0000
changeset 454164 5af72ae23d9640eceafe8af357c663411c452c88
child 542022 046dd0da3b8e606ae33895248cd41e4ef03a4fcc
permissions -rw-r--r--
Bug 1429511 - Move Rust port of mozrunner to central. r=ahal This moves the Rust crate mozrunner into central from GitHub. The old repository will be graveyarded: https://github.com/jgraham/rust_mozrunner The git history is not considered important, hence this does not overlay that onto central like we did for testing/geckodriver and testing/webdriver. MozReview-Commit-ID: J4ZYdow2Lkw

extern crate mozrunner;

use mozrunner::runner::platform;
use std::io::Write;

fn main() {
    let (path, code) = platform::firefox_default_path()
        .map(|x| (x.to_string_lossy().into_owned(), 0))
        .unwrap_or(("Firefox binary not found".to_owned(), 1));

    let mut writer: Box<Write> = match code {
        0 => Box::new(std::io::stdout()),
        _ => Box::new(std::io::stderr())
    };
    writeln!(&mut writer, "{}", &*path).unwrap();
    std::process::exit(code);
}