Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve AppVeyor Build #505

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ jobs:

strategy:
matrix:
ruby: ["3.1", "3.2", "jruby-9.4", "3.3"]
appraisal: [cucumber_8, cucumber_9]
include:
- ruby: "3.0"
appraisal: cucumber_8
ruby: ["3.2"]
appraisal: [cucumber_9]

env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.appraisal }}.gemfile
Expand All @@ -48,7 +45,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["3.0", "3.1", "3.2", "3.3"]
ruby: ["3.2"]

runs-on: macos-latest

Expand All @@ -68,7 +65,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["3.0", "3.1", "3.2", "3.3"]
ruby: ["3.2"]

runs-on: windows-latest

Expand All @@ -83,6 +80,8 @@ jobs:
bundler-cache: true
- name: Run specs
run: bundle exec rake spec
- name: Run cukes
run: bundle exec rake cucumber

checks:

Expand Down
6 changes: 6 additions & 0 deletions fixtures/cli-app/bin/aruba-test-cli.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "./aruba-test-cli" %1 %2 %3 %4 %5%6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
15 changes: 13 additions & 2 deletions spec/aruba/api/commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
include_context "uses aruba API"

describe "#run_command" do
let(:cmd) { 'ruby -ne "puts $_"' }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows doesn't have a command like cat that accepts input via stdin, prints it to stdout and accepts piped input, so this is the best I've come up with but it feels a little hack-y. @mvz, do you happen to know of any better ways to tackle this? Can you see any issues with this implementation? Thanks heaps!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something lets gets.chomp work here. Via an input on stdin? Genuinely not sure, so ignore me if not useful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That almost works, but the process exits immediately afterwards. I can add a loop and trap an interrupt signal, but it's a fair bit more verbose. I've also found it doesn't quite function in the same way that cat does. Thanks heaps for the suggestion, though. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xtrasimplicity I can't remember what the Windows-equivalent command was. type, maybe? I kind of like your change because it's Just Ruby, but it may slow down tests on JRuby. Let's see how this goes for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @mvz. type was almost perfect, from memory, but I don't think it handled SIGINT signals (or the windows equivalent) correctly. I'll keep it as is for the moment and see how it goes. :)


context "when succesfully running a command" do
before { @aruba.run_command "cat" }
before { @aruba.run_command cmd }

after { @aruba.all_commands.each(&:stop) }

Expand All @@ -33,6 +35,15 @@
@aruba.write_file(@file_name, "Hello\nWorld!")
@aruba.pipe_in_file(@file_name)
@aruba.close_input

@aruba.last_command_started.stop
last_command_output = @aruba.last_command_started.output

# Convert \r\n to \n, if present in the output
if last_command_output.include?("\r\n")
allow(@aruba.last_command_started).to receive(:output).and_return(last_command_output.gsub("\r\n", "\n"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to either:

  • make have_output behave properly in this case,
  • provide a special verision of have_output that ignores changes to line endings.
  • or change the expectation below depending on whethere we're on Windows.

I think I prefer the third option for now.

end

expect(@aruba.last_command_started).to have_output "Hello\nWorld!"
end
end
Expand All @@ -47,7 +58,7 @@
end

it "raises an error" do
expect { @aruba.run_command "cat" }.to raise_error NotImplementedError
expect { @aruba.run_command cmd }.to raise_error NotImplementedError
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/aruba/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,23 @@
end

describe "#set_environment_variable" do
let(:get_env_cmd) { FFI::Platform.windows? ? "set" : "env" }

after do
@aruba.all_commands.each(&:stop)
end

it "set environment variable" do
@aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "true"
@aruba.run_command_and_stop "env"
@aruba.run_command_and_stop get_env_cmd
expect(@aruba.last_command_started.output)
.to include("LONG_LONG_ENV_VARIABLE=true")
end

it "overwrites environment variable" do
@aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "true"
@aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "false"
@aruba.run_command_and_stop "env"
@aruba.run_command_and_stop get_env_cmd
expect(@aruba.last_command_started.output)
.to include("LONG_LONG_ENV_VARIABLE=false")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/aruba/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe Aruba::Command do
let(:command) do
described_class.new(
"true",
"exit 0",
event_bus: event_bus,
exit_timeout: exit_timeout,
io_wait_timeout: io_wait_timeout,
Expand Down
8 changes: 4 additions & 4 deletions spec/aruba/matchers/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def announcer(*args)
end

describe "#to_have_exit_status" do
let(:cmd) { "true" }
let(:cmd) { "exit 0" }

before { run_command(cmd) }

Expand All @@ -21,14 +21,14 @@ def announcer(*args)
end

context "when does not have exit 0" do
let(:cmd) { "false" }
let(:cmd) { "exit 1" }

it { expect(last_command_started).not_to have_exit_status 0 }
end
end

describe "#to_be_successfully_executed_" do
let(:cmd) { "true" }
let(:cmd) { "exit 0" }

before { run_command(cmd) }

Expand All @@ -37,7 +37,7 @@ def announcer(*args)
end

context "when does not have exit 0" do
let(:cmd) { "false" }
let(:cmd) { "exit 1" }

it { expect(last_command_started).not_to be_successfully_executed }
end
Expand Down
Loading