@@ -4,7 +4,7 @@ import os from "os";
4
4
5
5
import * as vscode from "vscode" ;
6
6
import sinon from "sinon" ;
7
- import { afterEach , beforeEach } from "mocha" ;
7
+ import { after , afterEach , before , beforeEach } from "mocha" ;
8
8
9
9
import { StreamingRunner } from "../../streamingRunner" ;
10
10
@@ -13,6 +13,26 @@ import { CONTEXT } from "./helpers";
13
13
suite ( "StreamingRunner" , ( ) => {
14
14
let sandbox : sinon . SinonSandbox ;
15
15
const tempDirUri = vscode . Uri . file ( path . join ( os . tmpdir ( ) , "ruby-lsp" ) ) ;
16
+ const dbUri = vscode . Uri . joinPath ( tempDirUri , "test_reporter_port_db.json" ) ;
17
+ let currentDbContents : string | undefined ;
18
+
19
+ before ( async ( ) => {
20
+ try {
21
+ const buffer = await vscode . workspace . fs . readFile ( dbUri ) ;
22
+ currentDbContents = buffer . toString ( ) ;
23
+ } catch {
24
+ // Do nothing
25
+ }
26
+ } ) ;
27
+
28
+ after ( async ( ) => {
29
+ if ( currentDbContents ) {
30
+ await vscode . workspace . fs . writeFile (
31
+ dbUri ,
32
+ Buffer . from ( currentDbContents ) ,
33
+ ) ;
34
+ }
35
+ } ) ;
16
36
17
37
beforeEach ( async ( ) => {
18
38
await vscode . workspace . fs . createDirectory ( tempDirUri ) ;
@@ -25,7 +45,6 @@ suite("StreamingRunner", () => {
25
45
} ) ;
26
46
27
47
test ( "updates port DB with new values" , async ( ) => {
28
- const dbUri = vscode . Uri . joinPath ( tempDirUri , "test_reporter_port_db.json" ) ;
29
48
const initialDb = {
30
49
// eslint-disable-next-line @typescript-eslint/naming-convention
31
50
"/some/path/to/project" : "1234" ,
0 commit comments