Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable more win32 specs #8683

Merged
2 changes: 1 addition & 1 deletion .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
make
- name: Cross-compile stdlib specs
run: |
bin/crystal build --cross-compile --target x86_64-pc-windows-msvc --exclude-warnings spec/std spec/std_spec.cr
bin/crystal build --cross-compile --target x86_64-pc-windows-msvc --exclude-warnings spec/std spec/std_spec.cr -Dwithout_zlib -Dwithout_openssl
- name: Upload compiled object
uses: actions/upload-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion spec/generate_windows_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ echo
for spec in $(find "spec/$SPEC_SUITE" -type f -iname "*_spec.cr" | sort); do
require="require \"./${spec##spec/}\""

if ! linker_command=$($CRYSTAL_BIN build --cross-compile --target x86_64--windows-msvc "$spec" 2>/dev/null); then
if ! linker_command=$($CRYSTAL_BIN build --cross-compile --target x86_64--windows-msvc -Dwithout_zlib -Dwithout_openssl "$spec" 2>/dev/null); then
straight-shoota marked this conversation as resolved.
Show resolved Hide resolved
echo "# $require (failed codegen)"
continue
fi
Expand Down
2 changes: 1 addition & 1 deletion spec/std/http/client/response_spec.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec"
require "http/client/response"

class HTTP::Client
class HTTP::Client::Response
describe Response do
it "parses response with body" do
response = Response.from_io(IO::Memory.new("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 5\r\n\r\nhelloworld"))
Expand Down
1 change: 1 addition & 0 deletions spec/std/http/cookie_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "spec"
require "http/cookie"
require "http/headers"

private def parse_first_cookie(header)
cookies = HTTP::Cookie::Parser.parse_cookies(header)
Expand Down
3 changes: 2 additions & 1 deletion spec/std/http/formdata/builder_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "spec"
require "http"
require "http/formdata"
require "http/server/response"

describe HTTP::FormData::Builder do
it "builds valid form-data messages" do
Expand Down
2 changes: 1 addition & 1 deletion spec/std/http/formdata/parser_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "spec"
require "http"
require "http/formdata"

describe HTTP::FormData::Parser do
it "parses formdata" do
Expand Down
5 changes: 3 additions & 2 deletions spec/std/http/formdata_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "spec"
require "http"
require "http/formdata"
require "http/server/response"

describe HTTP::FormData do
describe ".parse(IO, String)" do
Expand Down Expand Up @@ -94,7 +95,7 @@ describe HTTP::FormData do
end
end

describe ".build(HTTP::Response, String)" do
describe ".build(HTTP::Server::Response, String)" do
it "builds a message" do
io = IO::Memory.new
response = HTTP::Server::Response.new(io)
Expand Down
2 changes: 1 addition & 1 deletion spec/std/http/http_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe HTTP do
end

it "with local time zone" do
time = Time.local(1994, 11, 6, 8, 49, 37, nanosecond: 0, location: Time::Location.load("Europe/Berlin"))
time = Time.local(1994, 11, 6, 8, 49, 37, nanosecond: 0, location: Time::Location.fixed(3600))
HTTP.format_time(time).should eq(time.to_utc.to_s("%a, %d %b %Y %H:%M:%S GMT"))
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/std/http/server/handlers/error_handler_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "spec"
require "http/server"
require "http/server/handler"

describe HTTP::ErrorHandler do
it "rescues from exception" do
Expand Down
2 changes: 1 addition & 1 deletion spec/std/http/server/handlers/handler_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "spec"
require "http/server"
require "http/server/handler"

private class EmptyHTTPHandler
include HTTP::Handler
Expand Down
2 changes: 1 addition & 1 deletion spec/std/http/server/handlers/log_handler_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "spec"
require "http/server"
require "http/server/handler"

describe HTTP::LogHandler do
it "logs" do
Expand Down
3 changes: 2 additions & 1 deletion spec/std/http/server/handlers/static_file_handler_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "../../../spec_helper"
require "http/server"
require "http/server/handler"
require "http/client/response"

private def handle(request, fallthrough = true, directory_listing = true, ignore_body = false)
io = IO::Memory.new
Expand Down
4 changes: 3 additions & 1 deletion spec/std/http/server/request_processor_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ describe HTTP::Server::RequestProcessor do

it "handles Errno" do
processor = HTTP::Server::RequestProcessor.new { }
input = RaiseErrno.new(Errno::ECONNRESET)
# Using EPERM here instead of a more reasonable ECONNRESET because the
# latter is not available on all platforms (win32).
input = RaiseErrno.new(Errno::EPERM)
output = IO::Memory.new
processor.process(input, output)
output.rewind.gets_to_end.empty?.should be_true
Expand Down
8 changes: 5 additions & 3 deletions spec/std/json/any_spec.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "spec"
require "../spec_helper"
require "json"
require "yaml"
{% unless flag?(:win32) %}
require "yaml"
{% end %}
RX14 marked this conversation as resolved.
Show resolved Hide resolved

describe JSON::Any do
describe "casts" do
Expand Down Expand Up @@ -170,7 +172,7 @@ describe JSON::Any do
any2.as_a[0].as_a.should_not be(any.as_a[0].as_a)
end

it "#to_yaml" do
pending_win32 "#to_yaml" do
any = JSON.parse <<-JSON
{
"foo": "bar",
Expand Down
16 changes: 10 additions & 6 deletions spec/std/json/mapping_spec.cr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require "spec"
require "../spec_helper"
require "json"
require "uuid"
require "uuid/json"
require "big/json"
{% unless flag?(:win32) %}
require "big/json"
{% end %}

private class JSONPerson
JSON.mapping({
Expand Down Expand Up @@ -38,9 +40,11 @@ private class JSONWithUUID
JSON.mapping value: UUID
end

private class JSONWithBigDecimal
JSON.mapping value: BigDecimal
end
{% unless flag?(:win32) %}
private class JSONWithBigDecimal
JSON.mapping value: BigDecimal
end
{% end %}

private class JSONWithTime
JSON.mapping({
Expand Down Expand Up @@ -612,7 +616,7 @@ describe "JSON mapping" do
end
end

describe "BigDecimal" do
pending_win32 describe: "BigDecimal" do
it "parses json string with BigDecimal" do
json = JSONWithBigDecimal.from_json(%({"value": "10.05"}))
json.value.should eq(BigDecimal.new("10.05"))
Expand Down
70 changes: 38 additions & 32 deletions spec/std/json/serializable_spec.cr
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require "spec"
require "../spec_helper"
require "json"
require "big"
require "big/json"
{% unless flag?(:win32) %}
require "yaml"
require "big"
require "big/json"
{% end %}
require "uuid"
require "uuid/json"
require "yaml"

record JSONAttrPoint, x : Int32, y : Int32 do
include JSON::Serializable
Expand Down Expand Up @@ -94,11 +96,13 @@ class JSONAttrWithUUID
property value : UUID
end

class JSONAttrWithBigDecimal
include JSON::Serializable
{% unless flag?(:win32) %}
class JSONAttrWithBigDecimal
include JSON::Serializable

property value : BigDecimal
end
property value : BigDecimal
end
{% end %}

class JSONAttrWithTime
include JSON::Serializable
Expand Down Expand Up @@ -297,36 +301,38 @@ class JSONAttrModuleTest2 < JSONAttrModuleTest
end
end

struct JSONAttrPersonWithYAML
include JSON::Serializable
include YAML::Serializable
{% unless flag?(:win32) %}
struct JSONAttrPersonWithYAML
include JSON::Serializable
include YAML::Serializable

property name : String
property age : Int32?
property name : String
property age : Int32?

def initialize(@name : String, @age : Int32? = nil)
def initialize(@name : String, @age : Int32? = nil)
end
end
end

struct JSONAttrPersonWithYAMLInitializeHook
include JSON::Serializable
include YAML::Serializable
struct JSONAttrPersonWithYAMLInitializeHook
include JSON::Serializable
include YAML::Serializable

property name : String
property age : Int32?
property name : String
property age : Int32?

def initialize(@name : String, @age : Int32? = nil)
after_initialize
end
def initialize(@name : String, @age : Int32? = nil)
after_initialize
end

@[JSON::Field(ignore: true)]
@[YAML::Field(ignore: true)]
property msg : String?
@[JSON::Field(ignore: true)]
@[YAML::Field(ignore: true)]
property msg : String?

def after_initialize
@msg = "Hello " + name
def after_initialize
@msg = "Hello " + name
end
end
end
{% end %}

abstract class JSONShape
include JSON::Serializable
Expand Down Expand Up @@ -781,7 +787,7 @@ describe "JSON mapping" do
end
end

describe "BigDecimal" do
pending_win32 describe: "BigDecimal" do
it "parses json string with BigDecimal" do
json = JSONAttrWithBigDecimal.from_json(%({"value": "10.05"}))
json.value.should eq(BigDecimal.new("10.05"))
Expand Down Expand Up @@ -810,7 +816,7 @@ describe "JSON mapping" do
it { JSONAttrModuleTest2.from_json(%({"bar": 30, "moo": 40})).to_tuple.should eq({40, 15, 30}) }
end

it "works together with yaml" do
pending_win32 "works together with yaml" do
person = JSONAttrPersonWithYAML.new("Vasya", 30)
person.to_json.should eq "{\"name\":\"Vasya\",\"age\":30}"
person.to_yaml.should eq "---\nname: Vasya\nage: 30\n"
Expand All @@ -819,7 +825,7 @@ describe "JSON mapping" do
JSONAttrPersonWithYAML.from_yaml(person.to_yaml).should eq person
end

it "yaml and json with after_initialize hook" do
pending_win32 "yaml and json with after_initialize hook" do
person = JSONAttrPersonWithYAMLInitializeHook.new("Vasya", 30)
person.msg.should eq "Hello Vasya"

Expand Down
30 changes: 16 additions & 14 deletions spec/std/json/serialization_spec.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require "spec"
require "../spec_helper"
require "json"
require "big"
require "big/json"
{% unless flag?(:win32) %}
require "big"
require "big/json"
{% end %}
require "uuid"
require "uuid/json"

Expand Down Expand Up @@ -57,15 +59,15 @@ describe "JSON serialization" do
Hash(Float64, String).from_json(%({"1.23": "x", "4.56": "y"})).should eq({1.23 => "x", 4.56 => "y"})
end

it "does Hash(BigInt, String)#from_json" do
pending_win32 "does Hash(BigInt, String)#from_json" do
Hash(BigInt, String).from_json(%({"12345678901234567890": "x"})).should eq({"12345678901234567890".to_big_i => "x"})
end

it "does Hash(BigFloat, String)#from_json" do
pending_win32 "does Hash(BigFloat, String)#from_json" do
Hash(BigFloat, String).from_json(%({"1234567890.123456789": "x"})).should eq({"1234567890.123456789".to_big_f => "x"})
end

it "does Hash(BigDecimal, String)#from_json" do
pending_win32 "does Hash(BigDecimal, String)#from_json" do
Hash(BigDecimal, String).from_json(%({"1234567890.123456789": "x"})).should eq({"1234567890.123456789".to_big_d => "x"})
end

Expand Down Expand Up @@ -113,19 +115,19 @@ describe "JSON serialization" do
tuple.should be_a(NamedTuple(x: Int32?, y: String))
end

it "does for BigInt" do
pending_win32 "does for BigInt" do
big = BigInt.from_json("123456789123456789123456789123456789123456789")
big.should be_a(BigInt)
big.should eq(BigInt.new("123456789123456789123456789123456789123456789"))
end

it "does for BigFloat" do
pending_win32 "does for BigFloat" do
big = BigFloat.from_json("1234.567891011121314")
big.should be_a(BigFloat)
big.should eq(BigFloat.new("1234.567891011121314"))
end

it "does for BigFloat from int" do
pending_win32 "does for BigFloat from int" do
big = BigFloat.from_json("1234")
big.should be_a(BigFloat)
big.should eq(BigFloat.new("1234"))
Expand All @@ -149,13 +151,13 @@ describe "JSON serialization" do
uuid.should eq(UUID.new("ee843b26-56d8-472b-b343-0b94ed9077ff"))
end

it "does for BigDecimal from int" do
pending_win32 "does for BigDecimal from int" do
big = BigDecimal.from_json("1234")
big.should be_a(BigDecimal)
big.should eq(BigDecimal.new("1234"))
end

it "does for BigDecimal from float" do
pending_win32 "does for BigDecimal from float" do
big = BigDecimal.from_json("1234.05")
big.should be_a(BigDecimal)
big.should eq(BigDecimal.new("1234.05"))
Expand Down Expand Up @@ -355,7 +357,7 @@ describe "JSON serialization" do
{1.2 => 2, 3.4 => 6}.to_json.should eq(%({"1.2":2,"3.4":6}))
end

it "does for Hash with BigInt keys" do
pending_win32 "does for Hash with BigInt keys" do
{123.to_big_i => 2}.to_json.should eq(%({"123":2}))
end

Expand All @@ -375,12 +377,12 @@ describe "JSON serialization" do
JSONSpecEnum::One.to_json.should eq("1")
end

it "does for BigInt" do
pending_win32 "does for BigInt" do
big = BigInt.new("123456789123456789123456789123456789123456789")
big.to_json.should eq("123456789123456789123456789123456789123456789")
end

it "does for BigFloat" do
pending_win32 "does for BigFloat" do
big = BigFloat.new("1234.567891011121314")
big.to_json.should eq("1234.567891011121314")
end
Expand Down
Loading