Skip to content

Commit

Permalink
chore: move test files to testdata directory (denoland#11601)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Aug 11, 2021
1 parent a0285e2 commit 15a7631
Show file tree
Hide file tree
Showing 1,089 changed files with 1,150 additions and 1,160 deletions.
8 changes: 4 additions & 4 deletions .dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"cli/dts/lib.scripthost.d.ts",
"cli/dts/lib.webworker*.d.ts",
"cli/dts/typescript.d.ts",
"cli/tests/encoding",
"cli/tests/inline_js_source_map*",
"cli/tests/badly_formatted.md",
"cli/tests/badly_formatted.json",
"cli/tests/testdata/encoding",
"cli/tests/testdata/inline_js_source_map*",
"cli/tests/testdata/badly_formatted.md",
"cli/tests/testdata/badly_formatted.json",
"cli/tsc/*typescript.js",
"test_util/std",
"test_util/wpt",
Expand Down
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* text=auto eol=lf
*.png -text

/cli/tests/encoding/* -text
/cli/tests/testdata/encoding/* -text

# Tell git which symlinks point to files, and which ones point to directories.
# This is relevant for Windows only, and requires git >= 2.19.2 to work.
/cli/tests/symlink_to_subdir symlink=dir
/cli/tests/testdata/symlink_to_subdir symlink=dir

# Tell github these are vendored files.
# Doesn't include them in the language statistics.
Expand Down
41 changes: 29 additions & 12 deletions cli/bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,54 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[
// invalidating that cache.
(
"cold_hello",
&["run", "--reload", "cli/tests/002_hello.ts"],
&["run", "--reload", "cli/tests/testdata/002_hello.ts"],
None,
),
(
"cold_relative_import",
&["run", "--reload", "cli/tests/003_relative_import.ts"],
&[
"run",
"--reload",
"cli/tests/testdata/003_relative_import.ts",
],
None,
),
("hello", &["run", "cli/tests/002_hello.ts"], None),
("hello", &["run", "cli/tests/testdata/002_hello.ts"], None),
(
"relative_import",
&["run", "cli/tests/003_relative_import.ts"],
&["run", "cli/tests/testdata/003_relative_import.ts"],
None,
),
("error_001", &["run", "cli/tests/error_001.ts"], Some(1)),
(
"error_001",
&["run", "cli/tests/testdata/error_001.ts"],
Some(1),
),
(
"no_check_hello",
&["run", "--reload", "--no-check", "cli/tests/002_hello.ts"],
&[
"run",
"--reload",
"--no-check",
"cli/tests/testdata/002_hello.ts",
],
None,
),
(
"workers_startup",
&["run", "--allow-read", "cli/tests/workers/bench_startup.ts"],
&[
"run",
"--allow-read",
"cli/tests/testdata/workers/bench_startup.ts",
],
None,
),
(
"workers_round_robin",
&[
"run",
"--allow-read",
"cli/tests/workers/bench_round_robin.ts",
"cli/tests/testdata/workers/bench_round_robin.ts",
],
None,
),
Expand All @@ -75,23 +92,23 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[
&[
"run",
"--allow-read",
"cli/tests/workers/bench_large_message.ts",
"cli/tests/testdata/workers/bench_large_message.ts",
],
None,
),
(
"text_decoder",
&["run", "cli/tests/text_decoder_perf.js"],
&["run", "cli/tests/testdata/text_decoder_perf.js"],
None,
),
(
"text_encoder",
&["run", "cli/tests/text_encoder_perf.js"],
&["run", "cli/tests/testdata/text_encoder_perf.js"],
None,
),
(
"text_encoder_into",
&["run", "cli/tests/text_encoder_into_perf.js"],
&["run", "cli/tests/testdata/text_encoder_into_perf.js"],
None,
),
(
Expand Down
10 changes: 3 additions & 7 deletions cli/bench/throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CLIENT_ADDR: &str = "127.0.0.1 4544";
pub(crate) fn cat(deno_exe: &Path, megs: usize) -> f64 {
let size = megs * MB;
let shell_cmd = format!(
"{} run --allow-read cli/tests/cat.ts /dev/zero | head -c {}",
"{} run --allow-read cli/tests/testdata/cat.ts /dev/zero | head -c {}",
deno_exe.to_str().unwrap(),
size
);
Expand Down Expand Up @@ -47,12 +47,8 @@ pub(crate) fn tcp(deno_exe: &Path, megs: usize) -> Result<f64> {

// Run deno echo server in the background.
let mut echo_server = Command::new(deno_exe.to_str().unwrap())
.args(&[
"run",
"--allow-net",
"cli/tests/echo_server.ts",
SERVER_ADDR,
])
.args(&["run", "--allow-net", "echo_server.ts", SERVER_ADDR])
.current_dir(test_util::testdata_path())
.spawn()?;

std::thread::sleep(Duration::from_secs(5)); // wait for deno to wake up. TODO racy.
Expand Down
15 changes: 7 additions & 8 deletions cli/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|_| {
Expand Down Expand Up @@ -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());
Expand Down
Loading

0 comments on commit 15a7631

Please sign in to comment.