Skip to content

Commit

Permalink
Eliminate use of mutex in library_packages tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Aug 20, 2024
1 parent cb6299a commit 4bb16de
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions cargo-dylint/tests/library_packages.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use assert_cmd::prelude::*;
use dylint_internal::{env, packaging::isolate, CommandExt};
use predicates::prelude::*;
use std::{env::set_var, fs::OpenOptions, io::Write, sync::Mutex};
use std::{env::set_var, fs::OpenOptions, io::Write};
use tempfile::tempdir;

// smoelius: "Separate lints into categories" commit
Expand All @@ -12,16 +12,8 @@ fn initialize() {
set_var(env::CARGO_TERM_COLOR, "never");
}

// smoelius: The use of multiple revisions by the tests in this file causes problems. Specifically,
// multiple "checkouts" directories are created causing it to appear as though multiple directories
// were accessed. In this regard, `MUTEX` is merely a band-aid. A proper solution would address the
// underlying problem, rather than try to fix the tests themselves.
static MUTEX: Mutex<()> = Mutex::new(());

#[test]
fn array_pattern() {
let _lock = MUTEX.lock().unwrap();

let assert = std::process::Command::cargo_bin("cargo-dylint")
.unwrap()
.current_dir("fixtures/array_pattern")
Expand All @@ -37,8 +29,6 @@ fn array_pattern() {

#[test]
fn invalid_pattern() {
let _lock = MUTEX.lock().unwrap();

for pattern in ["/*", "../*"] {
let tempdir = tempdir().unwrap();

Expand Down Expand Up @@ -87,8 +77,6 @@ libraries = [

#[test]
fn library_packages_in_dylint_toml() {
let _lock = MUTEX.lock().unwrap();

std::process::Command::cargo_bin("cargo-dylint")
.unwrap()
.current_dir("fixtures/library_packages_in_dylint_toml")
Expand All @@ -102,8 +90,6 @@ fn library_packages_in_dylint_toml() {

#[test]
fn list() {
let _lock = MUTEX.lock().unwrap();

let tempdir = tempdir().unwrap();

dylint_internal::cargo::init("package `list_test`")
Expand Down Expand Up @@ -140,8 +126,6 @@ pattern = "examples/general/crate_wide_allow"
/// Verify that changes to workspace metadata cause the lints to be rerun.
#[test]
fn metadata_change() {
let _lock = MUTEX.lock().unwrap();

let tempdir = tempdir().unwrap();

dylint_internal::cargo::init("package `metadata_change_test`")
Expand Down Expand Up @@ -205,8 +189,6 @@ fn metadata_change() {

#[test]
fn nonexistent_git_library() {
let _lock = MUTEX.lock().unwrap();

let tempdir = tempdir().unwrap();

dylint_internal::cargo::init("package `nonexistent_git_library_test`")
Expand Down Expand Up @@ -259,8 +241,6 @@ pattern = "examples/general/nonexistent_library"

#[test]
fn nonexistent_path_library() {
let _lock = MUTEX.lock().unwrap();

let tempdir = tempdir().unwrap();

dylint_internal::cargo::init("package `nonexistent_path_library_test`")
Expand Down Expand Up @@ -316,8 +296,6 @@ path = "{}/../examples/general/nonexistent_library"
/// Verify that changes to `RUSTFLAGS` do not cause workspace metadata entries to be rebuilt.
#[test]
fn rustflags_change() {
let _lock = MUTEX.lock().unwrap();

let tempdir = tempdir().unwrap();

dylint_internal::cargo::init("package `rustflags_change_test`")
Expand Down Expand Up @@ -364,8 +342,6 @@ path = "{}/../examples/general/crate_wide_allow"

#[test]
fn unknown_keys() {
let _lock = MUTEX.lock().unwrap();

let tempdir = tempdir().unwrap();

dylint_internal::cargo::init("package `unknown_keys_test`")
Expand Down

0 comments on commit 4bb16de

Please sign in to comment.