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

Bugfix/windows bin #195

Merged
merged 5 commits into from
Nov 4, 2015
Merged

Bugfix/windows bin #195

merged 5 commits into from
Nov 4, 2015

Conversation

colinodell
Copy link
Member

Fixes #189

Due to limitations of PHP, it's impossible to read from STDIN without blocking.
If STDIN is empty, no help will be shown - it'll just hang on us.
@colinodell
Copy link
Member Author

Of course I just realized the stdin tests are going to fail on Windows. Let me see how I can best disable those.

@colinodell
Copy link
Member Author

Alright, that test should be skipped now :)

@garethellis36
Copy link

It no longer hangs when you run it with no STDIN (or with any STDIN for that matter). However...

Tests are failing still. A little debugging suggests it's because of this method below - there is no actual .bat file in the bin folder so it's returning false.

    protected function getPathToCommonmark()
    {
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            return realpath(__DIR__ . '/../../bin/commonmark.bat');
        }

        return realpath(__DIR__ . '/../../bin/commonmark');
    }

@colinodell
Copy link
Member Author

Hmm... according to the Composer documentation, a corresponding .bat file should have been created: https://getcomposer.org/doc/articles/vendor-binaries.md#what-about-windows-and-bat-files-

@garethellis36
Copy link

My understanding of that documentation is that composer would only create the .bat file if I install the package as a dependency in another project, not if I'm running composer install in the package itself.

I'll just test that theory now...

@garethellis36
Copy link

Confimed:

C:\inetpub\test>composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing league/commonmark (dev-bugfix/windows-bin 4af8bfa)
    Cloning 4af8bfaacd198f008fc3954e368a09f2849c1298

Writing lock file
Generating autoload files

C:\inetpub\test>ls
composer.json  composer.lock  vendor

C:\inetpub\test>cd vendor/bin

C:\inetpub\test\vendor\bin>ls
commonmark  commonmark.bat

If you change the getPathToCommonmark() method so that on Windows it returns "php " . realpath(__DIR__ . '/../../bin/commonmark');, this does mean that the bin test can run the script, but two tests in BinTest.php still fail:

1) League\CommonMark\Tests\Functional\BinTest::testNoArgsOrStdin
Failed asserting that 'Failed without error message: php C:\inetpub\commonmark\bin\commonmark' contains "Usage:".

C:\inetpub\commonmark\tests\functional\BinTest.php:19

2) League\CommonMark\Tests\Functional\BinTest::testUnknownOption
Failed asserting that 'Failed without error message: php C:\inetpub\commonmark\bin\commonmark --foo' contains "Unknown option".

C:\inetpub\commonmark\tests\functional\BinTest.php:58

This appears to be because the Command object is getting nothing back from stdout or stderr so the expected error message isn't present. I suspect these tests may have to be skipped on Windows as well.

Some tests in EmphasisTest also fail, but if you update the getPathToCommonmark() method here to match the BinTest version, the tests pass.

@colinodell
Copy link
Member Author

@garethellis36 Thank you for the detailed feedback! I have corrected the remaining issues and also added automated Windows testing via AppVeyor to ensure everything works properly.

colinodell added a commit that referenced this pull request Nov 4, 2015
Fix Windows binary bug and failing tests
@colinodell colinodell merged commit a991363 into master Nov 4, 2015
@colinodell colinodell deleted the bugfix/windows-bin branch November 4, 2015 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback wanted We need your input!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants