I’m stuck on Stage #RA6. I’m not sure why—when I run the same commands locally, everything works fine. For the pwd command, the path is /tmp/strawberry/grape/mango, as expected. However, when I run the tests, they fail and show /app instead.
Here are my logs:
[your-program] $ cd /tmp/strawberry/grape/mango
[your-program] $ pwd
[your-program] /app
[tester::#RA6] ^ Line does not match expected value.
[tester::#RA6] Expected: "/tmp/strawberry/grape/mango"
[tester::#RA6] Received: "/app"
And here’s a snippets of my code:
public class CdCommandHandler implements CommandHandler {
@Override
public boolean canHandle(String command) {
return command.startsWith("cd");
}
@Override
public void handle(String command) {
String[] commandParts = command.split("\\s+");
File file = new File(commandParts[1]);
if (file.isDirectory()) {
ShellUtils.CURRENT_DIRECTORY = commandParts[1];
} else {
System.out.println("cd: " + commandParts[1] + ": No such file or directory");
}
}
}
public class PwdCommandHandler implements CommandHandler {
@Override
public boolean canHandle(String command) {
return command.startsWith("pwd");
}
@Override
public void handle(String command) {
System.out.println(ShellUtils.CURRENT_DIRECTORY);
}
}
