KEMBAR78
Windows support path canonicalize by DDtKey · Pull Request #213 · dotenv-linter/dotenv-linter · GitHub
Skip to content

Conversation

@DDtKey
Copy link
Member

@DDtKey DDtKey commented Jun 12, 2020

To solve the problem with the UNC prefix on Win, I added dunce deps (it is very lightweight).
This elegantly solves our problem at the moment 👍

Windows output

new_out_win

PS D:\workdir\dotenv-linter-win-x64> ./dotenv-linter ../test
..\test\incorrect.env:1 LeadingCharacter: Invalid leading character detected
..\test\incorrect.env:2 KeyWithoutValue: The RAILS_ENV key should be with a value or have an equal sign
..\test\incorrect.env:3 IncorrectDelimiter: The DB-NAME key has incorrect delimiter
..\test\incorrect.env:3 UnorderedKey: The DB-NAME key should go before the LOGGER_LEVEL key
..\test\incorrect.env:4 LowercaseKey: The DEbUG_hTTP key should be in uppercase
..\test\incorrect.env:4 UnorderedKey: The DEbUG_hTTP key should go before the LOGGER_LEVEL key
..\test\incorrect.env:6 ExtraBlankLine: Extra blank line detected
..\test\incorrect.env:7 UnorderedKey: The DB_NAME key should go before the DEbUG_hTTP key
PS D:\workdir\dotenv-linter-win-x64> ./dotenv-linter ..\test\correct.env
PS D:\workdir\dotenv-linter-win-x64> ./dotenv-linter ..\test\incorrect.env
..\test\incorrect.env:1 LeadingCharacter: Invalid leading character detected
..\test\incorrect.env:2 KeyWithoutValue: The RAILS_ENV key should be with a value or have an equal sign
..\test\incorrect.env:3 IncorrectDelimiter: The DB-NAME key has incorrect delimiter
..\test\incorrect.env:3 UnorderedKey: The DB-NAME key should go before the LOGGER_LEVEL key
..\test\incorrect.env:4 LowercaseKey: The DEbUG_hTTP key should be in uppercase
..\test\incorrect.env:4 UnorderedKey: The DEbUG_hTTP key should go before the LOGGER_LEVEL key
..\test\incorrect.env:6 ExtraBlankLine: Extra blank line detected
..\test\incorrect.env:7 UnorderedKey: The DB_NAME key should go before the DEbUG_hTTP key

I also had to fix several integration tests so that the file separator was not tied to the platform.
Now, all tests passed and output looks good.

Windows tests results

As file:
test-win.txt

As text
D:\projects\dotenv-linter>cargo test
   Compiling dotenv-linter v1.2.0 (D:\projects\dotenv-linter)
    Finished test [unoptimized + debuginfo] target(s) in 0.87s
     Running target\debug\deps\dotenv_linter-2e142e803f25891e.exe

running 84 tests
test checks::duplicated_key::tests::with_two_unique_keys_test ... ok
test checks::duplicated_key::tests::one_duplicated_and_one_unique_key_test ... ok
test checks::duplicated_key::tests::with_two_duplicated_keys_test ... ok
test checks::duplicated_key::tests::with_one_duplicated_key_test ... ok
test checks::ending_blank_line::tests::blank_line_rn ... ok
test checks::ending_blank_line::tests::no_blank_line ... ok
test checks::ending_blank_line::tests::blank_line ... ok
test checks::extra_blank_line::tests::no_blank_lines ... ok
test checks::extra_blank_line::tests::single_blank_line ... ok
test checks::extra_blank_line::tests::three_blank_lines ... ok
test checks::extra_blank_line::tests::two_blank_lines ... ok
test checks::incorrect_delimiter::tests::empty_run ... ok
test checks::incorrect_delimiter::tests::failing_run ... ok
test checks::incorrect_delimiter::tests::failing_with_whitespace_run ... ok
test checks::incorrect_delimiter::tests::leading_space_run ... ok
test checks::incorrect_delimiter::tests::short_run ... ok
test checks::incorrect_delimiter::tests::trailing_space_run ... ok
test checks::incorrect_delimiter::tests::unformatted_run ... ok
test checks::incorrect_delimiter::tests::working_run ... ok
test checks::incorrect_delimiter::tests::working_with_digits_run ... ok
test checks::key_without_value::tests::failing_run ... ok
test checks::key_without_value::tests::working_run_with_blank_line ... ok
test checks::key_without_value::tests::working_run_with_value ... ok
test checks::key_without_value::tests::working_run_without_value ... ok
test checks::leading_character::tests::blank_line ... ok
test checks::leading_character::tests::leading_asterisk ... ok
test checks::leading_character::tests::leading_dot ... ok
test checks::leading_character::tests::leading_number ... ok
test checks::leading_character::tests::leading_space ... ok
test checks::leading_character::tests::leading_tab ... ok
test checks::leading_character::tests::leading_underscore ... ok
test checks::leading_character::tests::normal ... ok
test checks::leading_character::tests::two_leading_spaces ... ok
test checks::lowercase_key::tests::failing_run_with_lowercase_key ... ok
test checks::lowercase_key::tests::failing_run_with_lowercase_letter ... ok
test checks::lowercase_key::tests::working_run ... ok
test checks::quote_character::tests::with_double_quote_test ... ok
test checks::quote_character::tests::with_no_quotes_test ... ok
test checks::quote_character::tests::with_single_quote_test ... ok
test checks::space_character::tests::failing_run ... ok
test checks::space_character::tests::failing_when_whitespace_after_equal_sign_run ... ok
test checks::space_character::tests::failing_when_whitespace_before_equal_sign_run ... ok
test checks::space_character::tests::working_empty_run ... ok
test checks::space_character::tests::working_leading_run ... ok
test checks::space_character::tests::working_no_equal_sign_run ... ok
test checks::space_character::tests::working_run ... ok
test checks::space_character::tests::working_trailing_run ... ok
test checks::tests::check_name_list ... ok
test checks::tests::run_with_comment_line_test ... ok
test checks::tests::run_with_empty_line_test ... ok
test checks::tests::run_with_empty_vec_test ... ok
test checks::tests::run_with_invalid_line_test ... ok
test checks::tests::run_with_valid_line_test ... ok
test checks::tests::run_without_blank_line_test ... ok
test checks::tests::skip_all_checks ... ok
test checks::tests::skip_one_check ... ok
test checks::trailing_whitespace::tests::failing_trailing_run ... ok
test checks::trailing_whitespace::tests::working_run ... ok
test checks::unordered_key::tests::one_key_test ... ok
test checks::unordered_key::tests::one_unordered_key_test ... ok
test checks::unordered_key::tests::two_ordered_and_two_unordered_keys_test ... ok
test checks::unordered_key::tests::two_ordered_keys_test ... ok
test checks::unordered_key::tests::two_unordered_keys_before_and_after_test ... ok
test checks::unordered_key::tests::two_unordered_keys_before_test ... ok
test common::tests::file_entry::from::path_without_file_test ... ok
test common::tests::file_entry::from::path_with_file_test ... ok
test common::tests::file_entry::is_env_file_test ... ok
test common::tests::line_entry::get_key::correct_line_test ... ok
test common::tests::line_entry::get_key::empty_line_test ... ok
test common::tests::line_entry::get_key::line_without_value_test ... ok
test common::tests::line_entry::get_key::missing_value_and_equal_sign_test ... ok
test common::tests::line_entry::get_value::correct_line_test ... ok
test common::tests::line_entry::get_value::empty_line_test ... ok
test common::tests::line_entry::get_value::line_without_key_test ... ok
test common::tests::line_entry::get_value::line_without_value_test ... ok
test common::tests::line_entry::get_value::missing_value_and_equal_sign_test ... ok
test common::tests::line_entry::is_empty_or_comment::run_with_comment_line_test ... ok
test common::tests::line_entry::is_empty_or_comment::run_with_empty_line_test ... ok
test common::tests::line_entry::is_empty_or_comment::run_with_not_comment_or_empty_line_test ... ok
test common::tests::line_entry::trimmed_string::line_with_spaces_test ... ok
test common::tests::line_entry::trimmed_string::line_with_tab_test ... ok
test common::tests::line_entry::trimmed_string::line_without_blank_chars_test ... ok
test common::tests::warning_fmt_test ... ok
test fs_utils::tests::test_relative_path ... ok

test result: ok. 84 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\dotenv_linter-1f89931db1a4e2a3.exe

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\cli_basic-2124f9951beebd2f.exe

running 3 tests
test checks_current_dir ... ok
test exits_with_0_on_no_errors ... ok
test checks_current_dir_with_dot_arg ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\cli_exclude-e62b562e22ea331c.exe

running 3 tests
test exclude_one_file ... ok
test exclude_two_files ... ok
test exclude_one_file_check_one_file ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\cli_specific-64d956c050ca0f0d.exe

running 6 tests
test checks_one_specific_file_twice ... ok
test checks_one_specific_file ... ok
test checks_one_specific_path ... ok
test checks_one_specific_file_and_one_path ... ok
test checks_two_specific_files ... ok
test checks_two_specific_paths ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\ending_blank_line-a7ea2cecf43146a3.exe

running 2 tests
test correct_files ... ok
test incorrect_files ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target\debug\deps\extra_blank_line-b673247075673a6c.exe

running 4 tests
test two_blank_lines_at_the_end ... ok
test two_blank_lines_at_the_beginning ... ok
test two_blank_lines_in_the_middle ... ok
test correct_files ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests dotenv-linter

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

For UNIX it's also good works. All tests passed and seems correct.

✔ Checklist:

  • This PR has been added to CHANGELOG.md (at the top of the list);
  • Tests for the changes have been added (for bug fixes / features);
  • Docs have been added / updated (for bug fixes / features).

Copy link
Member

@mgrachev mgrachev left a comment

Choose a reason for hiding this comment

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

@DDtKey Thanks a lot! 🔥

I have left some comments. Please, look at them.

@codecov-commenter
Copy link

codecov-commenter commented Jun 15, 2020

Codecov Report

Merging #213 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #213      +/-   ##
==========================================
+ Coverage   96.56%   96.59%   +0.02%     
==========================================
  Files          15       16       +1     
  Lines        1457     1469      +12     
==========================================
+ Hits         1407     1419      +12     
  Misses         50       50              
Impacted Files Coverage Δ
src/fs_utils.rs 100.00% <100.00%> (ø)
src/lib.rs 86.76% <100.00%> (-3.56%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5dc8d05...46b8a2b. Read the comment docs.

@DDtKey DDtKey requested a review from mgrachev June 15, 2020 09:34
mgrachev
mgrachev previously approved these changes Jun 17, 2020
Copy link
Member

@mgrachev mgrachev left a comment

Choose a reason for hiding this comment

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

@DDtKey 🔥 Great job! Thank you! 🙏

Everything is fine, but before merging this PR I'd like to ensure that all tests for Windows pass.
So I'll merge this PR after we add additional steps to build and run tests on Windows.

@mgrachev mgrachev added the wait Wait for something label Jun 17, 2020
@DDtKey
Copy link
Member Author

DDtKey commented Jun 17, 2020

@DDtKey fire Great job! Thank you! pray

Everything is fine, but before merging this PR I'd like to ensure that all tests for Windows pass.
So I'll merge this PR after we add additional steps to build and run tests on Windows.

Yes, I agree, we need to add CI step ☺️
Thank you very much for your help and comments, I am glad to participate in this! 🚀

… into win-cannonicalize

� Conflicts:
�	CHANGELOG.md
@DDtKey
Copy link
Member Author

DDtKey commented Jun 17, 2020

Hmm, it seems we have new issue

It appears that std::process::Command::current_dir does not work as expected in this case (for test_command_*)

I will try to find a solution, a little later

@DDtKey
Copy link
Member Author

DDtKey commented Jun 17, 2020

@mgrachev It was necessary to use canonicalization of paths, in the case of github actions, it looks very much like a symbolic link was used and current_dir was not working correctly.
There is a issue around this

@mgrachev mgrachev merged commit de1012c into dotenv-linter:master Jun 18, 2020
@mgrachev
Copy link
Member

Thanks a lot! You're awesome! ❤️

This was referenced Jun 18, 2020
@DDtKey DDtKey deleted the win-cannonicalize branch June 22, 2020 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wait Wait for something

Development

Successfully merging this pull request may close these issues.

3 participants