diff --git a/Makefile b/Makefile index 798933c..dee1d9c 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ 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/ @@ -17,7 +20,7 @@ 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 diff --git a/internal/stages_test.go b/internal/stages_test.go index 2a57ff6..bd9fb05 100644 --- a/internal/stages_test.go +++ b/internal/stages_test.go @@ -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"}, + CodePath: "./test_helpers/pass_all", + ExpectedExitCode: 0, + StdoutFixturePath: "./test_helpers/fixtures/base/pass", + NormalizeOutputFunc: normalizeTesterOutput, + }, "segfault": { UntilStageSlug: "ws9", CodePath: "./test_helpers/scenarios/segfault", diff --git a/internal/test_helpers/fixtures/base/pass b/internal/test_helpers/fixtures/base/pass new file mode 100644 index 0000000..56a58e0 --- /dev/null +++ b/internal/test_helpers/fixtures/base/pass @@ -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.