mojo icon indicating copy to clipboard operation
mojo copied to clipboard

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

Open sampathchanda opened this issue 3 months ago • 3 comments

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

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

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`

sampathchanda avatar Apr 22 '24 00:04 sampathchanda

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

gabrieldemarmiesse avatar Apr 22 '24 13:04 gabrieldemarmiesse

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

sampathchanda avatar May 01 '24 03:05 sampathchanda