diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-08-11 10:20:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 10:20:47 -0400 |
commit | 15a763152f9d392cb80692262f8de5ef8ae15495 (patch) | |
tree | fcd1a59777f95920bf3502519983d6cc0d882a9a /cli/config_file.rs | |
parent | a0285e2eb88f6254f6494b0ecd1878db3a3b2a58 (diff) |
chore: move test files to testdata directory (#11601)
Diffstat (limited to 'cli/config_file.rs')
-rw-r--r-- | cli/config_file.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/cli/config_file.rs b/cli/config_file.rs index 5ea92447b..e366be77c 100644 --- a/cli/config_file.rs +++ b/cli/config_file.rs @@ -279,12 +279,12 @@ pub struct ConfigFile { } impl ConfigFile { - pub fn read(path_str: &str) -> Result<Self, AnyError> { - let path = Path::new(path_str); + pub fn read(path_ref: impl AsRef<Path>) -> Result<Self, AnyError> { + let path = Path::new(path_ref.as_ref()); let config_file = if path.is_absolute() { path.to_path_buf() } else { - std::env::current_dir()?.join(path_str) + std::env::current_dir()?.join(path_ref) }; let config_path = canonicalize_path(&config_file).map_err(|_| { @@ -349,16 +349,15 @@ mod tests { #[test] fn read_config_file_relative() { - let config_file = ConfigFile::read("tests/module_graph/tsconfig.json") - .expect("Failed to load config file"); + let config_file = + ConfigFile::read("tests/testdata/module_graph/tsconfig.json") + .expect("Failed to load config file"); assert!(config_file.json.compiler_options.is_some()); } #[test] fn read_config_file_absolute() { - let path = std::env::current_dir() - .unwrap() - .join("tests/module_graph/tsconfig.json"); + let path = test_util::testdata_path().join("module_graph/tsconfig.json"); let config_file = ConfigFile::read(path.to_str().unwrap()) .expect("Failed to load config file"); assert!(config_file.json.compiler_options.is_some()); |