forked from crystal-lang/shards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace minitest.cr in favor of std-lib spec (crystal-lang#334)
- Loading branch information
Brian J. Cardiff
committed
Mar 23, 2020
1 parent
4cc61bf
commit 6053248
Showing
40 changed files
with
1,401 additions
and
1,490 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
require "./spec_helper" | ||
|
||
private def bin_path(name) | ||
File.join(application_path, "bin", name) | ||
end | ||
|
||
describe "build" do | ||
before_each do | ||
Dir.mkdir(File.join(application_path, "src")) | ||
File.write(File.join(application_path, "src", "cli.cr"), "puts __FILE__") | ||
|
||
Dir.mkdir(File.join(application_path, "src", "commands")) | ||
File.write(File.join(application_path, "src", "commands", "check.cr"), "puts __LINE__") | ||
|
||
File.write File.join(application_path, "shard.yml"), <<-YAML | ||
name: build | ||
version: 0.1.0 | ||
targets: | ||
app: | ||
main: src/cli.cr | ||
alt: | ||
main: src/cli.cr | ||
check: | ||
main: src/commands/check.cr | ||
YAML | ||
end | ||
|
||
it "builds all targets" do | ||
Dir.cd(application_path) do | ||
run "shards build --no-color" | ||
|
||
File.exists?(bin_path("app")).should be_true | ||
File.exists?(bin_path("alt")).should be_true | ||
File.exists?(bin_path("check")).should be_true | ||
|
||
`#{bin_path("app")}`.chomp.should eq(File.join(application_path, "src", "cli.cr")) | ||
`#{bin_path("alt")}`.chomp.should eq(File.join(application_path, "src", "cli.cr")) | ||
`#{bin_path("check")}`.chomp.should eq("1") | ||
end | ||
end | ||
|
||
it "builds specified targets" do | ||
Dir.cd(application_path) do | ||
run "shards build --no-color alt check" | ||
File.exists?(bin_path("app")).should be_false | ||
File.exists?(bin_path("alt")).should be_true | ||
File.exists?(bin_path("check")).should be_true | ||
end | ||
end | ||
|
||
it "fails to build unknown target" do | ||
Dir.cd(application_path) do | ||
ex = expect_raises(FailedCommand) do | ||
run "shards build --no-color app unknown check" | ||
end | ||
ex.stdout.should contain("target unknown was not found") | ||
File.exists?(bin_path("app")).should be_true | ||
File.exists?(bin_path("check")).should be_false | ||
end | ||
end | ||
|
||
it "reports error when target failed to compile" do | ||
File.write File.join(application_path, "src", "cli.cr"), "a = ......" | ||
|
||
Dir.cd(application_path) do | ||
ex = expect_raises(FailedCommand) do | ||
run "shards build --no-color app" | ||
end | ||
ex.stdout.should contain("target app failed to compile") | ||
ex.stdout.should contain("unexpected token: ...") | ||
File.exists?(bin_path("app")).should be_false | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "./spec_helper" | ||
|
||
private def shard_path | ||
File.join(application_path, Shards::SPEC_FILENAME) | ||
end | ||
|
||
describe "init" do | ||
it "creates shard.yml" do | ||
Dir.cd(application_path) do | ||
run "shards init" | ||
File.exists?(File.join(application_path, Shards::SPEC_FILENAME)).should be_true | ||
spec = Shards::Spec.from_file(shard_path) | ||
spec.name.should eq("integration") | ||
spec.version.should eq("0.1.0") | ||
end | ||
end | ||
|
||
it "won't overwrite shard.yml" do | ||
Dir.cd(application_path) do | ||
File.write(shard_path, "") | ||
ex = expect_raises(FailedCommand) { run "shards init --no-color" } | ||
ex.stdout.should contain("#{Shards::SPEC_FILENAME} already exists") | ||
File.read(shard_path).should be_empty | ||
end | ||
end | ||
end |
Oops, something went wrong.