1
- // tslint:disable:interface-name no-any max-func-body-length estrict-plus-operands
1
+ // tslint:disable:interface-name no-any max-func-body-length estrict-plus-operands no-empty
2
2
3
3
import * as assert from 'assert' ;
4
4
import * as fs from 'fs-extra' ;
@@ -10,12 +10,12 @@ import { getTextEditsFromPatch } from '../../client/common/editor';
10
10
import { extractMethod } from '../../client/providers/simpleRefactorProvider' ;
11
11
import { RefactorProxy } from '../../client/refactor/proxy' ;
12
12
import { UnitTestIocContainer } from '../unittests/serviceRegistry' ;
13
- import { closeActiveWindows , initialize , initializeTest , wait } from './../initialize' ;
13
+ import { closeActiveWindows , initialize , initializeTest } from './../initialize' ;
14
14
import { MockOutputChannel } from './../mockClasses' ;
15
15
16
16
const EXTENSION_DIR = path . join ( __dirname , '..' , '..' , '..' ) ;
17
17
const refactorSourceFile = path . join ( __dirname , '..' , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'refactoring' , 'standAlone' , 'refactor.py' ) ;
18
- const refactorTargetFile = path . join ( __dirname , '..' , '..' , '..' , 'out' , 'test' , 'pythonFiles' , 'refactoring' , 'standAlone' , 'refactor.py ') ;
18
+ const refactorTargetFileDir = path . join ( __dirname , '..' , '..' , '..' , 'out' , 'test' , 'pythonFiles' , 'refactoring' , 'standAlone' ) ;
19
19
20
20
interface RenameResponse {
21
21
results : [ { diff : string } ] ;
@@ -25,31 +25,27 @@ suite('Method Extraction', () => {
25
25
// Hack hac hack
26
26
const oldExecuteCommand = vscode . commands . executeCommand ;
27
27
const options : vscode . TextEditorOptions = { cursorStyle : vscode . TextEditorCursorStyle . Line , insertSpaces : true , lineNumbers : vscode . TextEditorLineNumbersStyle . Off , tabSize : 4 } ;
28
-
28
+ let refactorTargetFile = '' ;
29
29
let ioc : UnitTestIocContainer ;
30
- suiteSetup ( async ( ) => {
31
- fs . copySync ( refactorSourceFile , refactorTargetFile , { overwrite : true } ) ;
32
- await initialize ( ) ;
33
- initializeDI ( ) ;
34
- } ) ;
30
+ suiteSetup ( initialize ) ;
35
31
suiteTeardown ( ( ) => {
36
32
vscode . commands . executeCommand = oldExecuteCommand ;
37
33
return closeActiveWindows ( ) ;
38
34
} ) ;
39
35
setup ( async ( ) => {
40
- if ( fs . existsSync ( refactorTargetFile ) ) {
41
- await wait ( 500 ) ;
42
- fs . unlinkSync ( refactorTargetFile ) ;
43
- }
36
+ initializeDI ( ) ;
37
+ refactorTargetFile = path . join ( refactorTargetFileDir , `refactor${ new Date ( ) . getTime ( ) } .py` ) ;
44
38
fs . copySync ( refactorSourceFile , refactorTargetFile , { overwrite : true } ) ;
45
39
await initializeTest ( ) ;
46
40
( < any > vscode ) . commands . executeCommand = ( cmd ) => Promise . resolve ( ) ;
47
41
} ) ;
48
- teardown ( ( ) => {
42
+ teardown ( async ( ) => {
49
43
vscode . commands . executeCommand = oldExecuteCommand ;
50
- return closeActiveWindows ( ) ;
44
+ try {
45
+ await fs . unlink ( refactorTargetFile ) ;
46
+ } catch { }
47
+ await closeActiveWindows ( ) ;
51
48
} ) ;
52
-
53
49
function initializeDI ( ) {
54
50
ioc = new UnitTestIocContainer ( ) ;
55
51
ioc . registerCommonTypes ( ) ;
0 commit comments