Skip to content

Commit 36eede7

Browse files
committed
Fix: Package must return spec at commit when present, then use version
1 parent 22b776e commit 36eede7

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

src/package.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Shards
2525
end
2626

2727
def spec
28-
@spec ||= resolver.spec(version)
28+
@spec ||= resolver.spec(commit || version)
2929
end
3030

3131
def installed?

test/integration/install_test.cr

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,38 @@ class InstallCommandTest < Minitest::Test
318318
end
319319
end
320320

321-
def test_installs_executables
321+
def test_installs_executables_at_version
322322
metadata = {
323-
dependencies: {
324-
binary: {type: "path", path: rel_path(:binary)},
325-
},
323+
dependencies: {binary: "0.1.0"}
326324
}
327325
with_shard(metadata) { run("shards install --no-color") }
328326

329327
foobar = File.join(application_path, "bin", "foobar")
330328
baz = File.join(application_path, "bin", "baz")
329+
foo = File.join(application_path, "bin", "foo")
331330

332331
assert File.exists?(foobar), "Expected to have installed bin/foobar executable"
333332
assert File.exists?(baz), "Expected to have installed bin/baz executable"
333+
refute File.exists?(foo), "Expected not to have installed bin/foo executable"
334334

335335
assert_equal "OK\n", `#{foobar}`
336336
assert_equal "KO\n", `#{baz}`
337337
end
338+
339+
def test_installs_executables_at_refs
340+
metadata = {
341+
dependencies: {
342+
binary: {git: git_url(:binary), commit: git_commits(:binary)[-1]}
343+
},
344+
}
345+
with_shard(metadata) { run("shards install --no-color") }
346+
347+
foobar = File.join(application_path, "bin", "foobar")
348+
baz = File.join(application_path, "bin", "baz")
349+
foo = File.join(application_path, "bin", "foo")
350+
351+
assert File.exists?(foobar), "Expected to have installed bin/foobar executable"
352+
assert File.exists?(baz), "Expected to have installed bin/baz executable"
353+
refute File.exists?(foo), "Expected not to have installed bin/foo executable"
354+
end
338355
end

test/integration/update_test.cr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,21 @@ class UpdateCommandTest < Minitest::Test
216216
end
217217
end
218218

219-
def test_installs_executables
220-
metadata = {
221-
dependencies: {
222-
binary: {type: "path", path: rel_path(:binary)},
223-
},
224-
}
225-
with_shard(metadata) { run("shards install --no-color") }
226-
227-
create_file "binary", "bin/foo", "echo 'FOO'", perm: 0o755
228-
create_shard "binary", "name: binary\nversion: 0.2.0\nexecutables:\n - foobar\n - baz\n - foo"
229-
230-
with_shard(metadata) { run("shards update --no-color") }
219+
def test_installs_new_executables
220+
metadata = {dependencies: {binary: "0.2.0"}}
221+
lock = {binary: "0.1.0"}
222+
with_shard(metadata, lock) { run("shards update --no-color") }
231223

224+
foobar = File.join(application_path, "bin", "foobar")
225+
baz = File.join(application_path, "bin", "baz")
232226
foo = File.join(application_path, "bin", "foo")
227+
228+
assert File.exists?(foobar), "Expected to have installed bin/foobar executable"
229+
assert File.exists?(baz), "Expected to have installed bin/baz executable"
233230
assert File.exists?(foo), "Expected to have installed bin/foo executable"
231+
232+
assert_equal "OK\n", `#{foobar}`
233+
assert_equal "KO\n", `#{baz}`
234234
assert_equal "FOO\n", `#{foo}`
235235
end
236236

test/support/factories.cr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ module Shards
3636
contents = shard.is_a?(String) ? shard : "name: #{project}\nversion: #{version}\n"
3737
create_shard project, contents
3838
end
39+
Dir.cd(git_path(project)) do
40+
run "git add src/#{project}.cr"
41+
end
3942
create_git_commit project, "release: v#{version}"
4043
end
4144
create_git_tag(project, "v#{version}")

0 commit comments

Comments
 (0)