Skip to content

Conversation

@aidanharan
Copy link
Contributor

@aidanharan aidanharan commented Apr 28, 2021

Coercing tests on Windows that rely on SchemaCache#dump_to. The call in https://github.com/rails/rails/blob/e2781c2d93808031fbc4dbecaa7aac59aa90b4b8/activesupport/lib/active_support/core_ext/file/atomic.rb#L50 to rename the file fails on Windows. This is a Rails/Windows issue.

MacOS

> tempfile = Tempfile.new('test.txt')
=> #<File:/var/folders/mp/_9w8583s18z93h_w2s7zxq24ks97j0/T/test.txt20210429-16257-39oo5i>
> File.atomic_write(tempfile.path) { |file| file.write('BLAH') }
=> 4

Windows

> tempfile = Tempfile.new('test.txt')
=> #<Tempfile:C:/Users/user/AppData/Local/Temp/test.txt20210429-8740-1pwkymo>
> File.atomic_write(tempfile.path) { |file| file.write('BLAH') }
*** Errno::EACCES Exception: Permission denied @ rb_file_s_rename - (C:/Users/user/AppData/Local/Temp/.test.txt20210429-8740-1pwkymo20210429-8740-yjlmty, C:/Users/user/AppData/Local/Temp/test.txt20210429-8740-1pwkymo)

An example of exception raised is (https://ci.appveyor.com/project/wpolicarpo/activerecord-sqlserver-adapter/builds/38929321#L397):

ActiveRecord::ConnectionAdapters::SchemaCacheTest#test_marshal_dump_and_load_with_gzip_coerced:
Errno::EACCES: Permission denied @ rb_file_s_rename - (C:/Users/appveyor/AppData/Local/Temp/1/.schema_cache-20210429-3648-11o6yfo.dump.gz20210429-3648-4s5ga8, C:/Users/appveyor/AppData/Local/Temp/1/schema_cache-20210429-3648-11o6yfo.dump.gz)
    rails (8b63ea762239) activesupport/lib/active_support/core_ext/file/atomic.rb:50:in `rename'
    rails (8b63ea762239) activesupport/lib/active_support/core_ext/file/atomic.rb:50:in `block in atomic_write'
    C:/Ruby26-x64/lib/ruby/2.6.0/tempfile.rb:295:in `open'
    rails (8b63ea762239) activesupport/lib/active_support/core_ext/file/atomic.rb:24:in `atomic_write'
    rails (8b63ea762239) activerecord/lib/active_record/connection_adapters/schema_cache.rb:211:in `open'
    rails (8b63ea762239) activerecord/lib/active_record/connection_adapters/schema_cache.rb:158:in `dump_to'

Also in this PR, no longer need to coerce the DatabaseTasksDumpSchemaCacheTest#test_dump_schema_cache test as it has been updated on the Rails test suite and will now work on Windows.

@aidanharan aidanharan force-pushed the windows-ci-file-permissions branch 3 times, most recently from 7c01721 to a14eec4 Compare April 29, 2021 10:37
@aidanharan aidanharan force-pushed the windows-ci-file-permissions branch from 14969c6 to e5a0118 Compare April 29, 2021 12:41
@aidanharan aidanharan marked this pull request as ready for review April 29, 2021 13:09
@aidanharan aidanharan marked this pull request as draft April 29, 2021 16:16
@aidanharan aidanharan changed the title Rails 6.1: Skip tests on Windows because of AppVeyor CI permissions issue Rails 6.1: Skip tests on Windows because file rename issue Apr 29, 2021
@aidanharan aidanharan changed the title Rails 6.1: Skip tests on Windows because file rename issue Rails 6.1: Skip tests on Windows because of file rename issue Apr 29, 2021
@aidanharan aidanharan changed the title Rails 6.1: Skip tests on Windows because of file rename issue Rails 6.1: Skip tests on Windows atomic write issue Apr 29, 2021
@aidanharan aidanharan changed the title Rails 6.1: Skip tests on Windows atomic write issue Rails 6.1: Skip tests on Windows because of atomic write issue Apr 29, 2021
@aidanharan aidanharan marked this pull request as ready for review April 29, 2021 18:53
@wpolicarpo wpolicarpo merged commit 84b35be into rails-sqlserver:main May 4, 2021
lavika pushed a commit to lavika/activerecord-sqlserver-adapter that referenced this pull request Sep 26, 2023
…rmissions issue (rails-sqlserver#920)

Co-authored-by: Aidan Haran <aharan@fusioneer.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants