Skip to content

Commit e0366c8

Browse files
Add functional tests for availability of lib dependencies (#29)
Ensure that the test program actually uses the tested libraries, because otherwise they would not be linked
1 parent ea5c034 commit e0366c8

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

.github/test/crystal-libs_spec.cr

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require "spec"
2+
require "yaml"
3+
4+
it "yaml" do
5+
any = YAML::Any.new({
6+
YAML::Any.new("foo") => YAML::Any.new(12_i64)
7+
})
8+
YAML.parse(any.to_yaml).should eq any
9+
end
10+
11+
require "xml"
12+
13+
it "xml" do
14+
string = XML.build do |xml|
15+
xml.element("person", id: 1) do
16+
xml.element("firstname") { xml.text "Jane" }
17+
xml.element("lastname") { xml.text "Doe" }
18+
end
19+
end
20+
21+
document = XML.parse(string)
22+
person = document.first_element_child.should_not be_nil
23+
person["id"].should eq "1"
24+
25+
props = {} of String => String
26+
person.children.select(&.element?).each do |child|
27+
props[child.name] = child.content
28+
end
29+
props.should eq({
30+
"firstname" => "Jane",
31+
"lastname" => "Doe",
32+
})
33+
end
34+
35+
require "big"
36+
37+
it "big" do
38+
1.to_big_d.to_i.should eq 1
39+
end
40+
41+
require "openssl/sha1"
42+
43+
it "openssl" do
44+
OpenSSL::SHA1.hash("foobarbaz").should eq StaticArray[95, 85, 19, 248, 130, 47, 219, 229, 20, 90, 243, 59, 100, 216, 217, 112, 220, 249, 92, 110]
45+
end

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ jobs:
5757
crystal --version | grep -E "${v}\\b"
5858
if: ${{ contains(matrix.config.crystal, '.') }}
5959
- run: |
60-
crystal eval 'require "yaml"; require "xml"; require "big"; require "openssl"'
61-
60+
crystal spec .github/test/crystal-libs_spec.cr
6261
- run: |
6362
shards --version
6463
if: ${{ !contains('false', matrix.config.shards) }}

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ jobs:
5757
crystal --version | grep -E "${v}\\b"
5858
if: ${{ contains(matrix.config.crystal, '.') }}
5959
- run: |
60-
crystal eval 'require "yaml"; require "xml"; require "big"; require "openssl"'
61-
60+
crystal spec .github/test/crystal-libs_spec.cr
6261
- run: |
6362
shards --version
6463
if: ${{ !contains('false', matrix.config.shards) }}

0 commit comments

Comments
 (0)