modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.35k stars 2.6k forks source link

[BUG] Tests fail to run when repository path contains spaces #2373

Open sampathchanda opened 7 months ago

sampathchanda commented 7 months ago

Bug description

I checked out my package under my iCloud directory (which is under Mobile Documents on Mac), and hence the absolute path of my repository contains spaces. Because of this, running the tests fail saying mojo is unable to find the specified test file. Following is the error message:

./stdlib/scripts/run-tests.sh

Creating build directory for building the stdlib running the tests in.
Packaging up the Standard Library.
Successfully created /Users/sampath/Library/Mobile Documents/com~apple~CloudDocs/MyData/Work/Learning/Mojo/contributing_tutorial/mojo/build/stdlib.mojopkg
Packaging up the test_utils.
FAIL: Mojo Standard Library :: collections/test_set.mojo (1 of 80)
******************** TEST 'Mojo Standard Library :: collections/test_set.mojo' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 13: mojo /Users/sampath/Library/Mobile Documents/com~apple~CloudDocs/MyData/Work/Learning/Mojo/contributing_tutorial/mojo/stdlib/test/collections/test_set.mojo
+ mojo /Users/sampath/Library/Mobile Documents/com~apple~CloudDocs/MyData/Work/Learning/Mojo/contributing_tutorial/mojo/stdlib/test/collections/test_set.mojo
mojo: error: no such command '/Users/sampath/Library/Mobile'

Am using Mac OS Sonoma 14.3 Mojo version: mojo 2024.4.1618 (37a3e965) Modular version: modular 0.7.2 (d0adc668)

PS: I tried renaming the Mobile Documents directory on Mac, which is a mistake that I understood later. Had to mess around quite a lot to get back the data from my iCloud. While I can checkout the repository somewhere else with the repository path not having spaces, I think it is still limiting to run tests to have this bug.

Steps to reproduce

System information

- What OS did you do install Mojo on ?
- Provide version information for Mojo by pasting the output of `mojo -v`
- Provide Modular CLI version by pasting the output of `modular -v`
gabrieldemarmiesse commented 7 months ago

Indeed that's caused by the lines:

# RUN: %mojo %s

In the test files, since they're executed by a shell, they're sensitive to spaces. We could change them to

# RUN: %mojo "%s"

but I'm not sure it's worth it as the command mojo test will soon be used to test the stdlib and those lines won't be needed anymore

sampathchanda commented 6 months ago

@gabrieldemarmiesse Do you know where the lines of code you specified are, in the repo?