well, the test will run in their environment, so you didn’t need worry about file don’t exist in your environment.try output more info to see what’s not working well
@JanInquisitor looks like you’ve got a !Files.exists(path), shouldn’t that have triggered an early return if the file doesn’t exist? Why are you getting an exception instead?
I’d also echo @rgbygv’s suggestion - try printing out the path value to make sure that args are being parsed correctly.
(Pretty sure the file exists btw, 1000s of users have passed this stage, and we haven’t changed the tester recently)
I changed the code and made it print the exception, I get a “java.nio.file.NoSuchFileException”. I’ve also printed the arguments goings into the program and I got the path file string, here it is:
remote: [tester::#OW9] Running tests for Stage #OW9 (Parse torrent file)
remote: [tester::#OW9] Running ./your_bittorrent.sh info /tmp/torrents770425335/itsworking.gif.torrent
remote: [your_program] /tmp/torrents770425335/itsworking.gif.torrent.
remote: [your_program] java.nio.file.NoSuchFileException: /tmp/torrents770425335/itsworking.gif.torrent.
remote: [your_program] at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
remote: [your_program] at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
remote: [your_program] at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
remote: [your_program] at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:261)
remote: [your_program] at java.base/java.nio.file.Files.newByteChannel(Files.java:379)
remote: [your_program] at java.base/java.nio.file.Files.newByteChannel(Files.java:431)
remote: [your_program] at java.base/java.nio.file.Files.readAllBytes(Files.java:3268)
remote: [your_program] at Main.readInfoFile(Main.java:40)
remote: [your_program] at Main.main(Main.java:28)
remote: [tester::#OW9] Checking for tracker URL (Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce)
remote: [tester::#OW9] Expected stdout to contain "Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce", got: "/tmp/torrents770425335/itsworking.gif.torrent.\n"
remote: [tester::#OW9] Test failed
@JanInquisitor is the “.” at the end of the filename part of the filename? Or was that added in your log? Seems a bit suspicious that the same dot would also be present in the “NoSuchFileException” log:
Gotcha. So the problem definitely seems to be related to the extra dot. @andy1li should be able to take a closer look at this for you on Monday. @JanInquisitor If you figure out what’s wrong in the meantime, please do let us know!