Skip to content

std::tests::test_dirs::test_dirs_command fails on MacOS #8528

Description

@amtoine

Describe the bug

the tests of #8525 do not pass.

according to the investigations of @fdncred in the comments of the PR

This is what's going on.

> assert ($base_path == $env.DIRS_LIST.0) "list is just pwd after initialization"
Error:
  × list is just pwd after initialization
   ╭─[entry #76:1:1]
 1 │ assert ($base_path == $env.DIRS_LIST.0) "list is just pwd after initialization"
   ·        ────────────────┬───────────────
   ·                        ╰── It is not true.
   ╰────
> $base_path
/var/folders/m1/x0gp9jy51s146ttxtz7jlpxh0000gn/T/test_dirs_14f52f6b-23fd-4324-a29e-b7f7f0ca314d
> $env.DIRS_LIST.0
/private/var/folders/m1/x0gp9jy51s146ttxtz7jlpxh0000gn/T/test_dirs_14f52f6b-23fd-4324-a29e-b7f7f0ca314d

/tmp is a symlink

^ls -al /tmp
lrwxr-xr-x 1 root wheel 11 Feb  9 03:39 /tmp -> private/tmp

How to reproduce

  1. have a Mac ( 👀 )
  2. run
let base_path = (($nu.temp-path) | path join $"test_dirs_(random uuid)" | path expand )
mkdir $base_path
cd $base_path

use /path/to/crates/nu-utils/standard_library/std.nu assert
assert (1 == ($env.DIRS_LIST | length))
  1. observe the error

Expected behavior

assert (1 == ($env.DIRS_LIST | length))

should work after any use std.nu ...

Screenshots

No response

Configuration

key value
version 0.77.2
branch main
commit_hash ef7fbf4
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.66.1 (90743e729 2023-01-10)
rust_channel 1.66.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.66.1 (ad779e08b 2023-01-10)
build_time 2023-03-17 17:50:12 +01:00
build_rust_channel release
features default, zip
installed_plugins gstat

Additional context

No response

Activity

  1. added
    tests
    A:std-library
    on Mar 19, 2023
  2. fdncred commented on Mar 19, 2023

    @fdncred
    Contributor

    In this instance, this works

    ($base_path | path expand) == $env.DIRS_LIST.0
    

    So, maybe we should make sure paths go through path expand to ensure they're "right"?

    or better yet, it could probably be fixed with this:

    > $nu.temp-path | path expand
    /private/var/folders/m1/x0gp9jy51s146ttxtz7jlpxh0000gn/T
    

    versus

    > $nu.temp-path
    /var/folders/m1/x0gp9jy51s146ttxtz7jlpxh0000gn/T/
    

    I kind of wonder if that $nu.temp-path (and the other paths in $nu) should go through a path expand before storing them in nushell's $nu?

  3. amtoine commented on Mar 20, 2023

    @amtoine
    MemberAuthor

    I kind of wonder if that $nu.temp-path (and the other paths in $nu) should go through a path expand before storing them in nushell's $nu?

    that might help catch this kind of annoying bug! 😋

  4. amtoine commented on Mar 20, 2023

    @amtoine
    MemberAuthor

    @fdncred i think i get the issue here, let me try to fix it 👌

  5. fdncred commented on Mar 20, 2023

    @fdncred
    Contributor

    the base_path is already expanded 🤔

    ya, i saw that, but it needs it again or it needs to be expanded in the rust code

  6. amtoine commented on Mar 21, 2023

    @amtoine
    MemberAuthor

    ya, i saw that, but it needs it again or it needs to be expanded in the rust code

    i can try to add more path expand and you tell me if that's any better? 🤔

  7. amtoine commented on Mar 21, 2023

    @amtoine
    MemberAuthor

    @fdncred

    can you tell me if that's any better with #8552? 😋

  8. added a commit that references this issue on Mar 22, 2023
    cb1eefd
  9. added this to the v0.78.0 milestone on Mar 22, 2023
  10. fdncred commented on Mar 22, 2023

    @fdncred
    Contributor

    Here are the latest results from MacOS as of this morning after landing #8552.

    NU_LOG_LEVEL=DEBUG nu crates/nu-utils/standard_library/tests.nu 
    INFO  Run tests in test_asserts
    DEBUG Run test test_asserts test_assert
    DEBUG Run test test_asserts test_assert_equal
    DEBUG Run test test_asserts test_assert_error
    DEBUG Run test test_asserts test_assert_greater
    DEBUG Run test test_asserts test_assert_greater_or_equal
    DEBUG Run test test_asserts test_assert_length
    DEBUG Run test test_asserts test_assert_less
    DEBUG Run test test_asserts test_assert_less_or_equal
    DEBUG Run test test_asserts test_assert_not_equal
    INFO  Run tests in test_dirs
    DEBUG Run test test_dirs test_dirs_command
    Error:
      × add changes PWD to first added dir
    
    INFO  Run tests in test_logger
    DEBUG Run test test_logger test_critical
    DEBUG Run test test_logger test_debug
    DEBUG Run test test_logger test_error
    DEBUG Run test test_logger test_info
    DEBUG Run test test_logger test_warning
    INFO  Run tests in test_std
    DEBUG Run test test_std test_match
    DEBUG Run test test_std test_path_add
    

    Here's the test results from Windows

    NU_LOG_LEVEL=DEBUG nu crates/nu-utils/standard_library/tests.nu
    INFO  Run tests in test_asserts
    DEBUG Run test test_asserts test_assert
    DEBUG Run test test_asserts test_assert_equal
    DEBUG Run test test_asserts test_assert_error
    DEBUG Run test test_asserts test_assert_greater
    DEBUG Run test test_asserts test_assert_greater_or_equal
    DEBUG Run test test_asserts test_assert_length
    DEBUG Run test test_asserts test_assert_less
    DEBUG Run test test_asserts test_assert_less_or_equal
    DEBUG Run test test_asserts test_assert_not_equal
    INFO  Run tests in test_dirs
    DEBUG Run test test_dirs test_dirs_command
    INFO  Run tests in test_logger
    DEBUG Run test test_logger test_critical
    DEBUG Run test test_logger test_debug
    DEBUG Run test test_logger test_error
    DEBUG Run test test_logger test_info
    DEBUG Run test test_logger test_warning
    INFO  Run tests in test_std
    DEBUG Run test test_std test_match
    DEBUG Run test test_std test_path_add
    

    And from Ubuntu via WSL

    NU_LOG_LEVEL=DEBUG nu crates/nu-utils/standard_library/tests.nu
    INFO  Run tests in test_asserts
    DEBUG Run test test_asserts test_assert
    DEBUG Run test test_asserts test_assert_equal
    DEBUG Run test test_asserts test_assert_error
    DEBUG Run test test_asserts test_assert_greater
    DEBUG Run test test_asserts test_assert_greater_or_equal
    DEBUG Run test test_asserts test_assert_length
    DEBUG Run test test_asserts test_assert_less
    DEBUG Run test test_asserts test_assert_less_or_equal
    DEBUG Run test test_asserts test_assert_not_equal
    INFO  Run tests in test_dirs
    DEBUG Run test test_dirs test_dirs_command
    INFO  Run tests in test_logger
    DEBUG Run test test_logger test_critical
    DEBUG Run test test_logger test_debug
    DEBUG Run test test_logger test_error
    DEBUG Run test test_logger test_info
    DEBUG Run test test_logger test_warning
    INFO  Run tests in test_std
    DEBUG Run test test_std test_match
    DEBUG Run test test_std test_path_add
    
  11. amtoine commented on Mar 22, 2023

    @amtoine
    MemberAuthor

    mm ok so it looks better but not perfect to me 🤔

  12. amtoine commented on Mar 22, 2023

    @amtoine
    MemberAuthor

    with the first test output i'd say that this issue should not be closed by #8552

  13. 2 remaining items

  14. amtoine commented on Mar 22, 2023

    @amtoine
    MemberAuthor

    it must be something different. i haven't drilled in to see what is going on exactly with line-by-line debugging. but it runs further before puking.

    yeah something different than the base_path addressed in #8552 👍

    but still the issue in this issue is not addressed 😮
    std::tests::test_dirs::test_dirs_command still fails on macOS, right?

    worse, maybe we should revert the changes in #8552 if that's not the real problem 🤔
    we need to investigate more on this 😉
    this is why i think we should reopen this issue 😋

    All this makes me glad that we plan to do ci testing cross-platform for std.nu.

    oh yeah for sure 😌

  15. amtoine commented on Mar 22, 2023

    @amtoine
    MemberAuthor

    thanks a lot 😋

    there is no rush for this, #8525 can wait a bit more 😉

  16. presidento commented on Mar 22, 2023

    @presidento
    Contributor

    @amtoine

    you put a 👍 in #8552, have you tested the fix in macOS to see if the tests run properly without any errors? 😋

    No. I did not approve it, I reviewed your code changes and liked it. Sorry if I made confusion with that.

  17. presidento commented on Mar 22, 2023

    @presidento
    Contributor

    there is no rush for this, #8525 can wait a bit more 😉

    I do not agree. I think it would be better to remove dirs commands, until it is fixed, and wire in the CI without it, since it already breaks the philosophy of being fully cross-platform. (Also it will be easier to test the re-addition in a new PR, since MacOS test will run against it. Until CI is active we cannot be sure that a new command will also break in some platform or not.)

  18. amtoine commented on Mar 22, 2023

    @amtoine
    MemberAuthor

    No. I did not approve it, I reviewed your code changes and liked it. Sorry if I made confusion with that.

    yeah that's what i thought, do not worry 😉
    not a big deal at all, things can be reverted and reopened 💪

  19. amtoine commented on Mar 22, 2023

    @amtoine
    MemberAuthor

    I do not agree. I think it would be better to remove dirs commands, until it is fixed, and wire in the CI without it, since it already breaks the philosophy of being fully cross-platform. (Also it will be easier to test the re-addition in a new PR, since MacOS test will run against it. Until CI is active we cannot be sure that a new command will also break in some platform or not.)

    i'd rather disable the tests, e.g. by making theirs names invisible by the test runner, in order to speed up #8525

    then i can solve the merge conflict in the runner and finally merge all this 💪

    if everyone is ok with disabling the tests in test_dirs.nu, i can do that tomorrow right after work 👍

  20. presidento commented on Mar 22, 2023

    @presidento
    Contributor

    I do not want to hold it back. If the decision is to disable these tests, please do this way (of course, replace Windows with the proper name for MacOS. I do not know, what are the possible values here):

    diff --git a/crates/nu-utils/standard_library/test_dirs.nu b/crates/nu-utils/standard_library/test_dirs.nu
    index 1370c5e35..fe5ec61cf 100644
    --- a/crates/nu-utils/standard_library/test_dirs.nu
    +++ b/crates/nu-utils/standard_library/test_dirs.nu
    @@ -1,5 +1,6 @@
     use std.nu "assert length"
     use std.nu "assert equal"
    +use std.nu "log warning"
    
     def clean [path: path] {
         cd $path
    @@ -8,6 +9,10 @@ def clean [path: path] {
     }
    
     export def test_dirs_command [] {
    +    if (sys).host.name == "Windows" {
    +        log warning "Skip testing in MacOS, see https://github.com/nushell/nushell/issues/8528"
    +        return
    +    }
         # need some directories to play with
         let base_path = (($nu.temp-path) | path join $"test_dirs_(random uuid)" | path expand )
         let path_a = ($base_path | path expand | path join "a")
  21. amtoine commented on Mar 22, 2023

    @amtoine
    MemberAuthor

    @presidento, kinda like the way you disable them 👍

  22. fdncred commented on Mar 22, 2023

    @fdncred
    Contributor

    The problem with add changes PWD to first added dir is because:

    > $env.PWD
    /private/var/folders/m1/x0gp9jy51s146ttxtz7jlpxh0000gn/T/test_dirs_a1f40969-e630-490c-b205-7edc6604b698/b
    > $path_b
    /var/folders/m1/x0gp9jy51s146ttxtz7jlpxh0000gn/T/test_dirs_a1f40969-e630-490c-b205-7edc6604b698/b
    

    It looks like $path_b isn't being expanded through the symlink.

    To be more clear, if we want this to work, we'll have to path expand after the path join (i think) or we'll need to modify path join's rust code so that it does expand.

    So, maybe we can get by for now by changing this:

        let path_a = ($base_path | path expand | path join "a")
        let path_b = ($base_path | path expand | path join "b")
    

    to this: (i need to test this first)

        let path_a = ($base_path | path join "a" | path expand)
        let path_b = ($base_path | path join "b" | path expand)
    
  23. fdncred commented on Mar 22, 2023

    @fdncred
    Contributor

    After talking about this in our meeting today, we do not want to disable any tests, but we want to fix the problems that we find because that just makes the language better. I think we need to fix path join so that it expands.

  24. added a commit that references this issue on Mar 23, 2023
    616f065
  25. fdncred commented on Mar 23, 2023

    @fdncred
    Contributor

    btw #8576 i think fixes the problems we were having. hopefully this will "unstick" us so we can keep moving forward.

  26. amtoine commented on Mar 23, 2023

    @amtoine
    MemberAuthor

    i'll try to fix #8525 tonight 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:std-librarytests

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions