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

Fix tests to get script/test to pass on Windows #5526

Merged
merged 6 commits into from
Nov 10, 2016

Conversation

ashmaroli
Copy link
Member

@ashmaroli ashmaroli commented Nov 2, 2016

  • Fix TestGeneratedSite
  • Fix TestFilters
  • Fix TestSite (only partially)
  • Add new helper method to skip testing symlinks on Windows

--

ref: #5241
/cc @jekyll/windows

adding a pipe character ('|') preserves the formatting of
'expected_output' with a trailing newline bit, in windows.
@ashmaroli
Copy link
Member Author

This PR is a refined version of the referenced pull.

@@ -14,14 +14,20 @@ class TestSite < JekyllUnitTest

should "have an array for plugins if passed as a string" do
site = Site.new(site_configuration({ "plugins_dir" => "/tmp/plugins" }))
assert_equal ["/tmp/plugins"], site.plugins
array = Utils::Platforms.really_windows? ? ["C:/tmp/plugins"] : ["/tmp/plugins"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why hardcode this? You should just use the environment variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

just use the environment variable

please explain more.

Copy link
Contributor

Choose a reason for hiding this comment

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

C:\Users\XhmikosR\Desktop>echo %TEMP%
C:\Users\XhmikosR\AppData\Local\Temp

C:\Users\XhmikosR\Desktop>echo %TMP%
C:\Users\XhmikosR\AppData\Local\Temp

So, just use the environment variable, any of those two.

Copy link
Member Author

Choose a reason for hiding this comment

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

the path is not important here actually. This step and the next is to simply test if plugins are correctly detected as specified.
e.g. if were to set plugins_dir => "/apps/bazinga", the array returned would be:

["C:/apps/bazinga"] # on Windows and AppVeyor CI
["/apps/bazinga"] # on Unixoids and Travis CI

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just saying, it's bad practice hardcoding paths. Especially when you can use something a lot more reliable to detect the path.

Copy link
Member Author

Choose a reason for hiding this comment

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

the more I think about this, I wonder if this is a bug or intended..
when I set, plugins_dir => "/apps/plugins"
I should get a relative path to plugins dir inside my site, or an absolute_path to plugins dir with my site.

Copy link
Member Author

@ashmaroli ashmaroli Nov 2, 2016

Choose a reason for hiding this comment

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

update: it works as expected, if the leading / is avoided..
set plugins_dir => "apps/bazinga"
then I get site.plugins == [C:/~/apps/bazinga]

Copy link
Member Author

Choose a reason for hiding this comment

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

moving this segment to a dedicated issue ticket..

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

Cool, looking good! Thanks for this.

Out of curiosity, why are we using really_windows? instead of just windows?


def skip_if_windows(msg = nil)
if Utils::Platforms.really_windows?
msg ||= "Jekyll doesn't currently support Symlinks on Windows"
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a strange default. Is this only used in symlinks-related code? If not, I'd suggest something like Jekyll does not currently support this feature on Windows.

@@ -186,6 +186,9 @@ class TestCollections < JekyllUnitTest
end

should "include the symlinked file from site.source in the list of docs" do
# no support for including symlinked file on Windows
skip_if_windows
Copy link
Member

Choose a reason for hiding this comment

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

Then here I'd be specific with my message and say skip_if_windows, "Jekyll does not currently support symlinsk on Windows.".

@@ -82,6 +82,9 @@ class TestEntryFilter < JekyllUnitTest

# rubocop:disable Performance/FixedSize
should "include only safe symlinks in safe mode" do
# no support for symlinks on Windows
skip_if_windows
Copy link
Member

Choose a reason for hiding this comment

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

Same here and everywhere you use this method – make that comment the message instead of a comment so when I run the tests, this information is surfaced.

| - /css/screen.css last edited at #{time_regexp} with extname .css
- /pgp.key last edited at #{time_regexp} with extname .key
- /products.yml last edited at #{time_regexp} with extname .yml
- /symlink-test/symlinked-dir/screen.css last edited at #{time_regexp} with extname .css
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? Can you paste the test failure in a comment below?

Copy link
Member Author

Choose a reason for hiding this comment

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

@parkr 👇

Failure:
TestGeneratedSite#test_: generated sites should print a nice list of static files.  [C:/projects/jekyll/test/test_generated_site.rb:59]
Minitest::Assertion: Expected /- \/css\/screen.css last edited at \d+:\d+ with extname .css
- \/pgp.key last edited at \d+:\d+ with extname .key
- \/products.yml last edited at \d+:\d+ with extname .yml
- \/symlink-test\/symlinked-dir\/screen.css last edited at \d+:\d+ with extname .css
/ to match "\n- /css/screen.css last edited at 23:11 with extname .css\n- /pgp.key last edited at 23:11 with extname .key\n- /products.yml last edited at 23:11 with extname .yml\n- /symlink-test/symlinked-dir last edited at 23:11 with extname \n- /symlink-test/symlinked-file last edited at 23:11 with extname \n".

@@ -175,7 +175,6 @@ def generate(site)
method.call(*args, &block).reverse
end
@site.process
# files in symlinked directories may appear twice
Copy link
Member

Choose a reason for hiding this comment

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

Maybe say here than symlinked directories are excluded from this list and added in when not Windows.

@parkr parkr added windows Related to the Windows platform tests labels Nov 2, 2016
add symlinked files to "sorted_pages" array only when testing on
non-windows platforms.
Adjust the size of grouped-items array as it won't include symlinked
pages in Windows.
@ashmaroli
Copy link
Member Author

Out of curiosity, why are we using really_windows? instead of just windows?

Because ::Platforms.really_windows? is more strict than ::Platforms.windows?

@parkr
Copy link
Member

parkr commented Nov 2, 2016

Because ::Platforms.really_windows? is more strict than ::Platforms.windows?

Why do we want it to be more strict?

@ashmaroli
Copy link
Member Author

Why do we want it to be more strict?

😃 Because currently, symlinks is known to not have native support in Windows env. But then it may work in Windows subsystem on Linux

  - add a new helper method to skip tests if on Windows platform
  - skip those tests that fail due to lack of support for symlinked files
    on Windows.
The array of plugins will contain current drive-letter in Windows
@ashmaroli
Copy link
Member Author

ashmaroli commented Nov 5, 2016

TODO: Undo Gemfile changes when codeclimate-test-reporter issue is fixed on master

@parkr
Copy link
Member

parkr commented Nov 9, 2016

This is looking excellent!

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

👌

@@ -22,7 +22,7 @@ group :test do
gem "cucumber", "~> 2.1"
gem "jekyll_test_plugin"
gem "jekyll_test_plugin_malicious"
gem "codeclimate-test-reporter"
gem "codeclimate-test-reporter", "0.6.0"
Copy link
Member

Choose a reason for hiding this comment

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

Want to submit a separate PR for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@parkr, if you think, going with "~> 0.6.0" is the better way for now, I shall definitely move this to a dedicated PR. Otherwise, this will remain here to have the tests run correctly..

@parkr parkr changed the title Fix tests to get them to pass on Windows Fix tests to get script/test to pass on Windows Nov 10, 2016
@parkr
Copy link
Member

parkr commented Nov 10, 2016

@jekyllbot: merge +dev

@jekyllbot jekyllbot merged commit 3e1fad2 into jekyll:master Nov 10, 2016
jekyllbot added a commit that referenced this pull request Nov 10, 2016
@ashmaroli ashmaroli deleted the fix-win-tests branch November 11, 2016 03:36
@jekyll jekyll locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants