-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Conversation
adding a pipe character ('|') preserves the formatting of 'expected_output' with a trailing newline bit, in windows.
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"] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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..
b2bf987
to
2ef891a
Compare
There was a problem hiding this 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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.
2ef891a
to
901df5b
Compare
Because |
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
279882a
to
2c68069
Compare
e9a7909
to
e05fd81
Compare
|
This is looking excellent! |
There was a problem hiding this 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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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..
e05fd81
to
1bafbd9
Compare
@jekyllbot: merge +dev |
TestGeneratedSite
TestFilters
TestSite
(only partially)--
ref: #5241
/cc @jekyll/windows