From 66ecc6bf2556ebfda8dc317e8f4ef27bf4ab918d Mon Sep 17 00:00:00 2001 From: Quinton Miller Date: Wed, 13 Dec 2023 23:01:19 +0800 Subject: [PATCH] Add `pending_wasm32` --- spec/compiler/crystal/tools/init_spec.cr | 1 - spec/spec_helper.cr | 1 + spec/std/socket/address_spec.cr | 1 - spec/std/socket/socket_spec.cr | 1 - spec/std/socket/tcp_socket_spec.cr | 1 - spec/std/spec_helper.cr | 1 + spec/std/string_spec.cr | 12 +++++------- spec/support/wasm32.cr | 19 +++++++++++++++++++ 8 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 spec/support/wasm32.cr diff --git a/spec/compiler/crystal/tools/init_spec.cr b/spec/compiler/crystal/tools/init_spec.cr index 71bbd8de9d35..c4c040fa9f44 100644 --- a/spec/compiler/crystal/tools/init_spec.cr +++ b/spec/compiler/crystal/tools/init_spec.cr @@ -7,7 +7,6 @@ require "spec" require "yaml" require "../../../support/tempfile" require "../../../support/env" -require "../../../support/win32" private def exec_init(project_name, project_dir = nil, type = "lib", force = false, skip_existing = false) args = [type, project_name] diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 98f39b1fc042..a1ee9f49daa1 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -8,6 +8,7 @@ require "compiler/requires" require "./support/syntax" require "./support/tempfile" require "./support/win32" +require "./support/wasm32" class Crystal::Program setter temp_var_counter diff --git a/spec/std/socket/address_spec.cr b/spec/std/socket/address_spec.cr index d2e4768db987..97f5791b8bea 100644 --- a/spec/std/socket/address_spec.cr +++ b/spec/std/socket/address_spec.cr @@ -1,6 +1,5 @@ require "spec" require "socket" -require "../../support/win32" require "spec/helpers/string" describe Socket::Address do diff --git a/spec/std/socket/socket_spec.cr b/spec/std/socket/socket_spec.cr index 79c5d8b2c9c5..f9597f3686e1 100644 --- a/spec/std/socket/socket_spec.cr +++ b/spec/std/socket/socket_spec.cr @@ -1,6 +1,5 @@ require "./spec_helper" require "../../support/tempfile" -require "../../support/win32" describe Socket, tags: "network" do describe ".unix" do diff --git a/spec/std/socket/tcp_socket_spec.cr b/spec/std/socket/tcp_socket_spec.cr index 68c00ccd2e79..ba782d68983b 100644 --- a/spec/std/socket/tcp_socket_spec.cr +++ b/spec/std/socket/tcp_socket_spec.cr @@ -1,7 +1,6 @@ {% skip_file if flag?(:wasm32) %} require "./spec_helper" -require "../../support/win32" describe TCPSocket, tags: "network" do describe "#connect" do diff --git a/spec/std/spec_helper.cr b/spec/std/spec_helper.cr index 75f8a1fe36d3..7f4b80405826 100644 --- a/spec/std/spec_helper.cr +++ b/spec/std/spec_helper.cr @@ -2,6 +2,7 @@ require "spec" require "../support/tempfile" require "../support/fibers" require "../support/win32" +require "../support/wasm32" def datapath(*components) File.join("spec", "std", "data", *components) diff --git a/spec/std/string_spec.cr b/spec/std/string_spec.cr index 178fa81a172c..0d60b3ac2466 100644 --- a/spec/std/string_spec.cr +++ b/spec/std/string_spec.cr @@ -2687,14 +2687,12 @@ describe "String" do end end - {% unless flag?(:wasm32) %} - it "allocates buffer of correct size (#3332)" do - String.new(255_u8) do |buffer| - LibGC.size(buffer).should be > 255 - {255, 0} - end + pending_wasm32 "allocates buffer of correct size (#3332)" do + String.new(255_u8) do |buffer| + LibGC.size(buffer).should be > 255 + {255, 0} end - {% end %} + end it "raises if returned bytesize is greater than capacity" do expect_raises ArgumentError, "Bytesize out of capacity bounds" do diff --git a/spec/support/wasm32.cr b/spec/support/wasm32.cr new file mode 100644 index 000000000000..98c9de69ea9e --- /dev/null +++ b/spec/support/wasm32.cr @@ -0,0 +1,19 @@ +require "spec" + +{% if flag?(:wasm32) %} + def pending_wasm32(description = "assert", file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + pending("#{description} [wasm32]", file, line, end_line) + end + + def pending_wasm32(*, describe, file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + pending_wasm32(describe, file, line, end_line) { } + end +{% else %} + def pending_wasm32(description = "assert", file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + it(description, file, line, end_line, &block) + end + + def pending_wasm32(*, describe, file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block) + describe(describe, file, line, end_line, &block) + end +{% end %}