Use pretty_assertions in the root crate (#8818)

# Description

This PR is just a minor development improvement. While working on
another feature, I noticed that the root crate lists the super useful
`pretty_assertions` in the root crate but doesn't use it in most tests.
With this change `pretty_assertions::assert_eq!` is used instead of
`core::assert_eq!` for better diffs when debugging the tests.

I thought of adding the dependency to other crates but I decided not to
since I didn't want a huge disruptive PR :)
This commit is contained in:
Maria José Solano 2023-04-08 11:52:37 -07:00 committed by GitHub
parent d128c0e02b
commit 5afbfb5c2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 26 additions and 9 deletions

View file

@ -1,4 +1,5 @@
use nu_test_support::nu; use nu_test_support::nu;
use pretty_assertions::assert_eq;
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;

View file

@ -1,5 +1,6 @@
use crate::tests::{fail_test, run_test, run_test_contains, TestResult}; use crate::tests::{fail_test, run_test, run_test_contains, TestResult};
use nu_test_support::nu; use nu_test_support::nu;
use pretty_assertions::assert_eq;
#[test] #[test]
fn no_scope_leak1() -> TestResult { fn no_scope_leak1() -> TestResult {

View file

@ -1,4 +1,5 @@
use nu_test_support::{nu, pipeline}; use nu_test_support::{nu, pipeline};
use pretty_assertions::assert_eq;
#[test] #[test]
fn const_bool() { fn const_bool() {

View file

@ -1,4 +1,5 @@
use nu_test_support::{nu, nu_repl_code}; use nu_test_support::{nu, nu_repl_code};
use pretty_assertions::assert_eq;
fn env_change_hook_code_list(name: &str, code_list: &[&str]) -> String { fn env_change_hook_code_list(name: &str, code_list: &[&str]) -> String {
let mut list = String::new(); let mut list = String::new();

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline}; use nu_test_support::{nu, pipeline};
use pretty_assertions::assert_eq;
#[test] #[test]
fn module_private_import_decl() { fn module_private_import_decl() {

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use nu_test_support::{nu, nu_repl_code, pipeline}; use nu_test_support::{nu, nu_repl_code, pipeline};
use pretty_assertions::assert_eq;
#[test] #[test]
fn add_overlay() { fn add_overlay() {

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline}; use nu_test_support::{nu, pipeline};
use pretty_assertions::assert_eq;
#[test] #[test]
fn source_file_relative_to_file() { fn source_file_relative_to_file() {

View file

@ -1,9 +1,8 @@
use std::path::Path; use nu_path::canonicalize_with;
use nu_test_support::fs::Stub::EmptyFile; use nu_test_support::fs::Stub::EmptyFile;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use pretty_assertions::assert_eq;
use nu_path::canonicalize_with; use std::path::Path;
#[test] #[test]
fn canonicalize_path() { fn canonicalize_path() {

View file

@ -1,8 +1,7 @@
use std::path::PathBuf;
use nu_test_support::playground::Playground;
use nu_path::expand_path_with; use nu_path::expand_path_with;
use nu_test_support::playground::Playground;
use pretty_assertions::assert_eq;
use std::path::PathBuf;
#[cfg(not(windows))] #[cfg(not(windows))]
#[test] #[test]

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContent; use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::nu_with_plugins; use nu_test_support::nu_with_plugins;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use pretty_assertions::assert_eq;
#[test] #[test]
fn chooses_highest_increment_if_given_more_than_one() { fn chooses_highest_increment_if_given_more_than_one() {

View file

@ -1,4 +1,5 @@
use nu_test_support::nu_with_plugins; use nu_test_support::nu_with_plugins;
use pretty_assertions::assert_eq;
#[test] #[test]
fn can_get_custom_value_from_plugin_and_instantly_collapse_it() { fn can_get_custom_value_from_plugin_and_instantly_collapse_it() {

View file

@ -1,4 +1,5 @@
use nu_test_support::nu_with_plugins; use nu_test_support::nu_with_plugins;
use pretty_assertions::assert_eq;
const TEST_CWD: &str = "tests/fixtures/formats"; const TEST_CWD: &str = "tests/fixtures/formats";

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::nu_with_plugins; use nu_test_support::nu_with_plugins;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use pretty_assertions::assert_eq;
#[test] #[test]
fn infers_types() { fn infers_types() {

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::nu_with_plugins; use nu_test_support::nu_with_plugins;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use pretty_assertions::assert_eq;
const TEST_CWD: &str = "tests/fixtures/formats"; const TEST_CWD: &str = "tests/fixtures/formats";

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::nu_with_plugins; use nu_test_support::nu_with_plugins;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use pretty_assertions::assert_eq;
#[test] #[test]
fn infers_types() { fn infers_types() {

View file

@ -1,4 +1,5 @@
use nu_test_support::nu; use nu_test_support::nu;
use pretty_assertions::assert_eq;
#[ignore = "TODO: This shows old-style aliases. New aliases are under commands"] #[ignore = "TODO: This shows old-style aliases. New aliases are under commands"]
#[test] #[test]

View file

@ -4,7 +4,7 @@ use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::nu; use nu_test_support::nu;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use nu_test_support::{nu_repl_code, pipeline}; use nu_test_support::{nu_repl_code, pipeline};
use pretty_assertions::assert_eq;
use serial_test::serial; use serial_test::serial;
#[test] #[test]

View file

@ -3,6 +3,7 @@ use super::support::Trusted;
use nu_test_support::fs::Stub::FileWithContent; use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline}; use nu_test_support::{nu, pipeline};
use pretty_assertions::assert_eq;
use serial_test::serial; use serial_test::serial;

View file

@ -1,6 +1,7 @@
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use nu_test_support::{nu, nu_repl_code, pipeline}; use nu_test_support::{nu, nu_repl_code, pipeline};
use pretty_assertions::assert_eq;
#[cfg(feature = "which-support")] #[cfg(feature = "which-support")]
mod environment; mod environment;

View file

@ -1,4 +1,5 @@
use nu_test_support::nu; use nu_test_support::nu;
use pretty_assertions::assert_eq;
#[cfg(feature = "which-support")] #[cfg(feature = "which-support")]
#[test] #[test]

View file

@ -2,6 +2,7 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::nu; use nu_test_support::nu;
use nu_test_support::pipeline; use nu_test_support::pipeline;
use nu_test_support::playground::Playground; use nu_test_support::playground::Playground;
use pretty_assertions::assert_eq;
#[test] #[test]
fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() { fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {

View file

@ -1,6 +1,7 @@
mod commands; mod commands;
use nu_test_support::nu; use nu_test_support::nu;
use pretty_assertions::assert_eq;
#[test] #[test]
fn doesnt_break_on_utf8() { fn doesnt_break_on_utf8() {