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

v 0.7.4 ChildProcess on Windows requires "cmd.exe /c" #283

Closed
weedySeaDragon opened this issue Jul 14, 2015 · 5 comments · Fixed by #302
Closed

v 0.7.4 ChildProcess on Windows requires "cmd.exe /c" #283

weedySeaDragon opened this issue Jul 14, 2015 · 5 comments · Fixed by #302
Labels

Comments

@weedySeaDragon
Copy link
Contributor

Using version 0.7.4 on Windows, in run! Child.Process.build(....) fails with a ChildeProcess LaunchError. Here's a simple example running a cucumber scenario that uses aruba to call "rake spec"
Here's the cucumber scenario:

Feature: Newly created rails gem is A-OK

  A rails gem that has just been created by the bundler should pass basic spec tests

  @announce
  @rail_gem
  Scenario: A newly created gem passes all spec tests
    Given the empty file named "test.tmp"
    When I run `rake spec`
    Then the output should contain "0 failures"

and here's the error that happens when running it:

> bundle exec rake cucumber

Feature: Newly created rails gem is A-OK

  A rails gem that has just been created by the bundler should pass basic spec tests

  @announce @rail_gem
  Scenario: A newly created gem passes all spec tests # features\generator_new_gem.feature:7
    Given the empty file named "test.tmp"             # aruba-0.7.4/lib/aruba/cucumber.rb:47
$ cd C:/Users/ashley/RubymineProjects/ammeter
$ rake spec
    When I run `rake spec`                            # aruba-0.7.4/lib/aruba/cucumber.rb:119
      The system cannot find the file specified. (error #2 -(size  44) (Aruba::LaunchError)
      features\generator_new_gem.feature:9:in `When I run `rake spec`'
    Then the output should contain "0 failures"       # aruba-0.7.4/lib/aruba/cucumber.rb:166

Failing Scenarios:
cucumber features\generator_new_gem.feature:7 # Scenario: A newly created gem passes all spec tests

1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)
0m0.047s

Per enkessler/childprocess#59, on Windows, ChildProcess requires you to start any shell commands with "cmd.exe /c". The following code works for me:

def run!
        @process = ChildProcess.build(*Shellwords.split(@cmd))

        # Windows needs to prepend commands with 'cmd.exe /c' @see from https://github.com/jarib/childprocess/issues/59
        @process = ChildProcess.build(*(Shellwords.split(@cmd).unshift("cmd.exe", "/c"))) if ChildProcess.windows?

Would you like a PR for this?

@ghost
Copy link

ghost commented Jul 15, 2015

Mmh... I would to prefer to have a separate Launcher for this. Something like that.

class PosixSpawnProcess < SpawnProcess
  def self.match?(check)
    true
  end
end

class WindowsSpawnProcess < SpawnProcess
  def self.match?(check)
  :spawn == check && ChildProcess.windows?
  end

  def run!
  end
end

@ghost ghost added the feature label Jul 15, 2015
@mattwynne
Copy link
Member

Thanks @weedySeaDragon - a PR would be great. And using @dg-ratiodata's suggestion of polymorphic process spawners sounds like the best approach.

@weedySeaDragon
Copy link
Contributor Author

OK. I'll start working on a PR using that approach. Thanks for the quick responses, @mattwynne and @dg-ratiodata .

@maxmeyer
Copy link
Member

Thanks a lot.

@maxmeyer
Copy link
Member

maxmeyer commented Aug 8, 2015

I added *CommandString which is platform-dependent in #302. So SpawnProcess can be used on both platforms and the CommandString is only different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants