Application.app_dir failing test on master
I have a folder with all capital letters ("/Users/holsee/MEGA") in my path to the elixir working directory. This has highlighted a potentially false assumption regarding the format of the path returned by Application.app_dir or at the very least a test which needs to be tweaked.
iex(1)> Path.expand(".")
"/Users/holsee/MEGA/Projects/elixir"
iex(2)> System.cwd!
"/Users/holsee/MEGA/Projects"
iex(3)> Application.app_dir(:elixir)
"/Users/holsee/Mega/Projects/elixir/bin/../lib/elixir"
iex(4)> :code.lib_dir(:elixir)
'/Users/holsee/Mega/Projects/elixir/bin/../lib/elixir'
Failing test on stable and master:
1) test application directory (ApplicationTest)
test/elixir/application_test.exs:20
Assertion with == failed
code: Application.app_dir(:elixir) == Path.join(root, "bin/../lib/elixir")
lhs: "/Users/holsee/Mega/Projects/elixir/bin/../lib/elixir"
rhs: "/Users/holsee/MEGA/Projects/elixir/bin/../lib/elixir"
stacktrace:
test/elixir/application_test.exs:22
application_test.exs line 21 - 22
root = Path.expand("../../../..", __DIR__)
assert Application.app_dir(:elixir) ==
Path.join(root, "bin/../lib/elixir")
For what its worth I am running OS X and pwd in my shell (ohmyzsh) returns:
> $ pwd
/Users/holsee/Mega/Projects
I don't see this issue and am on top of tree master with all tests passing.
iex(1)> Path.expand(".")
"/Users/pkumar/development/TEST/elixir"
iex(2)> System.cwd!
"/Users/pkumar/development/TEST/elixir"
iex(3)> Application.app_dir(:elixir)
"/Users/pkumar/development/TEST/elixir/bin/../lib/elixir"
iex(4)> :code.lib_dir(:elixir)
'/Users/pkumar/development/TEST/elixir/bin/../lib/elixir'
@holsee @gsphanikumar
I got the same failing test here. On my machine, :code.lib_dir(:elixir) is returning some_path/documents/some_path, yet Path.expand(".") gives some_path/Documents/some_path.
@ericmj Looks to me Application.app_dir/1 is only called once in the whole code base, solely for the testing purpose. But can we still rely on app_dir/1 (which invokes :code.lib_dir/1) to assert application directory has the right path, since it seems :code.lib_dir/1 has some upper/lower case issues?
Yeah, the issue is ultimately in Erlang. The thing though is that it should not matter in practice, because the OS is case insensitive, just when directly comparing to another string. We could downcase both in tests.
@josevalim Thanks for the quick response. I thought (most of) windows file system is case-sensitive, or am I missing something?
I thought (most of) windows file system is case-sensitive, or am I missing something?
Yes. All the examples here seem to be using Mac though. One would need to check if the issue shows up on Windows machines.
Just tried on Windows and things are working fine on the Windows machine.
If I have a path some_path/Document/Elixir/, the OS will auto downcase the path to some_path/document/elixir/ (e.g. pwd gives some_path/document/elixir/).
Looks like in both Windows and Linux/Unix environment, this case issue doesn't matter. I will send a patch soon.
Just fyi: It would appear this issue is still present in tag v1.0.3, fixed in master.