Skip to content

Commit

Permalink
Merge pull request #71 from codecrafters-io/CC-1226
Browse files Browse the repository at this point in the history
CC-1226: Use updated RunCLI interface from tester-utils
  • Loading branch information
ryan-gang authored May 29, 2024
2 parents 2c2ee5f + ec991dc commit d801c66
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17.x
go-version: 1.21.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17.x
go-version: 1.21.x
- name: Set up Python
uses: actions/setup-python@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
__pycache__
vendor
vendor
.history/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test:

test_with_git: build
CODECRAFTERS_SUBMISSION_DIR=$(shell pwd)/internal/test_helpers/pass_all \
CODECRAFTERS_TEST_CASES_JSON='[{"slug":"init","tester_log_prefix":"stage-1","title":"Stage #1: Initialize the .git directory"},{"slug":"read_blob","tester_log_prefix":"stage-2","title":"Stage #2: Read a blob object"},{"slug":"create_blob","tester_log_prefix":"stage-3","title":"Stage #3: Create a blob object"},{"slug":"read_tree","tester_log_prefix":"stage-4","title":"Stage #4: Read a tree object"},{"slug":"write_tree","tester_log_prefix":"stage-5","title":"Stage #5: Write a tree object"},{"slug":"create_commit","tester_log_prefix":"stage-6","title":"Stage #6: Create a commit"},{"slug":"clone_repository","tester_log_prefix":"stage-7","title":"Stage #7: Clone a repository"}]' \
CODECRAFTERS_TEST_CASES_JSON='[{"slug":"gg4","tester_log_prefix":"stage-1","title":"Stage #1: Initialize the .git directory"},{"slug":"ic4","tester_log_prefix":"stage-2","title":"Stage #2: Read a blob object"},{"slug":"jt4","tester_log_prefix":"stage-3","title":"Stage #3: Create a blob object"},{"slug":"kp1","tester_log_prefix":"stage-4","title":"Stage #4: Read a tree object"},{"slug":"fe4","tester_log_prefix":"stage-5","title":"Stage #5: Write a tree object"},{"slug":"jm9","tester_log_prefix":"stage-6","title":"Stage #6: Create a commit"},{"slug":"mg6","tester_log_prefix":"stage-7","title":"Stage #7: Clone a repository"}]' \
dist/main.out

copy_course_file:
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module github.com/codecrafters-io/git-tester

go 1.20
go 1.21

toolchain go1.22.1

require (
github.com/codecrafters-io/tester-utils v0.2.21
github.com/codecrafters-io/tester-utils v0.2.24
github.com/go-git/go-billy/v5 v5.0.0
github.com/go-git/go-git/v5 v5.0.0
)
Expand All @@ -14,7 +16,7 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
Expand All @@ -28,7 +30,7 @@ require (
github.com/xanzy/ssh-agent v0.2.1 // indirect
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 // indirect
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/sys v0.20.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
36 changes: 6 additions & 30 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,16 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/codecrafters-io/tester-utils v0.2.7 h1:PkYNYBrQRwFdw/kt3y1D3duqdiBrj5RYyT9wqJx5W2U=
github.com/codecrafters-io/tester-utils v0.2.7/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.10 h1:Xpu6wzgpRpiZPFNGWMRcJXwAZZ0Yb5Mv6IDOR319f+s=
github.com/codecrafters-io/tester-utils v0.2.10/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.15 h1:d6lbr1nVkZ4+G55E47bG3bf1lWiMLOUZy5EiHwX2SsE=
github.com/codecrafters-io/tester-utils v0.2.15/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.16 h1:PGOtXxklmoXPjZn5Yc/FObiXQZvRZ+f3qqUlGklRbKs=
github.com/codecrafters-io/tester-utils v0.2.16/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.17 h1:rO04TuOME773cZE729kIVOiXpZSq5oXsaSrDj6ga2X8=
github.com/codecrafters-io/tester-utils v0.2.17/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.18 h1:fjIWERlzR1700Mogr8+30H3bYyLY+36KMU8ojloo3/0=
github.com/codecrafters-io/tester-utils v0.2.18/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.20 h1:t/IFFXOrSgRIoq6x4kUnRdjuai7EcwWH42Za25hvneA=
github.com/codecrafters-io/tester-utils v0.2.20/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.21 h1:eVq/23WocZMCFnNPiB6rgP/4FZ/tlLoijT2EulkOng4=
github.com/codecrafters-io/tester-utils v0.2.21/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.24 h1:8IwKd70n9BMfVqNoGxRJItFj769p6h6LxCx4OMwWoq8=
github.com/codecrafters-io/tester-utils v0.2.24/go.mod h1:VgP0WmmRsA8L1urWGMXPW4Zv5jcwHwR0LdKZ8ZAEFT4=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
Expand All @@ -56,8 +40,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
Expand Down Expand Up @@ -91,14 +73,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
10 changes: 1 addition & 9 deletions internal/cli.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
package internal

import (
"fmt"
testerutils "github.com/codecrafters-io/tester-utils"
)

func RunCLI(env map[string]string) int {
tester, err := testerutils.NewTester(env, testerDefinition)

if err != nil {
fmt.Printf("%s", err)
return 1
}

return tester.RunCLI()
return testerutils.RunCLI(env, testerDefinition)
}
30 changes: 15 additions & 15 deletions internal/tester_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@ import (
)

var testerDefinition = tester_definition.TesterDefinition{
AntiCheatTestCases: []tester_definition.TestCase{},
AntiCheatTestCases: []tester_definition.TestCase{},
ExecutableFileName: "your_git.sh",
TestCases: []tester_definition.TestCase{
{
Slug: "gg4",
TestFunc: testInit,
Slug: "gg4",
TestFunc: testInit,
},
{
Slug: "ic4",
TestFunc: testReadBlob,
Slug: "ic4",
TestFunc: testReadBlob,
},
{
Slug: "jt4",
TestFunc: testCreateBlob,
Slug: "jt4",
TestFunc: testCreateBlob,
},
{
Slug: "kp1",
TestFunc: testReadTree,
Slug: "kp1",
TestFunc: testReadTree,
},
{
Slug: "fe4",
TestFunc: testWriteTree,
Slug: "fe4",
TestFunc: testWriteTree,
},
{
Slug: "jm9",
TestFunc: testCreateCommit,
Slug: "jm9",
TestFunc: testCreateCommit,
},
{
Slug: "mg6",
TestFunc: testCloneRepository,
Slug: "mg6",
TestFunc: testCloneRepository,
},
},
}

0 comments on commit d801c66

Please sign in to comment.