File tree Expand file tree Collapse file tree 6 files changed +16
-10
lines changed Expand file tree Collapse file tree 6 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,11 @@ def scan():
42
42
config = ConfigurationLoader .load ()
43
43
set_logging_options (config )
44
44
45
- cache_manager = cache .get_default ()
46
-
47
45
api = build_api (config )
48
46
check_version (api )
49
47
update_config_with_api_urls (config , api .base_urls )
50
48
49
+ cache_manager = cache .get_cache (config )
51
50
scanner = create_scanner_engine (api , cache_manager , config )
52
51
53
52
return scanner .run (config )
Original file line number Diff line number Diff line change 23
23
from dataclasses import dataclass
24
24
25
25
from pysonar_scanner import utils
26
+ from pysonar_scanner .configuration .properties import SONAR_USER_HOME
26
27
27
28
OpenBinaryMode = typing .Literal ["wb" , "xb" ]
28
29
@@ -68,5 +69,9 @@ def create_cache(cache_folder: pathlib.Path):
68
69
return Cache (cache_folder )
69
70
70
71
71
- def get_default () -> Cache :
72
- return Cache .create_cache (pathlib .Path .home () / ".sonar-scanner/cache" )
72
+ def get_cache (config ) -> Cache :
73
+ if SONAR_USER_HOME in config :
74
+ cache_folder = pathlib .Path (config [SONAR_USER_HOME ]) / "cache"
75
+ else :
76
+ cache_folder = pathlib .Path .home () / ".sonar/cache"
77
+ return Cache .create_cache (cache_folder )
Original file line number Diff line number Diff line change 19
19
#
20
20
import contextlib
21
21
from typing import Optional
22
+
22
23
from pysonar_scanner import utils
23
24
from pysonar_scanner .api import JRE , BaseUrls , SonarQubeApi
24
25
import responses
Original file line number Diff line number Diff line change 23
23
24
24
from pysonar_scanner .cache import Cache , CacheFile
25
25
import pysonar_scanner .cache as cache
26
+ from pysonar_scanner .configuration .properties import SONAR_USER_HOME
26
27
27
28
28
29
class TestCacheFile (unittest .TestCase ):
@@ -52,7 +53,10 @@ def test_get_file(self):
52
53
self .assertEqual (cache_file .checksum , "123" )
53
54
54
55
def test_get_default (self ):
55
- self .assertEqual (cache .get_default ().cache_folder , pathlib .Path .home () / ".sonar-scanner/cache" )
56
+ self .assertEqual (cache .get_cache ({}).cache_folder , pathlib .Path .home () / ".sonar/cache" )
57
+
58
+ def test_uses_user_home (self ):
59
+ self .assertEqual (cache .get_cache ({SONAR_USER_HOME : "my/home" }).cache_folder , pathlib .Path ("my/home" ) / "cache" )
56
60
57
61
def test_exists (self ):
58
62
cache = Cache .create_cache (pathlib .Path ("/folder1/folder2/" ))
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class TestJREProvisioner(pyfakefs.TestCase):
45
45
def setUp (self ):
46
46
self .setUpPyfakefs (allow_root_user = False )
47
47
48
- self .cache = cache .get_default ( )
48
+ self .cache = cache .get_cache ({} )
49
49
self .api = sq_api_utils .get_sq_server ()
50
50
51
51
self .__setup_zip_file ()
Original file line number Diff line number Diff line change 29
29
30
30
from pysonar_scanner import cache
31
31
from pysonar_scanner import scannerengine
32
- from pysonar_scanner .api import SQVersion
33
- from pysonar_scanner .exceptions import ChecksumException , SQTooOldException
34
- from pysonar_scanner .jre import JREResolvedPath , JREResolver
32
+ from pysonar_scanner .exceptions import ChecksumException
35
33
from pysonar_scanner .scannerengine import (
36
34
LogLine ,
37
- ScannerEngine ,
38
35
ScannerEngineProvisioner ,
39
36
default_log_line_listener ,
40
37
)
You can’t perform that action at this time.
0 commit comments