C++ #ND2 challenge build time is taking so much that it causes the time to exceed

I’m stuck on Stage #ND2.

My sole problem is that when I try to test my code it always exceeds the time. because all the time taken by building step, which weirdly is included in the test time

Here are my logs:

[compile] Compilation successful.
[tester::#ND2] Running tests for Stage #ND2 (Download a piece)
[tester::#ND2] Running ./your_bittorrent.sh download_piece -o /tmp/torrents3170529684/piece-9 /tmp/torrents3170529684/itsworking.gif.torrent 9
[your_program] -- Running vcpkg install
[your_program] All requested packages are currently installed.
[your_program] All requested installations completed successfully in: 40.8 us
[your_program] -- Running vcpkg install - done
[your_program] -- The C compiler identification is GNU 14.2.0
[your_program] -- The CXX compiler identification is GNU 14.2.0
[your_program] -- Detecting C compiler ABI info
[your_program] -- Detecting C compiler ABI info - done
[your_program] -- Check for working C compiler: /usr/bin/cc - skipped
[your_program] -- Detecting C compile features
[your_program] -- Detecting C compile features - done
[your_program] -- Detecting CXX compiler ABI info
[your_program] -- Detecting CXX compiler ABI info - done
[your_program] -- Check for working CXX compiler: /usr/local/bin/c++ - skipped
[your_program] -- Detecting CXX compile features
[your_program] -- Detecting CXX compile features - done
[your_program] -- Configuring done (6.0s)
[your_program] -- Generating done (0.0s)
[your_program] -- Build files have been written to: /app/build
[your_program] [  5%] Building CXX object CMakeFiles/bittorrent.dir/src/commands/decode.cpp.o
[your_program] [ 10%] Building CXX object CMakeFiles/bittorrent.dir/src/commands/download_piece.cpp.o
[tester::#ND2] timed out, test exceeded 10 seconds
[tester::#ND2] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

Hey @ycsvenom, I’ve pushed a fix to your repo. You can run git pull to sync the changes.

Let me know if you’re still running into issues!

Okay, thanks for updating the template, but there is still a problem
It would fail with this error when the test is being executed

Initiating test run...

⚡ This is a turbo test run. https://codecrafters.io/turbo

Running tests. Logs should appear shortly...

[compile] -- Running vcpkg install
[compile] All requested packages are currently installed.
[compile] All requested installations completed successfully in: 56.7 us
[compile] -- Running vcpkg install - done
[compile] -- The C compiler identification is GNU 14.2.0
[compile] -- The CXX compiler identification is GNU 14.2.0
[compile] -- Detecting C compiler ABI info
[compile] -- Detecting C compiler ABI info - done
[compile] -- Check for working C compiler: /usr/bin/cc - skipped
[compile] -- Detecting C compile features
[compile] -- Detecting C compile features - done
[compile] -- Detecting CXX compiler ABI info
[compile] -- Detecting CXX compiler ABI info - done
[compile] -- Check for working CXX compiler: /usr/local/bin/c++ - skipped
[compile] -- Detecting CXX compile features
[compile] -- Detecting CXX compile features - done
[compile] -- Configuring done (4.9s)
[compile] CMake Error at /vcpkg/scripts/buildsystems/vcpkg.cmake:599 (_add_executable):
[compile]   No SOURCES given to target: tests
[compile] Call Stack (most recent call first):
[compile]   CMakeLists.txt:25 (add_executable)
[compile] 
[compile] 
[compile] CMake Generate step failed.  Build files cannot be regenerated correctly.
[compile] Looks like your code failed to compile.
[compile] If you think this is a CodeCrafters error, please let us know at hello@codecrafters.io.

even though that there is TEST_SOURCES given for tests target it will still fail. if I commented everything for tests it will return to normal but I don’t want to do that since it will diverge into inconvenience later

@ycsvenom Looks like codecrafters test was having trouble picking up the changes from CMakeLists.txt and src/tests.

Could you try committing and pushing those changes to see if that resolves the No SOURCES given to target: tests issue?

I can get a new error after doing that:

Sorry for late response,
Can’t you make a new branch? it’s best to not mess a lot with the branch just for debugging
Thanks a lot

@ycsvenom I haven’t made any changes to your master branch since the initial fix. The screenshot above was from a cloned copy.

Could you try committing and pushing any changes (instead of using codecrafters test) to see if that resolves the No SOURCES given to target: tests issue?

I am sorry again for keeping you wait, I had a severe muscle strain in my neck and my free period has ended so there is no point to fix it, thanks again anyway, In the mean time I will try to fix my code to handle multiple peers instead of because it keeps getting time exceeded for one piece downloads

No worries at all. Hope you’re feeling better now!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.