Skip to content

Commit fd26bf6

Browse files
Add Run/Debug File
1 parent 7000354 commit fd26bf6

File tree

2 files changed

+199
-107
lines changed

2 files changed

+199
-107
lines changed

release/package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
"category": "Tests",
8585
"title": "Run Project"
8686
},
87+
{
88+
"command": "neptune.runFile",
89+
"category": "Tests",
90+
"title": "Run File"
91+
},
8792
{
8893
"command": "neptune.debugList",
8994
"category": "Tests",
@@ -99,6 +104,11 @@
99104
"category": "Tests",
100105
"title": "Debug Project"
101106
},
107+
{
108+
"command": "neptune.debugFile",
109+
"category": "Tests",
110+
"title": "Debug File"
111+
},
102112
{
103113
"command": "neptune.debugAll",
104114
"category": "Tests",
@@ -141,6 +151,24 @@
141151
]
142152
},
143153
"menus": {
154+
"commandPalette": [
155+
{
156+
"command": "neptune.runProject",
157+
"when": "false"
158+
},
159+
{
160+
"command": "neptune.debugProject",
161+
"when": "false"
162+
},
163+
{
164+
"command": "neptune.runFile",
165+
"when": "false"
166+
},
167+
{
168+
"command": "neptune.debugFile",
169+
"when": "false"
170+
}
171+
],
144172
"view/title": [
145173
{
146174
"command": "neptune.runAll",
@@ -181,6 +209,16 @@
181209
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.projectRunDebug",
182210
"group": "actions@1"
183211
},
212+
{
213+
"command": "neptune.runFile",
214+
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.fileRun",
215+
"group": "actions@1"
216+
},
217+
{
218+
"command": "neptune.runFile",
219+
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.fileRunDebug",
220+
"group": "actions@1"
221+
},
184222
{
185223
"command": "neptune.runTest",
186224
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.testRun",
@@ -211,6 +249,16 @@
211249
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.projectRunDebug",
212250
"group": "actions@2"
213251
},
252+
{
253+
"command": "neptune.debugFile",
254+
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.fileDebug",
255+
"group": "actions@2"
256+
},
257+
{
258+
"command": "neptune.debugFile",
259+
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.fileRunDebug",
260+
"group": "actions@2"
261+
},
214262
{
215263
"command": "neptune.debugTest",
216264
"when": "view == neptune.testExplorer && viewItem == neptune.testExplorer.testDebug",

src/TestExplorer.fs

Lines changed: 151 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -900,124 +900,168 @@ let activate selector (context: ExtensionContext) (reporter : IReporter) =
900900

901901
commands.registerCommand("neptune.runProject", Func<obj, obj>(fun m ->
902902
withProgress (fun msgHandler ->
903-
let m =
904-
if JS.isDefined m then
905-
reporter.sendTelemetryEvent "RunProject/Activate" undefined undefined
906-
Promise.lift <| unbox<TreeModel> m
907-
else
908-
reporter.sendTelemetryEvent "RunProject/Activate/Palette" undefined undefined
909-
let tests =
910-
flattedTests ()
911-
|> Seq.filter (fun n -> not n.List)
912-
|> Seq.map (fun n ->
913-
let qpi = createEmpty<QuickPickItem>
914-
qpi.label <- n.Name
915-
qpi?data <- n
916-
qpi
917-
)
918-
|> ResizeArray
919-
window.showQuickPick(U2.Case1 tests)
920-
|> Promise.map (fun n -> n?data |> unbox<TreeModel>)
921-
m
922-
|> Promise.bind (fun m ->
923-
let proj =
924-
getProjectList ()
925-
|> List.tryFind (fun n -> n.Project = m.FileName)
926-
match proj with
927-
| None -> Promise.lift []
928-
| Some proj ->
903+
reporter.sendTelemetryEvent "RunProject/Activate" undefined undefined
904+
let m = unbox<TreeModel> m
905+
906+
let proj =
907+
getProjectList ()
908+
|> List.tryFind (fun n -> n.Project = m.FileName)
909+
match proj with
910+
| None -> Promise.lift []
911+
| Some proj ->
912+
913+
let tests =
914+
flattedTests ()
915+
|> Seq.filter (fun t ->
916+
match getProjectForFile t.FileName with
917+
| None -> false
918+
| Some p -> p.Project = proj.Project )
919+
|> Seq.map (fun test -> test.FullName.Trim( '"', ' ', '\\', '/'))
920+
|> Seq.toList
921+
922+
let projectsWithTests = [ (proj, tests)]
929923

930-
let tests =
931-
flattedTests ()
932-
|> Seq.filter (fun t ->
933-
match getProjectForFile t.FileName with
934-
| None -> false
935-
| Some p -> p.Project = proj.Project )
936-
|> Seq.map (fun test -> test.FullName.Trim( '"', ' ', '\\', '/'))
937-
|> Seq.toList
924+
msgHandler |> report startingMsg
925+
runnerRegister.Values
926+
|> Promise.collect (fun r ->
927+
let prjsWithTsts = projectsWithTests |> List.filter (fun (p,_) -> r.ShouldProjectBeRun p)
928+
match prjsWithTsts with
929+
| [] -> Promise.lift []
930+
| xs -> r.RunTests msgHandler xs
931+
)
932+
|> Promise.onSuccess (fun n ->
933+
msgHandler |> report completedMsg
934+
handleTestResults n
935+
)
936+
|> Promise.onFail (fun n ->
937+
msgHandler |> report failedRunMsg
938+
window.showErrorMessage (sprintf "Running test failed - %O" n)
939+
|> ignore
940+
()
941+
)
942+
)
943+
)) |> context.subscriptions.Add
938944

939-
let projectsWithTests = [ (proj, tests)]
945+
commands.registerCommand("neptune.debugProject", Func<obj, obj>(fun m ->
946+
withProgress (fun msgHandler ->
947+
reporter.sendTelemetryEvent "DebugProject/Activate" undefined undefined
948+
let m = unbox<TreeModel> m
949+
let proj =
950+
getProjectList ()
951+
|> List.tryFind (fun n -> n.Project = m.FileName)
952+
match proj with
953+
| None -> Promise.lift []
954+
| Some proj ->
955+
956+
let tests =
957+
flattedTests ()
958+
|> Seq.filter (fun t ->
959+
match getProjectForFile t.FileName with
960+
| None -> false
961+
| Some p -> p.Project = proj.Project )
962+
|> Seq.map (fun test -> test.FullName.Trim( '"', ' ', '\\', '/'))
963+
|> Seq.toList
964+
965+
let projectsWithTests = [ (proj, tests)]
940966

941-
msgHandler |> report startingMsg
942-
runnerRegister.Values
943-
|> Promise.collect (fun r ->
944-
let prjsWithTsts = projectsWithTests |> List.filter (fun (p,_) -> r.ShouldProjectBeRun p)
945-
match prjsWithTsts with
946-
| [] -> Promise.lift []
947-
| xs -> r.RunTests msgHandler xs
948-
)
949-
|> Promise.onSuccess (fun n ->
950-
msgHandler |> report completedMsg
951-
handleTestResults n
952-
)
953-
|> Promise.onFail (fun n ->
954-
msgHandler |> report failedRunMsg
955-
window.showErrorMessage (sprintf "Running test failed - %O" n)
956-
|> ignore
957-
()
958-
)
967+
msgHandler |> report startingMsg
968+
runnerRegister.Values
969+
|> Promise.collect (fun r ->
970+
let prjsWithTsts = projectsWithTests |> List.filter (fun (p,_) -> r.ShouldProjectBeRun p)
971+
match prjsWithTsts with
972+
| [] -> Promise.lift []
973+
| xs -> r.DebugTests msgHandler xs
974+
)
975+
|> Promise.onSuccess (fun n ->
976+
msgHandler |> report completedMsg
977+
handleTestResults n
978+
)
979+
|> Promise.onFail (fun n ->
980+
msgHandler |> report failedRunMsg
981+
window.showErrorMessage (sprintf "Running test failed - %O" n)
982+
|> ignore
983+
()
959984
)
985+
960986
)
961987
)) |> context.subscriptions.Add
962988

963-
commands.registerCommand("neptune.debugProject", Func<obj, obj>(fun m ->
989+
commands.registerCommand("neptune.runFile", Func<obj, obj>(fun m ->
964990
withProgress (fun msgHandler ->
965-
let m =
966-
if JS.isDefined m then
967-
reporter.sendTelemetryEvent "DebugProject/Activate" undefined undefined
968-
Promise.lift <| unbox<TreeModel> m
969-
else
970-
reporter.sendTelemetryEvent "DebugProject/Activate/Palette" undefined undefined
971-
let tests =
972-
flattedTests ()
973-
|> Seq.filter (fun n -> not n.List)
974-
|> Seq.map (fun n ->
975-
let qpi = createEmpty<QuickPickItem>
976-
qpi.label <- n.Name
977-
qpi?data <- n
978-
qpi
979-
)
980-
|> ResizeArray
981-
window.showQuickPick(U2.Case1 tests)
982-
|> Promise.map (fun n -> n?data |> unbox<TreeModel>)
983-
m
984-
|> Promise.bind (fun m ->
985-
let proj =
986-
getProjectList ()
987-
|> List.tryFind (fun n -> n.Project = m.FileName)
988-
match proj with
989-
| None -> Promise.lift []
990-
| Some proj ->
991+
reporter.sendTelemetryEvent "RunFile/Activate" undefined undefined
992+
let m = unbox<TreeModel> m
991993

992-
let tests =
993-
flattedTests ()
994-
|> Seq.filter (fun t ->
995-
match getProjectForFile t.FileName with
996-
| None -> false
997-
| Some p -> p.Project = proj.Project )
998-
|> Seq.map (fun test -> test.FullName.Trim( '"', ' ', '\\', '/'))
999-
|> Seq.toList
994+
let proj = getProjectForFile m.FileName
1000995

1001-
let projectsWithTests = [ (proj, tests)]
996+
match proj with
997+
| None -> Promise.lift []
998+
| Some proj ->
1002999

1003-
msgHandler |> report startingMsg
1004-
runnerRegister.Values
1005-
|> Promise.collect (fun r ->
1006-
let prjsWithTsts = projectsWithTests |> List.filter (fun (p,_) -> r.ShouldProjectBeRun p)
1007-
match prjsWithTsts with
1008-
| [] -> Promise.lift []
1009-
| xs -> r.DebugTests msgHandler xs
1010-
)
1011-
|> Promise.onSuccess (fun n ->
1012-
msgHandler |> report completedMsg
1013-
handleTestResults n
1014-
)
1015-
|> Promise.onFail (fun n ->
1016-
msgHandler |> report failedRunMsg
1017-
window.showErrorMessage (sprintf "Running test failed - %O" n)
1018-
|> ignore
1019-
()
1020-
)
1000+
let tests =
1001+
flattedTests ()
1002+
|> Seq.filter (fun t -> t.FileName = m.FileName)
1003+
|> Seq.map (fun test -> test.FullName.Trim( '"', ' ', '\\', '/'))
1004+
|> Seq.toList
1005+
1006+
let projectsWithTests = [ (proj, tests)]
1007+
1008+
msgHandler |> report startingMsg
1009+
runnerRegister.Values
1010+
|> Promise.collect (fun r ->
1011+
let prjsWithTsts = projectsWithTests |> List.filter (fun (p,_) -> r.ShouldProjectBeRun p)
1012+
match prjsWithTsts with
1013+
| [] -> Promise.lift []
1014+
| xs -> r.RunTests msgHandler xs
1015+
)
1016+
|> Promise.onSuccess (fun n ->
1017+
msgHandler |> report completedMsg
1018+
handleTestResults n
1019+
)
1020+
|> Promise.onFail (fun n ->
1021+
msgHandler |> report failedRunMsg
1022+
window.showErrorMessage (sprintf "Running test failed - %O" n)
1023+
|> ignore
1024+
()
1025+
)
1026+
)
1027+
)) |> context.subscriptions.Add
1028+
1029+
commands.registerCommand("neptune.debugFile", Func<obj, obj>(fun m ->
1030+
withProgress (fun msgHandler ->
1031+
reporter.sendTelemetryEvent "DebugFile/Activate" undefined undefined
1032+
let m = unbox<TreeModel> m
1033+
1034+
let proj = getProjectForFile m.FileName
1035+
1036+
match proj with
1037+
| None -> Promise.lift []
1038+
| Some proj ->
1039+
1040+
let tests =
1041+
flattedTests ()
1042+
|> Seq.filter (fun t -> t.FileName = m.FileName)
1043+
|> Seq.map (fun test -> test.FullName.Trim( '"', ' ', '\\', '/'))
1044+
|> Seq.toList
1045+
1046+
let projectsWithTests = [ (proj, tests)]
1047+
1048+
msgHandler |> report startingMsg
1049+
runnerRegister.Values
1050+
|> Promise.collect (fun r ->
1051+
let prjsWithTsts = projectsWithTests |> List.filter (fun (p,_) -> r.ShouldProjectBeRun p)
1052+
match prjsWithTsts with
1053+
| [] -> Promise.lift []
1054+
| xs -> r.RunTests msgHandler xs
1055+
)
1056+
|> Promise.onSuccess (fun n ->
1057+
msgHandler |> report completedMsg
1058+
handleTestResults n
1059+
)
1060+
|> Promise.onFail (fun n ->
1061+
msgHandler |> report failedRunMsg
1062+
window.showErrorMessage (sprintf "Running test failed - %O" n)
1063+
|> ignore
1064+
()
10211065
)
10221066
)
10231067
)) |> context.subscriptions.Add

0 commit comments

Comments
 (0)