Skip to content

Commit

Permalink
[truffleruby] Official Support (#140)
Browse files Browse the repository at this point in the history
* [ci] return truffleruby

* [gem] bump version

* [truffelruby-support] support for actual truffleruby + ignore threadsafety specs (implementation issue)

* [truffelruby-support] codestyle updates

* [truffelruby-support] codestyle updates

* [truffelruby-support] changelog updates
  • Loading branch information
0exp authored Dec 14, 2024
1 parent ec1e13b commit 8d88d37
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 87 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
include:
- ruby: head
experimental: true
- ruby: truffleruby
experimental: true
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
### Added
- Support for `truffleruby`;

## [0.30.0] - 2024-12-14
### Changed
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
qonfig (0.29.1)
qonfig (0.30.0)
base64 (>= 0.2)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/with_external_deps.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
qonfig (0.29.1)
qonfig (0.30.0)
base64 (>= 0.2)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/without_external_deps.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
qonfig (0.29.1)
qonfig (0.30.0)
base64 (>= 0.2)

GEM
Expand Down
138 changes: 70 additions & 68 deletions spec/features/run_code_with_temporary_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,83 +22,85 @@
expect(config.settings.api.login).to eq('D@iVeR')
end

specify 'thread-safety' do
config = Qonfig::DataSet.build do
setting :api do
setting :token, 'test123'
setting :login, 'D@iVeR'
end
unless RUBY_ENGINE.include?('truffleruby')
specify 'thread-safety' do
config = Qonfig::DataSet.build do
setting :api do
setting :token, 'test123'
setting :login, 'D@iVeR'
end

setting :credentials do
setting :user, 'admin'
setting :password, '1234asdf'
setting :credentials do
setting :user, 'admin'
setting :password, '1234asdf'
end
end
end

ThreadGroup.new.tap do |thread_group|
10.times do
thread_group.add(Thread.new do
# NOTE: change settings temporary
config.with(api: { token: '777555' }, credentials: { password: 'test123' }) do
config.settings.credentials.user = 'nimda'
end
end)
ThreadGroup.new.tap do |thread_group|
10.times do
thread_group.add(Thread.new do
# NOTE: change settings temporary
config.with(api: { token: '777555' }, credentials: { password: 'test123' }) do
config.settings.credentials.user = 'nimda'
end
end)

thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)
thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)

thread_group.add(Thread.new do
# NOTE: change settings temporary
config.with do
config.settings.api.login = 'provider'
config.settings.api.token = 'super_puper_123'
end
end)
thread_group.add(Thread.new do
# NOTE: change settings temporary
config.with do
config.settings.api.login = 'provider'
config.settings.api.token = 'super_puper_123'
end
end)

thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)
thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)

thread_group.add(Thread.new do
config.with(api: { login: '0exp' }, credentials: { user: 'D@iVeR' }) do
config.settings.api.token = 'kekpek123'
config.settings.credentials.password = 'admin'
end
end)
thread_group.add(Thread.new do
config.with(api: { login: '0exp' }, credentials: { user: 'D@iVeR' }) do
config.settings.api.token = 'kekpek123'
config.settings.credentials.password = 'admin'
end
end)

thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)
thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)

thread_group.add(Thread.new do
# NOTE: change settings temporary
config.with(api: { login: 'mobile_legends' }, credentials: { user: 'dota2' }) do
config.settings.api.token = 'league_of_legends'
config.settings.credentials.password = 'overwatch'
end
end)
thread_group.add(Thread.new do
# NOTE: change settings temporary
config.with(api: { login: 'mobile_legends' }, credentials: { user: 'dota2' }) do
config.settings.api.token = 'league_of_legends'
config.settings.credentials.password = 'overwatch'
end
end)

thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)
end
end.list.map(&:join)
thread_group.add(Thread.new do
# NOTE: settings are not changed :)
expect(config.settings.credentials.user).to eq('admin')
expect(config.settings.credentials.password).to eq('1234asdf')
expect(config.settings.api.token).to eq('test123')
expect(config.settings.api.login).to eq('D@iVeR')
end)
end
end.list.map(&:join)
end
end
end
54 changes: 38 additions & 16 deletions spec/features/save_to_file/save_to_json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,44 @@
# NOTE: step 2) read saved file
file_data = File.read(config_file_path)

expect(file_data).to eq(<<~JSON.strip)
{
"true_bollean": true,
"false_boolean": false,
"empty_object": {},
"filled_object": {
"a": 1,
"b": null,
"c": true,
"d": "1",
"e": false
},
"null_data": null,
"collection": [ "1", 2, true, false, null, [], {}]
}
JSON
expected_json =
if RUBY_ENGINE.include?('truffleruby')
<<~JSON.strip
{
"true_bollean": true,
"false_boolean": false,
"empty_object": {},
"filled_object": {
"a": 1,
"b": null,
"c": true,
"d": "1",
"e": false
},
"null_data": null,
"collection": ["1",2,true,false,null,[],{}]
}
JSON
else
<<~JSON.strip
{
"true_bollean": true,
"false_boolean": false,
"empty_object": {},
"filled_object": {
"a": 1,
"b": null,
"c": true,
"d": "1",
"e": false
},
"null_data": null,
"collection": [ "1", 2, true, false, null, [], {}]
}
JSON
end

expect(file_data).to eq(expected_json)
end
end

Expand Down

0 comments on commit 8d88d37

Please sign in to comment.