-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: rewrite deno test, add Deno.test() #3865
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
9450279
wip new testing framework
bartlomieju a135a6f
merge mod and new_mod
bartlomieju 339868d
fix runIfMain
bartlomieju 21fada7
self host js unit tests
bartlomieju ffc23e7
wip2
bartlomieju 2251411
wip3
bartlomieju 3bc052a
Merge branch 'master' into tests
bartlomieju 3a97cc5
basic matching working
bartlomieju f5d4f35
maybe working
bartlomieju 984b593
Merge branch 'master' into tests
bartlomieju c423aaa
fmt
bartlomieju c715799
dir glob expansion working somehow
bartlomieju df1f2b9
fix tests
bartlomieju 509bc58
remove Deno.runIfMain
bartlomieju bad13dc
disableLog
bartlomieju be9880b
fix declaration
bartlomieju dba93ea
reset CI
bartlomieju a25e942
remove globs from test runner
bartlomieju c53efa3
Merge branch 'master' into tests
bartlomieju dd9529b
fix import
bartlomieju c1f3307
revert std/
bartlomieju 9b5862c
smaller diff
bartlomieju d7d8dd2
reset CI
bartlomieju cf17d12
Merge remote-tracking branch 'upstream/master' into tests
bartlomieju 7acca37
life logic to test_command
bartlomieju 0af4e12
Merge branch 'master' into tests
bartlomieju 0f949a3
cleanup
bartlomieju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,15 +22,6 @@ macro_rules! sset { | |
}} | ||
} | ||
|
||
macro_rules! std_url { | ||
($x:expr) => { | ||
concat!("https://deno.land/[email protected]/", $x) | ||
}; | ||
} | ||
|
||
/// Used for `deno test...` subcommand | ||
const TEST_RUNNER_URL: &str = std_url!("testing/runner.ts"); | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub enum DenoSubcommand { | ||
Bundle { | ||
|
@@ -65,6 +56,12 @@ pub enum DenoSubcommand { | |
Run { | ||
script: String, | ||
}, | ||
Test { | ||
fail_fast: bool, | ||
quiet: bool, | ||
allow_none: bool, | ||
include: Option<Vec<String>>, | ||
}, | ||
Types, | ||
} | ||
|
||
|
@@ -495,40 +492,31 @@ fn run_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) { | |
} | ||
|
||
fn test_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) { | ||
flags.subcommand = DenoSubcommand::Run { | ||
script: TEST_RUNNER_URL.to_string(), | ||
}; | ||
flags.allow_read = true; | ||
|
||
run_test_args_parse(flags, matches); | ||
|
||
if matches.is_present("quiet") { | ||
flags.argv.push("--quiet".to_string()); | ||
} | ||
|
||
if matches.is_present("failfast") { | ||
flags.argv.push("--failfast".to_string()); | ||
} | ||
|
||
if matches.is_present("exclude") { | ||
flags.argv.push("--exclude".to_string()); | ||
let exclude: Vec<String> = matches | ||
.values_of("exclude") | ||
.unwrap() | ||
.map(String::from) | ||
.collect(); | ||
flags.argv.extend(exclude); | ||
} | ||
let quiet = matches.is_present("quiet"); | ||
let failfast = matches.is_present("failfast"); | ||
let allow_none = matches.is_present("allow_none"); | ||
|
||
if matches.is_present("files") { | ||
flags.argv.push("--".to_string()); | ||
let include = if matches.is_present("files") { | ||
let files: Vec<String> = matches | ||
.values_of("files") | ||
.unwrap() | ||
.map(String::from) | ||
.collect(); | ||
flags.argv.extend(files); | ||
} | ||
Some(files) | ||
} else { | ||
None | ||
}; | ||
|
||
flags.subcommand = DenoSubcommand::Test { | ||
quiet, | ||
fail_fast: failfast, | ||
include, | ||
allow_none, | ||
}; | ||
} | ||
|
||
fn types_subcommand<'a, 'b>() -> App<'a, 'b> { | ||
|
@@ -857,11 +845,10 @@ fn test_subcommand<'a, 'b>() -> App<'a, 'b> { | |
.takes_value(false), | ||
) | ||
.arg( | ||
Arg::with_name("exclude") | ||
.short("e") | ||
.long("exclude") | ||
.help("List of file names to exclude from run") | ||
.takes_value(true), | ||
Arg::with_name("allow_none") | ||
.long("allow-none") | ||
.help("Don't return error code if no test files are found") | ||
.takes_value(false), | ||
) | ||
.arg( | ||
Arg::with_name("files") | ||
|
@@ -2041,45 +2028,25 @@ mod tests { | |
); | ||
} | ||
|
||
#[test] | ||
fn test_with_exclude() { | ||
let r = flags_from_vec_safe(svec![ | ||
"deno", | ||
"test", | ||
"--exclude", | ||
"some_dir/", | ||
"dir1/", | ||
"dir2/" | ||
]); | ||
assert_eq!( | ||
r.unwrap(), | ||
DenoFlags { | ||
subcommand: DenoSubcommand::Run { | ||
script: TEST_RUNNER_URL.to_string(), | ||
}, | ||
argv: svec!["--exclude", "some_dir/", "--", "dir1/", "dir2/"], | ||
allow_read: true, | ||
..DenoFlags::default() | ||
} | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_with_allow_net() { | ||
let r = flags_from_vec_safe(svec![ | ||
"deno", | ||
"test", | ||
"--allow-net", | ||
"--allow-none", | ||
"dir1/", | ||
"dir2/" | ||
]); | ||
assert_eq!( | ||
r.unwrap(), | ||
DenoFlags { | ||
subcommand: DenoSubcommand::Run { | ||
script: TEST_RUNNER_URL.to_string(), | ||
subcommand: DenoSubcommand::Test { | ||
fail_fast: false, | ||
quiet: false, | ||
allow_none: true, | ||
include: Some(svec!["dir1/", "dir2/"]), | ||
}, | ||
argv: svec!["--", "dir1/", "dir2/"], | ||
allow_read: true, | ||
allow_net: true, | ||
..DenoFlags::default() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉