File tree 2 files changed +18
-4
lines changed
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ The commands are:
17
17
page build index.md file
18
18
tag build all tags file
19
19
helper build helper file
20
- question build problem description file
20
+ question build problem solution file
21
21
open open a problem solution in browser
22
22
test run go test
23
23
description build all problems description file
Original file line number Diff line number Diff line change @@ -3,22 +3,36 @@ package test
3
3
import (
4
4
"os"
5
5
"os/exec"
6
+ "strconv"
6
7
7
8
"github.com/openset/leetcode/internal/base"
9
+ "github.com/openset/leetcode/internal/leetcode"
8
10
)
9
11
10
12
var CmdTest = & base.Command {
11
13
Run : runTest ,
12
- UsageLine : "test" ,
14
+ UsageLine : "test [QuestionId] " ,
13
15
Short : "run go test" ,
14
16
Long : "automates testing the packages." ,
15
17
}
16
18
17
19
func runTest (cmd * base.Command , args []string ) {
18
- if len (args ) != 0 {
20
+ if len (args ) > 1 {
19
21
cmd .Usage ()
20
22
}
21
- c := exec .Command ("go" , "test" , "./..." )
23
+ target := "./..."
24
+ if len (args ) == 1 {
25
+ if questionId , err := strconv .Atoi (args [0 ]); err == nil {
26
+ problems := leetcode .ProblemsAll ()
27
+ for _ , problem := range problems .StatStatusPairs {
28
+ if problem .Stat .FrontendQuestionId == questionId {
29
+ target = "./problems/" + problem .Stat .QuestionTitleSlug
30
+ break
31
+ }
32
+ }
33
+ }
34
+ }
35
+ c := exec .Command ("go" , "test" , target )
22
36
c .Stdout = os .Stdout
23
37
c .Stderr = os .Stderr
24
38
err := c .Run ()
You can’t perform that action at this time.
0 commit comments