Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions src/test/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ use crate::test::utils::*;
use fs::File;
use fs_err as fs;
use futures::channel::oneshot::{self, Sender};
#[cfg(not(target_os = "macos"))]
use serial_test::serial;
use std::io::{Cursor, Write};
#[cfg(not(target_os = "macos"))]
use std::net::TcpListener;
use std::path::Path;
#[cfg(not(target_os = "macos"))]
use std::process::Command;
use std::sync::{Arc, Mutex, mpsc};
use std::thread;
use std::time::Duration;
Expand Down Expand Up @@ -293,32 +287,3 @@ fn test_server_compile() {
// Ensure that it shuts down.
child.join().unwrap();
}

#[test]
#[serial]
// test fails intermittently on macos:
// https://github.com/mozilla/sccache/issues/234
#[cfg(not(target_os = "macos"))]
fn test_server_port_in_use() {
// Bind an arbitrary free port.
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let sccache = find_sccache_binary();
let output = Command::new(sccache)
.arg("--start-server")
.env(
"SCCACHE_SERVER_PORT",
listener.local_addr().unwrap().port().to_string(),
)
.env_remove("SCCACHE_SERVER_UDS")
.output()
.unwrap();
assert!(!output.status.success());
let s = String::from_utf8_lossy(&output.stderr);
const MSG: &str = "Server startup failed:";
assert!(
s.contains(MSG),
"Output did not contain '{}':\n========\n{}\n========",
MSG,
s
);
}
19 changes: 0 additions & 19 deletions src/test/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,6 @@ pub fn next_command_calls<C: Fn(&[OsString]) -> Result<MockChild> + Send + 'stat
creator.lock().unwrap().next_command_calls(call);
}

#[cfg(not(target_os = "macos"))]
pub fn find_sccache_binary() -> PathBuf {
// Older versions of cargo put the test binary next to the sccache binary.
// Newer versions put it in the deps/ subdirectory.
let exe = env::current_exe().unwrap();
let this_dir = exe.parent().unwrap();
let dirs = &[&this_dir, &this_dir.parent().unwrap()];
dirs.iter()
.map(|d| d.join("sccache").with_extension(env::consts::EXE_EXTENSION))
.filter_map(|d| fs::metadata(&d).ok().map(|_| d))
.next()
.unwrap_or_else(|| {
panic!(
"Error: sccache binary not found, looked in `{:?}`. Do you need to run `cargo build`?",
dirs
)
})
}

pub struct TestFixture {
/// Temp directory.
pub tempdir: TempDir,
Expand Down
34 changes: 34 additions & 0 deletions tests/server.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#[cfg(not(target_os = "macos"))]
use std::{net::TcpListener, process::Command};

#[cfg(not(target_os = "macos"))]
use serial_test::serial;

#[test]
#[serial]
// test fails intermittently on macos:
// https://github.com/mozilla/sccache/issues/234
#[cfg(not(target_os = "macos"))]
fn test_server_port_in_use() {
// Bind an arbitrary free port.
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let sccache = env!("CARGO_BIN_EXE_sccache");
let output = Command::new(sccache)
.arg("--start-server")
.env(
"SCCACHE_SERVER_PORT",
listener.local_addr().unwrap().port().to_string(),
)
.env_remove("SCCACHE_SERVER_UDS")
.output()
.unwrap();
assert!(!output.status.success());
let s = String::from_utf8_lossy(&output.stderr);
const MSG: &str = "Server startup failed:";
assert!(
s.contains(MSG),
"Output did not contain '{}':\n========\n{}\n========",
MSG,
s
);
}
Loading