jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

Ruby 3.x support #140

Open bensandland opened 2 months ago

bensandland commented 2 months ago

I have been working on adding functionality to build the gem for the mingw-ucrt platform. In order to do that I have modified the Rakefile, made a "compile" task and modified the previously defined "build" task.

The build task will iterate through the supported platforms, build the externals (if .dll is missing) and then move the DLLs from eg 'x86Release' -> 'Release' and then the gem is built.

This results in 4 .gem files in the pkg directory, x86/x64-mingw + x86/x64-mingw-ucrt. These changes also means that the compilation and moving of files is all handled in the Rakefile, and the .gemspec only notifies for any missing DLLs. This does however mean that building the Gem is best done through the Rakefile, since running "gem build rautomation" will assume the DLLs are compiled and placed within their respective "Release" folder.

To compile and build the .gem files use rake task build or install

Regarding the change from notepad to regedit in the specs I changed this because I was no longer able to interact with notepad on Windows 11. It seems like the UWP apps are containerized in some way and automating these has to be done with a different API

Apologies for the messy commit. I ended up doing too many things at once after parking the task for a bit. Let me know if you have any questions or suggestions regarding this update.

jarmo commented 1 month ago

@bensandland huge thanks for your continued contribution and effort!

I had a first quick look by just reading the changes. Will have a more thorough look at one point, but will not promise anything specific.

My first question - previously this gem was released by rake release, which compiled every necessary dependency, ran all specs and then pushed gems to Rubygems. What command should now be used to have similar process? Reading the Rakefile changes and your comment I have a suspicion that rake release does not do that anymore.

bensandland commented 1 month ago

@bensandland huge thanks for your continued contribution and effort!

I had a first quick look by just reading the changes. Will have a more thorough look at one point, but will not promise anything specific.

My first question - previously this gem was released by rake release, which compiled every necessary dependency, ran all specs and then pushed gems to Rubygems. What command should now be used to have similar process? Reading the Rakefile changes and your comment I have a suspicion that rake release does not do that anymore.

Should be able to do that again. The Bundler::GemHelper.install_tasks call adds the build, install and release tasks.

jarmo commented 2 days ago

Sorry for taking so long to look at this in more detail.

I managed to run specs using Ruby 3, but after these changes it's not possible to run specs on 32bit Ruby anymore, which are passing without these changes (I was using ruby 2.6.5p114 (2019-10-01 revision 67812) [i386-mingw32]).

Here's what I see when trying to run bundle exec rake spec:all:

Running specs for adapter: win_32
C:/Ruby26-x86/bin/ruby.exe -I'C:/Ruby26-x86/lib/ruby/gems/2.6.0/gems/rspec-core-3.11.0/lib';'C:/Ruby26-x86/lib/ruby/gems/2.6.0/gems/rspec-support-3.11.0/lib' 'C:/Ruby26-x86/lib/ruby/gems/2.6.0/gems/rspec-core-3.11.0/exe/rspec' --pattern 'spec/**{,/*/**}/*_spec.rb'

An error occurred while loading ./spec/adapter/ms_uia/control_spec.rb. - Did you mean?
                    rspec ./spec/adapter/ms_uia/value_control_spec.rb
                    rspec ./spec/adapter/ms_uia/tab_control_spec.rb
                    rspec ./spec/adapter/ms_uia/table_spec.rb

Failure/Error: ffi_lib 'user32', 'kernel32', 'ole32', File.dirname(__FILE__) + '/../../../../ext/IAccessibleDLL/Release/iaccessibleDll.dll'

LoadError:
  Could not open library 'C:/RAutomation/lib/rautomation/adapter/ms_uia/../../../../ext/IAccessibleDLL/Release/iaccessibleDll.dll': ?[♀?♦
# ./lib/rautomation/adapter/ms_uia/functions.rb:11:in `<module:Functions>'
# ./lib/rautomation/adapter/ms_uia/functions.rb:8:in `<module:MsUia>'
# ./lib/rautomation/adapter/ms_uia/functions.rb:6:in `<module:Adapter>'
# ./lib/rautomation/adapter/ms_uia/functions.rb:5:in `<module:RAutomation>'
# ./lib/rautomation/adapter/ms_uia/functions.rb:4:in `<top (required)>'
# ./lib/rautomation/adapter/ms_uia.rb:10:in `require'
# ./lib/rautomation/adapter/ms_uia.rb:10:in `<top (required)>'
# ./spec/adapter/ms_uia/control_spec.rb:45:in `require'
# ./spec/adapter/ms_uia/control_spec.rb:45:in `block in <top (required)>'
# ./spec/adapter/ms_uia/control_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/adapter/ms_uia/spinner_spec.rb.
Failure/Error:
  describe MsUia::Spinner, if: SpecHelper.adapter == :ms_uia  do
    let(:main_window) { RAutomation::Window.new(title: 'MainFormWindow') }
    let(:data_entry) { main_window.button(value: 'Data Entry Form').click { window.exist? } }
    let(:window) { RAutomation::Window.new(title: 'DataEntryForm') }

    subject { window.spinner(id: 'numericUpDown1') }

    before(:each) do
      data_entry
    end

NameError:
  uninitialized constant RAutomation::Adapter::MsUia::Spinner
# ./spec/adapter/ms_uia/spinner_spec.rb:5:in `<top (required)>'

An error occurred while loading ./spec/adapter/ms_uia/tab_control_spec.rb.
Failure/Error:
  describe MsUia::TabControl, if: SpecHelper.adapter == :ms_uia do
    let(:window) { RAutomation::Window.new(title: 'MainFormWindow') }
    let(:about) { RAutomation::Window.new(title: 'About') }
    subject { about.tab_control(id: 'tabControl') }

    before(:each) do
      window.button(value: 'About').click { true }
    end

    it { should exist }

NameError:
  uninitialized constant RAutomation::Adapter::MsUia::TabControl
# ./spec/adapter/ms_uia/tab_control_spec.rb:5:in `<top (required)>'

Finished in 0.00003 seconds (files took 0.52163 seconds to load)
0 examples, 0 failures, 3 errors occurred outside of examples

C:/Ruby26-x86/bin/ruby.exe -I'C:/Ruby26-x86/lib/ruby/gems/2.6.0/gems/rspec-core-3.11.0/lib';'C:/Ruby26-x86/lib/ruby/gems/2.6.0/gems/rspec-support-3.11.0/lib' 'C:/Ruby26-x86/lib/ruby/gems/2.6.0/gems/rspec-core-3.11.0/exe/rspec' --pattern 'spec/**{,/*/**}/*_spec.rb' failed