Skip to content

Commit 0012bc1

Browse files
authored
Merge pull request #169 from codecrafters-io/fix-confusing-stage-1-messagse
Don't mention long-running process in earlier stages
2 parents f405a3f + 4fa8b00 commit 0012bc1

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

internal/rdb_file_creator_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package internal
22

33
import (
4-
"fmt"
54
"io"
65
"os"
76
"path/filepath"
@@ -26,7 +25,6 @@ func TestRDBFileCreator(t *testing.T) {
2625

2726
fh, _ := os.Open(filepath.Join(RDBFileCreator.Dir, RDBFileCreator.Filename))
2827
defer fh.Close()
29-
fmt.Println("File content:")
3028
data, err := io.ReadAll(fh)
3129
if err != nil {
3230
t.Fatalf("CodeCrafters Tester Error: %s", err)
@@ -37,5 +35,4 @@ func TestRDBFileCreator(t *testing.T) {
3735
version := versionData[5:9]
3836
assert.Equal(t, "REDIS", magicString)
3937
assert.Equal(t, "0011", version)
40-
t.Logf("Version: %s", version)
4138
}

internal/test_cases/bind_test_case.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ func (t BindTestCase) Run(executable *redis_executable.RedisExecutable, logger *
3030

3131
if err != nil {
3232
if executable.HasExited() {
33-
return fmt.Errorf("Looks like your program has terminated. A redis server is expected to be a long-running process.")
33+
// We don't need to mention that the user's program exited or is expected to be a long-running process as
34+
// this could be confusing in early stages where the user is expected to only handle a single request from
35+
// a single client.
36+
//
37+
// Let's just exit early and not retry if this happens.
38+
return fmt.Errorf("Failed to connect to port %d.", t.Port)
3439
}
3540

3641
// Don't print errors in the first second

internal/test_helpers/fixtures/bind/failure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
[stage-1] $ ./spawn_redis_server.sh
33
[stage-1] Connecting to port 6379...
44
[your_program] hey, not going to bind!
5-
[stage-1] Looks like your program has terminated. A redis server is expected to be a long-running process.
5+
[stage-1] Failed to connect to port 6379.
66
[stage-1] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

0 commit comments

Comments
 (0)