Commit d1ec5ba2 authored by Jakub Jirutka's avatar Jakub Jirutka

testing/crystal: fix tests and enable check

parent 481cc18a
......@@ -3,7 +3,7 @@
# TODO: Fix SSL bindings for LibreSSL (https://github.com/crystal-lang/crystal/issues/4676)
pkgname=crystal
pkgver=0.24.2
pkgrel=2
pkgrel=3
_bootver=0.24.2
_llvmver=5
pkgdesc="The Crystal Programming Language"
......@@ -11,7 +11,7 @@ url="https://crystal-lang.org/"
arch="x86_64 aarch64"
license="Apache-2.0"
depends="gc-dev libatomic_ops libevent-dev libxml2-dev gcc gmp-dev pcre-dev yaml-dev"
checkdepends="openssl-dev paxmark readline-dev zlib-dev"
checkdepends="openssl-dev paxmark readline-dev tzdata zlib-dev"
makedepends="llvm$_llvmver-dev ${BUILD_STATIC:+"llvm$_llvmver-static"}"
subpackages="$pkgname-doc
$pkgname-bash-completion:bashcomp:noarch
......@@ -25,9 +25,10 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/crystal-lang/$pkgname/archiv
makefile-allow-extra-flags.patch
paxmark.patch
aarch64-linux-musl.patch
fix-codegen-specs.patch
disable-specs-using-GB2312-encoding.patch
"
builddir="$srcdir/$pkgname-$pkgver"
options="!check" # FIXME
export CRYSTAL_CONFIG_VERSION="$pkgver"
export CRYSTAL_CACHE_DIR="$srcdir/.cache"
......@@ -127,4 +128,6 @@ d6ed122a5ddb4e1ea772357cd3115dcf8cd92a75f973b6f7e4b8b6135fb4123fb98334495f6f312d
2f995903093da9af4263bf2d7fde75715a114b02b74ba26c8290d7b20042be8a2db305a2ea144925f054354f6f6a430750d19fa036bf764562dedb56da12866a fix-makefile-stderr-redirect.patch
d1641f538cb1ae9f817b57e19800b0af91e3723c752fba38b2644b8acc66d80862c6bef22194f1f4c64ae7d8393c2772f0a0ea0a76a199151ef8c74c686ea49f makefile-allow-extra-flags.patch
dec4ed7abfd215eec825bed97b1e40bf3aa8bd959a4ec7153ea1bc51d409d892ebec19ddb0372e3a543e74c7018aca0c1f3cf956fa1d95efb946c8c3417c8749 paxmark.patch
0252e850b79d622fe69329fac3653128b1cc0108961c928a9efa8fa5df1bce13692b6a520697c45c37791a9e6547d5ec7f0f11905e8299902055ab3dbdfd7556 aarch64-linux-musl.patch"
0252e850b79d622fe69329fac3653128b1cc0108961c928a9efa8fa5df1bce13692b6a520697c45c37791a9e6547d5ec7f0f11905e8299902055ab3dbdfd7556 aarch64-linux-musl.patch
702927a86c2e934511415e97093fb6fe04e2e63dd5a4e2e2b1fcc772c7f02e037f1b05e516943222f282515fc562618a83442e2d53cc899933a2b2e8ad8dd53d fix-codegen-specs.patch
269976fbc990dde075769e651c9fac6e7e0b39681e55cbd067c6d2a790c58a096bdc9981f62ae69b5217623025ba768daa63bc5316bd8ddd18192d88839aedcb disable-specs-using-GB2312-encoding.patch"
From 774c93390cfa5af0675b398b308f90cd692b4af6 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Mon, 26 Mar 2018 02:20:06 +0200
Subject: [PATCH] Disable specs using GB2312 encoding on musl
Musl libc does not support GB2312 encoding.
Fixes #3976
Upstream-Issue: https://github.com/crystal-lang/crystal/pull/5867
---
spec/std/io/buffered_spec.cr | 19 ++++---
spec/std/io/io_spec.cr | 133 +++++++++++++++++++++++--------------------
spec/std/string_spec.cr | 41 ++++++-------
3 files changed, 104 insertions(+), 89 deletions(-)
diff --git a/spec/std/io/buffered_spec.cr b/spec/std/io/buffered_spec.cr
index 1e4d4a473f..6e34c994ea 100644
--- a/spec/std/io/buffered_spec.cr
+++ b/spec/std/io/buffered_spec.cr
@@ -374,15 +374,18 @@ describe "IO::Buffered" do
end
end
- it "gets big GB2312 string" do
- str = ("你好我是人\n" * 1000).encode("GB2312")
- base_io = IO::Memory.new(str)
- io = BufferedWrapper.new(base_io)
- io.set_encoding("GB2312")
- 1000.times do
- io.gets(chomp: false).should eq("你好我是人\n")
+ # Musl does not support GB2312 encoding.
+ {% unless flag?(:musl) %}
+ it "gets big GB2312 string" do
+ str = ("你好我是人\n" * 1000).encode("GB2312")
+ base_io = IO::Memory.new(str)
+ io = BufferedWrapper.new(base_io)
+ io.set_encoding("GB2312")
+ 1000.times do
+ io.gets(chomp: false).should eq("你好我是人\n")
+ end
end
- end
+ {% end %}
it "reads char" do
str = "x\nHello world" + ("1234567890" * 1000)
diff --git a/spec/std/io/io_spec.cr b/spec/std/io/io_spec.cr
index 01e829c800..946bfa70ac 100644
--- a/spec/std/io/io_spec.cr
+++ b/spec/std/io/io_spec.cr
@@ -550,16 +550,19 @@ describe IO do
end
end
- it "gets big GB2312 string" do
- 2.times do
- str = ("你好我是人\n" * 1000).encode("GB2312")
- io = SimpleIOMemory.new(str)
- io.set_encoding("GB2312")
- 1000.times do
- io.gets.should eq("你好我是人")
+ # Musl does not support GB2312 encoding.
+ {% unless flag?(:musl) %}
+ it "gets big GB2312 string" do
+ 2.times do
+ str = ("你好我是人\n" * 1000).encode("GB2312")
+ io = SimpleIOMemory.new(str)
+ io.set_encoding("GB2312")
+ 1000.times do
+ io.gets.should eq("你好我是人")
+ end
end
end
- end
+ {% end %}
it "does gets on unicode with char and limit without off-by-one" do
io = SimpleIOMemory.new("test\nabc".encode("UCS-2LE"))
@@ -635,51 +638,54 @@ describe IO do
io.read_utf8_byte.should be_nil
end
- it "reads utf8" do
- io = IO::Memory.new("你".encode("GB2312"))
- io.set_encoding("GB2312")
+ # Musl does not support GB2312 encoding.
+ {% unless flag?(:musl) %}
+ it "reads utf8" do
+ io = IO::Memory.new("你".encode("GB2312"))
+ io.set_encoding("GB2312")
- buffer = uninitialized UInt8[1024]
- bytes_read = io.read_utf8(buffer.to_slice) # => 3
- bytes_read.should eq(3)
- buffer.to_slice[0, bytes_read].to_a.should eq("你".bytes)
- end
+ buffer = uninitialized UInt8[1024]
+ bytes_read = io.read_utf8(buffer.to_slice) # => 3
+ bytes_read.should eq(3)
+ buffer.to_slice[0, bytes_read].to_a.should eq("你".bytes)
+ end
- it "raises on incomplete byte sequence" do
- io = SimpleIOMemory.new("好".byte_slice(0, 1))
- io.set_encoding("GB2312")
- expect_raises ArgumentError, "Incomplete multibyte sequence" do
- io.read_char
+ it "raises on incomplete byte sequence" do
+ io = SimpleIOMemory.new("好".byte_slice(0, 1))
+ io.set_encoding("GB2312")
+ expect_raises ArgumentError, "Incomplete multibyte sequence" do
+ io.read_char
+ end
end
- end
- it "says invalid byte sequence" do
- io = SimpleIOMemory.new(Slice.new(1, 140_u8))
- io.set_encoding("GB2312")
- expect_raises ArgumentError, "Invalid multibyte sequence" do
- io.read_char
+ it "says invalid byte sequence" do
+ io = SimpleIOMemory.new(Slice.new(1, 140_u8))
+ io.set_encoding("GB2312")
+ expect_raises ArgumentError, "Invalid multibyte sequence" do
+ io.read_char
+ end
end
- end
- it "skips invalid byte sequences" do
- string = String.build do |str|
- str.write "好".encode("GB2312")
- str.write_byte 140_u8
- str.write "是".encode("GB2312")
+ it "skips invalid byte sequences" do
+ string = String.build do |str|
+ str.write "好".encode("GB2312")
+ str.write_byte 140_u8
+ str.write "是".encode("GB2312")
+ end
+ io = SimpleIOMemory.new(string)
+ io.set_encoding("GB2312", invalid: :skip)
+ io.read_char.should eq('好')
+ io.read_char.should eq('是')
+ io.read_char.should be_nil
end
- io = SimpleIOMemory.new(string)
- io.set_encoding("GB2312", invalid: :skip)
- io.read_char.should eq('好')
- io.read_char.should eq('是')
- io.read_char.should be_nil
- end
- it "says invalid 'invalid' option" do
- io = SimpleIOMemory.new
- expect_raises ArgumentError, "Valid values for `invalid` option are `nil` and `:skip`, not :foo" do
- io.set_encoding("GB2312", invalid: :foo)
+ it "says invalid 'invalid' option" do
+ io = SimpleIOMemory.new
+ expect_raises ArgumentError, "Valid values for `invalid` option are `nil` and `:skip`, not :foo" do
+ io.set_encoding("GB2312", invalid: :foo)
+ end
end
- end
+ {% end %}
it "says invalid encoding" do
io = SimpleIOMemory.new("foo")
@@ -803,28 +809,31 @@ describe IO do
slice.should eq("hi-123-45.67".encode("UCS-2LE"))
end
- it "raises on invalid byte sequence" do
- io = SimpleIOMemory.new
- io.set_encoding("GB2312")
- expect_raises ArgumentError, "Invalid multibyte sequence" do
- io.print "ñ"
+ # Musl does not support GB2312 encoding.
+ {% unless flag?(:musl) %}
+ it "raises on invalid byte sequence" do
+ io = SimpleIOMemory.new
+ io.set_encoding("GB2312")
+ expect_raises ArgumentError, "Invalid multibyte sequence" do
+ io.print "ñ"
+ end
end
- end
- it "skips on invalid byte sequence" do
- io = SimpleIOMemory.new
- io.set_encoding("GB2312", invalid: :skip)
- io.print "ñ"
- io.print "foo"
- end
+ it "skips on invalid byte sequence" do
+ io = SimpleIOMemory.new
+ io.set_encoding("GB2312", invalid: :skip)
+ io.print "ñ"
+ io.print "foo"
+ end
- it "raises on incomplete byte sequence" do
- io = SimpleIOMemory.new
- io.set_encoding("GB2312")
- expect_raises ArgumentError, "Incomplete multibyte sequence" do
- io.print "好".byte_slice(0, 1)
+ it "raises on incomplete byte sequence" do
+ io = SimpleIOMemory.new
+ io.set_encoding("GB2312")
+ expect_raises ArgumentError, "Incomplete multibyte sequence" do
+ io.print "好".byte_slice(0, 1)
+ end
end
- end
+ {% end %}
it "says invalid encoding" do
io = SimpleIOMemory.new
diff --git a/spec/std/string_spec.cr b/spec/std/string_spec.cr
index 6fbdebc7d0..761398fb8f 100644
--- a/spec/std/string_spec.cr
+++ b/spec/std/string_spec.cr
@@ -2285,35 +2285,38 @@ describe "String" do
end
end
- it "raises if illegal byte sequence" do
- expect_raises ArgumentError, "Invalid multibyte sequence" do
- "ñ".encode("GB2312")
+ # Musl does not support GB2312 encoding.
+ {% unless flag?(:musl) %}
+ it "raises if illegal byte sequence" do
+ expect_raises ArgumentError, "Invalid multibyte sequence" do
+ "ñ".encode("GB2312")
+ end
end
- end
- it "doesn't raise on invalid byte sequence" do
- "好ñ是".encode("GB2312", invalid: :skip).to_a.should eq([186, 195, 202, 199])
- end
+ it "doesn't raise on invalid byte sequence" do
+ "好ñ是".encode("GB2312", invalid: :skip).to_a.should eq([186, 195, 202, 199])
+ end
- it "raises if incomplete byte sequence" do
- expect_raises ArgumentError, "Incomplete multibyte sequence" do
- "好".byte_slice(0, 1).encode("GB2312")
+ it "raises if incomplete byte sequence" do
+ expect_raises ArgumentError, "Incomplete multibyte sequence" do
+ "好".byte_slice(0, 1).encode("GB2312")
+ end
end
- end
- it "doesn't raise if incomplete byte sequence" do
- ("好".byte_slice(0, 1) + "是").encode("GB2312", invalid: :skip).to_a.should eq([202, 199])
- end
+ it "doesn't raise if incomplete byte sequence" do
+ ("好".byte_slice(0, 1) + "是").encode("GB2312", invalid: :skip).to_a.should eq([202, 199])
+ end
+
+ it "decodes with skip" do
+ bytes = Bytes[186, 195, 140, 202, 199]
+ String.new(bytes, "GB2312", invalid: :skip).should eq("好是")
+ end
+ {% end %}
it "decodes" do
bytes = "Hello".encode("UTF-16LE")
String.new(bytes, "UTF-16LE").should eq("Hello")
end
-
- it "decodes with skip" do
- bytes = Bytes[186, 195, 140, 202, 199]
- String.new(bytes, "GB2312", invalid: :skip).should eq("好是")
- end
end
it "inserts" do
From 19bad9d05b723980551eb203715456e700b06002 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Mon, 26 Mar 2018 00:44:52 +0200
Subject: [PATCH 1/2] Fix codegen/asm specs to run x86 ASM only on x86_64 and
i686
See https://github.com/crystal-lang/crystal/pull/5861#issuecomment-376006679
Upstream-Issue: https://github.com/crystal-lang/crystal/pull/5866
---
spec/compiler/codegen/asm_spec.cr | 59 ++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 28 deletions(-)
diff --git a/spec/compiler/codegen/asm_spec.cr b/spec/compiler/codegen/asm_spec.cr
index 6fe8cbc26e..bc68d0f0cc 100644
--- a/spec/compiler/codegen/asm_spec.cr
+++ b/spec/compiler/codegen/asm_spec.cr
@@ -1,34 +1,37 @@
require "../../spec_helper"
describe "Code gen: asm" do
- it "codegens without inputs" do
- run(%(
- dst = uninitialized Int32
- asm("mov $$1234, $0" : "=r"(dst))
- dst
- )).to_i.should eq(1234)
- end
+ # TODO: arm asm tests
+ {% if flag?(:i686) || flag?(:x86_64) %}
+ it "codegens without inputs" do
+ run(%(
+ dst = uninitialized Int32
+ asm("mov $$1234, $0" : "=r"(dst))
+ dst
+ )).to_i.should eq(1234)
+ end
- it "codegens with one input" do
- run(%(
- src = 1234
- dst = uninitialized Int32
- asm("mov $1, $0" : "=r"(dst) : "r"(src))
- dst
- )).to_i.should eq(1234)
- end
+ it "codegens with one input" do
+ run(%(
+ src = 1234
+ dst = uninitialized Int32
+ asm("mov $1, $0" : "=r"(dst) : "r"(src))
+ dst
+ )).to_i.should eq(1234)
+ end
- it "codegens with two inputs" do
- run(%(
- c = uninitialized Int32
- a = 20
- b = 22
- asm(
- "add $2, $0"
- : "=r"(c)
- : "0"(a), "r"(b)
- )
- c
- )).to_i.should eq(42)
- end
+ it "codegens with two inputs" do
+ run(%(
+ c = uninitialized Int32
+ a = 20
+ b = 22
+ asm(
+ "add $2, $0"
+ : "=r"(c)
+ : "0"(a), "r"(b)
+ )
+ c
+ )).to_i.should eq(42)
+ end
+ {% end %}
end
From bde57387cf7239dea152b870471500da8faaec6f Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Mon, 26 Mar 2018 00:48:14 +0200
Subject: [PATCH 2/2] Fix codegen/sizeof specs for aarch64 (and other 64bit
arches)
See https://github.com/crystal-lang/crystal/pull/5861#issuecomment-376006679
---
spec/compiler/codegen/sizeof_spec.cr | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/spec/compiler/codegen/sizeof_spec.cr b/spec/compiler/codegen/sizeof_spec.cr
index 2f703abd1c..bc4a2d5b9a 100644
--- a/spec/compiler/codegen/sizeof_spec.cr
+++ b/spec/compiler/codegen/sizeof_spec.cr
@@ -48,7 +48,7 @@ describe "Code gen: sizeof" do
# be struct { 8 bytes, 8 bytes }.
#
# In 32 bits structs are aligned to 4 bytes, so it remains the same.
- {% if flag?(:x86_64) %}
+ {% if flag?(:bits64) %}
size.should eq(16)
{% else %}
size.should eq(12)
@@ -137,7 +137,7 @@ describe "Code gen: sizeof" do
sizeof(typeof(foo))
)).to_i
- {% if flag?(:x86_64) %}
+ {% if flag?(:bits64) %}
size.should eq(8)
{% else %}
size.should eq(4)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment