Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ release:
build:
go build -o dist/main.out ./cmd/tester

record_fixtures:
CODECRAFTERS_RECORD_FIXTURES=true make test

test:
TESTER_DIR=$(shell pwd) go test -v ./internal/

test_and_watch:
onchange '**/*' -- go test -v ./internal/

test_with_sqlite: build
CODECRAFTERS_SUBMISSION_DIR=$(shell pwd)/internal/test_helpers/pass_all \
CODECRAFTERS_REPOSITORY_DIR=$(shell pwd)/internal/test_helpers/pass_all \
CODECRAFTERS_TEST_CASES_JSON='[{"slug":"dr6","tester_log_prefix":"stage-1","title":"Stage #1: Print page size"},{"slug":"ce0","tester_log_prefix":"stage-2","title":"Stage #2: Print number of tables"},{"slug":"sz4","tester_log_prefix":"stage-3","title":"Stage #3: Print table names"},{"slug":"nd9","tester_log_prefix":"stage-4","title":"Stage #4: Count rows in a table"},{"slug":"az9","tester_log_prefix":"stage-5","title":"Stage #5: Read data from a single column"},{"slug":"vc9","tester_log_prefix":"stage-6","title":"Stage #6: Read data from multiple columns"},{"slug":"rf3","tester_log_prefix":"stage-7","title":"Stage #7: Filter data with a WHERE clause"},{"slug":"ws9","tester_log_prefix":"stage-8","title":"Stage #8: Retrieve data using a full-table scan"},{"slug":"nz8","tester_log_prefix":"stage-9","title":"Stage #9: Retrieve data using an index"}]' \
dist/main.out

Expand Down
9 changes: 9 additions & 0 deletions internal/stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ func TestStages(t *testing.T) {
StdoutFixturePath: "./test_helpers/fixtures/table_names/success",
NormalizeOutputFunc: normalizeTesterOutput,
},
"pass_all": {
// omitted "dr6", "ce0" because sqlite3 on linux is not compiled to support .dbinfo
// omitted "az9", "vc9", "rf3" because of randomness issues
StageSlugs: []string{"sz4", "nd9", "ws9", "nz8"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andy1li what's the context here and the reason for this PR? If we're adding this I think we should solve the problems mentioned above re: randomness and .dbinfo support not being available.

Copy link
Member Author

@andy1li andy1li Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's part of my investigation on the timing-out issue in the last "index" stage. The main purpose of this PR was to determine if the issue would happen in GH actions. Result: it did not time out here.

Will try and resolve the problems mentioned in the comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay - yeah if it's easy to do feel free to, if not no problem we'll get to it when we're working on SQLite next

CodePath: "./test_helpers/pass_all",
ExpectedExitCode: 0,
StdoutFixturePath: "./test_helpers/fixtures/base/pass",
NormalizeOutputFunc: normalizeTesterOutput,
},
"segfault": {
UntilStageSlug: "ws9",
CodePath: "./test_helpers/scenarios/segfault",
Expand Down
52 changes: 52 additions & 0 deletions internal/test_helpers/fixtures/base/pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Debug = true

[tester::#SZ4] Running tests for Stage #SZ4 (sz4)
[tester::#SZ4] Creating test.db with tables: [apple blueberry grape orange strawberry]
[tester::#SZ4] $ ./your_sqlite3.sh test.db .tables
[your_program] apple blueberry grape orange strawberry
[tester::#SZ4] Test passed.

[tester::#ND9] Running tests for Stage #ND9 (nd9)
[tester::#ND9] Creating table 'grape' with 114 rows
[tester::#ND9] $ ./your_sqlite3.sh test.db "select count(*) from grape"
[your_program] 114
[tester::#ND9] Test passed.

[tester::#WS9] Running tests for Stage #WS9 (ws9)
[tester::#WS9] $ ./your_sqlite3.sh test.db "SELECT id, name FROM superheroes WHERE eye_color = 'Gold Eyes'"
[your_program] 764|Azrael (New Earth)
[your_program] 1131|Lambien (New Earth)
[your_program] 1616|Anna Fortune (New Earth)
[your_program] 2995|Layla (New Earth)
[your_program] 4346|Allegra Garcia (New Earth)
[your_program] 4533|Kal-El (DC One Million)
[your_program] 4710|Amber (New Earth)
[your_program] 4765|Ahura-Mazda (New Earth)
[your_program] 5413|Majistra (New Earth)
[tester::#WS9] $ ./your_sqlite3.sh test.db "SELECT id, name FROM superheroes WHERE eye_color = 'Pink Eyes'"
[your_program] 297|Stealth (New Earth)
[your_program] 790|Tobias Whale (New Earth)
[your_program] 1085|Felicity (New Earth)
[your_program] 2729|Thrust (New Earth)
[your_program] 3289|Angora Lapin (New Earth)
[your_program] 3913|Matris Ater Clementia (New Earth)
[tester::#WS9] $ ./your_sqlite3.sh test.db "SELECT id, name FROM superheroes WHERE hair_color = 'Reddish Brown Hair'"
[your_program] 474|Yolanda Montez (New Earth)
[your_program] 3748|Deron Ved (Earth-One)
[your_program] 6777|G'Nort (New Earth)
[tester::#WS9] Test passed.

[tester::#NZ8] Running tests for Stage #NZ8 (nz8)
[tester::#NZ8] $ ./your_sqlite3.sh test.db "SELECT id, name FROM companies WHERE country = 'micronesia'"
[your_program] 1307865|college of micronesia
[your_program] 3696903|nanofabrica
[your_program] 4023193|fsm statistics
[your_program] 6132291|vital energy micronesia
[your_program] 6387751|fsm development bank
[tester::#NZ8] $ ./your_sqlite3.sh test.db "SELECT id, name FROM companies WHERE country = 'tonga'"
[your_program] 361142|tonga communications corporation
[your_program] 3186430|tonga development bank
[your_program] 3583436|leiola group limited
[your_program] 4796634|royco amalgamated company limited
[your_program] 7084593|tonga business enterprise centre
[tester::#NZ8] Test passed.