I’m stuck on Stage # #ei0.
First I thought I am loosing my mind, but the logs clearly show the testing process is incorrect
I am currently in the pwd builtin section, which is fairly easy task but my code is getting stuck in the type testcase which I have already passed before. I then hard coded the paths and tried to check if there is my_exe is expected in them, but the path my program shows seems to be the correct one and the expected path doesn’t have the my_exe file. Moreover, I have no idea why I am suddenly getting error in this testcase which I have already passed before
Any help is appreciated
Here are my logs:
remote: [your-program] $ type mkdir
remote: [tester::#MG5] ✓ Received expected response
remote: [your-program] $ type my_exe
remote: [your-program] my_exe is /tmp/quz/my_exe
remote: [tester::#MG5] Output does not match expected value.
remote: [tester::#MG5] Expected: "my_exe is /tmp/bar/my_exe"
remote: [tester::#MG5] Received: "my_exe is /tmp/quz/my_exe"
remote: [your-program] True
remote: [your-program] False
remote: [your-program] False
remote: [your-program] False
remote: [your-program] $
remote: [tester::#MG5] Assertion failed.
remote: [tester::#MG5] Test failed`
And here’s a snippet of my relevant code:
elif split_command[0] == "type":
PATH = os.environ.get("PATH")
PATH_SPLIT = PATH.split(":") #separated by : in codecrafter's server
command_path = 0
for path in PATH_SPLIT:
# print("currently in:",str(path) + "/" + str(split_command[1]))
if os.path.isfile(str(path) + "/" + str(split_command[1])):
# print(str(path) + "/" + str(split_command[1]))
command_path = str(path) + "/" + str(split_command[1])
if split_command[1] in ['echo','type','exit','pwd']:
print(split_command[1],"is a shell builtin")
elif split_command[1] == "my_exe":
print("my_exe is",command_path)
print(os.path.isfile(command_path))
print(os.path.isfile("/tmp/bar/my_exe"))
print(os.path.isfile("/tmp/qux/my_exe"))
print(os.path.isfile("/tmp/foo/my_exe"))
elif command_path:
print(split_command[1],"is",command_path)
else:
print(split_command[1],": not found", sep="")

