Skip to content

Commit

Permalink
Improve encoding test
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki committed Nov 20, 2024
1 parent 725aab3 commit 1575407
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/engines/ruby/2.1/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 2.7.11
RUN gem install bundler --version 1.17.3
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/2.2/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 2.7.11
RUN gem install bundler --version 1.17.3
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/2.3/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.3.26
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/2.4/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.3.26
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/2.5/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.3.26
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/2.6/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.3.26
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/2.7/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.3.26
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/3.0/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.5.21
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/3.1/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.5.21
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/3.2/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.5.21
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/3.3/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.5.21
RUN gem install bundler:2.3.26
Expand Down
2 changes: 2 additions & 0 deletions src/engines/ruby/3.4/Dockerfile.musl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARG REPRO_RUN_KEY=0
# updated by changing the `REPRO_RUN_KEY`.
RUN true "${REPRO_RUN_KEY}" && apk update

ENV LANG en_US.UTF-8

## Install a pinned RubyGems and Bundler
RUN gem update --system 3.5.21
RUN gem install bundler:2.3.26
Expand Down
6 changes: 5 additions & 1 deletion tasks/docker.rake
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ namespace :docker do
tag = target[:tag]
platform = docker_platform

exec "docker run --rm -it --platform #{platform} -v #{Dir.pwd}:#{Dir.pwd} -w #{Dir.pwd} #{image}:#{tag} /bin/sh"
version = tag =~ /^(\d+\.\d+)/ && $1
engine = image =~ /([^\/]+)$/ && $1
gemfile = "gemfiles/#{engine}-#{version}.gemfile"

exec "docker run --rm -it --platform #{platform} -v #{Dir.pwd}:#{Dir.pwd} -w #{Dir.pwd} -e BUNDLE_GEMFILE=#{Dir.pwd}/#{gemfile} #{image}:#{tag} /bin/sh"
end

desc "Run container with irb."
Expand Down
26 changes: 20 additions & 6 deletions test/engines/test_encoding.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
require 'minitest/autorun'
require "minitest/autorun"

# polyfill for Ruby 2.2 and down, used by minitest
unless "".respond_to?(:match?)
String.instance_eval do
def match?(other)
(Regexp === other) ? other.match?(self) : (self == other)
end
end
end

class TestEncoding < Minitest::Test
def test_utf8
assert_equal("".encoding, Encoding::UTF_8)
def test_utf8_lang
assert_equal("en_US.UTF-8", ENV["LANG"])
end

def test_utf8_string
assert_equal(Encoding::UTF_8, "".encoding)
end

def test_read_utf8
contents = File.read('test/fixtures/encoding/utf-8.txt')
assert_equal(contents.encoding, Encoding::UTF_8)
assert_equal(contents, "\u2705\n")
contents = File.read("test/fixtures/encoding/utf-8.txt")

assert_equal(Encoding::UTF_8, contents.encoding)
assert_equal("\u2705\n", contents)
end
end

0 comments on commit 1575407

Please sign in to comment.