-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from Shopify/improve-dev-commands
Improve dev commands
- Loading branch information
Showing
2 changed files
with
69 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
def main | ||
begin | ||
command = create_command | ||
rescue ArgumentError => e | ||
abort(e.message) | ||
end | ||
puts "Running #{command.join(" ")}" | ||
system(*command) | ||
end | ||
|
||
def create_command | ||
case ARGV.length | ||
when 0 | ||
["bundle", "exec", "rake", "test"] | ||
when 1 | ||
filename = ARGV[0] | ||
["bundle", "exec", "rake", "test", "TEST=#{filename}"] | ||
when 2 | ||
filename = ARGV[0] | ||
test_name = ARGV[1] | ||
test_name_with_underscores = test_name.tr(" ", "_") | ||
test_name_pattern = "/#{Regexp.escape(test_name_with_underscores)}/" | ||
["bundle", "exec", "rake", "test", "TEST=#{filename}", "TESTOPTS=\"--name=#{test_name_pattern} -v\""] | ||
else | ||
raise ArgumentError, "Too many arguments. Did you forget to put the test name in quotes?" | ||
end | ||
end | ||
|
||
main |
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