CodeCrafter 소개 - 단계별 프로그램 제작 실습
프로그래밍 공부하기 재미있는 사이트가 하나 있군요. ^^
Catalog | CodeCrafters - Challenges
; https://app.codecrafters.io/courses
접속하고 로그인하면 각각의 주제별로 다양한 프로그램을 작성하는 과제가 나옵니다. 비록 유료이긴 하지만, 처음이라면 "FREE THIS MONTH"라든가 "FREE DURING BETA" 같은 주제를 선정해서 하나씩 심심할 때 실습하는 것도 좋을 것 같습니다. ^^
방식은 간단합니다. 특정 주제를 선택하고, 단계별로 요구하는 기능을 작성한 후에 git commit을 하면 codecrafters 서버 측에서 기능 테스트가 이뤄집니다. 즉, 구현 여부에 대한 판정은 기능 테스트 통과로 결정됩니다.
그런데, 하다 보면 기능 테스트를 위해 매번 git commit을 하는 것이 번거롭다고 느낄 수 있는데요, 그럴 때는 로컬에 codecrafters-cli를 설치해,
How do I install the CLI?
; https://docs.codecrafters.io/cli/installation
// 윈도우 환경이라면 WSL에서 실행
$ curl https://codecrafters.io/install.sh | sh
$ git config --global user.email "...git사용자 이메일..."
$ git config --global user.name "...git사용자이름..."
코드 변경 후 (git commit 없이) 해당 프로젝트 디렉터리에서 "codecrafters test" 명령어를 실행하면 기능 테스트를 구동할 수 있습니다.
$ pwd
/mnt/c/git_temp/codecrafters-shell-csharp
$ codecrafters test
Initiating test run...
⚡ This is a turbo test run. https://codecrafters.io/turbo
Running tests. Logs should appear shortly...
[compile] Determining projects to restore...
[compile] All projects are up-to-date for restore.
[compile] codecrafters-shell -> /tmp/codecrafters-build-csharp/codecrafters-shell.dll
...[생략]...
[tester::#WH6] Running tests for Stage #WH6 (Autocompletion - Multiple completions)
[tester::#WH6] [setup] export PATH=/tmp/quz:$PATH
[tester::#WH6] [setup] export PATH=/tmp/qux:$PATH
[tester::#WH6] [setup] export PATH=/tmp/foo:$PATH
[tester::#WH6] [setup] Available executables:
[tester::#WH6] [setup] - xyz_baz
[tester::#WH6] [setup] - xyz_bar
[tester::#WH6] [setup] - xyz_qux
[tester::#WH6] Running ./your_program.sh
...[생략]...
참고로, 윈도우 + WSL 환경인 경우 "codecrafters test" 시에 이런 오류가 발생할 수 있습니다.
$ codecrafters test
Initiating test run...
⏳ Turbo test runners busy. You are in queue.
Upgrade to skip the wait: https://codecrafters.io/turbo
Running tests. Logs should appear shortly...
: not foundapp/.codecrafters/compile.sh: line 8:
: not foundapp/.codecrafters/compile.sh: line 10:
[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.
View our article on debugging test failures: https://codecrafters.io/debug
Failed to execute /app/your_program.sh: fork/exec /app/your_program.sh: no such file or directory
Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
왜냐하면, 해당 프로젝트의 ".codecrafters" 하위에 있는 "compile.sh", "run.sh" 파일이 (윈도우 환경의 git 설정에 따라) CRLF로 저장돼 있는 경우 저런 식으로 오류가 발생합니다. 따라서, 해당 파일을 LF로 변경한 후 다시 테스트를 수행하면 됩니다.