sflkit 0.2.17__tar.gz → 0.2.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {sflkit-0.2.17/src/sflkit.egg-info → sflkit-0.2.18}/PKG-INFO +1 -1
  2. {sflkit-0.2.17 → sflkit-0.2.18}/pyproject.toml +1 -1
  3. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/__init__.py +1 -1
  4. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/config.py +14 -1
  5. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/instrumentation/__init__.py +4 -6
  6. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/instrumentation/dir_instrumentation.py +4 -3
  7. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/instrumentation/file_instrumentation.py +5 -4
  8. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/mapping.py +17 -9
  9. {sflkit-0.2.17 → sflkit-0.2.18/src/sflkit.egg-info}/PKG-INFO +1 -1
  10. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_config.py +1 -0
  11. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_instrumentation.py +15 -0
  12. {sflkit-0.2.17 → sflkit-0.2.18}/LICENSE +0 -0
  13. {sflkit-0.2.17 → sflkit-0.2.18}/README.md +0 -0
  14. {sflkit-0.2.17 → sflkit-0.2.18}/setup.cfg +0 -0
  15. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/__init__.py +0 -0
  16. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/analysis_type.py +0 -0
  17. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/analyzer.py +0 -0
  18. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/factory.py +0 -0
  19. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/mapping.py +0 -0
  20. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/predicate.py +0 -0
  21. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/similarity.py +0 -0
  22. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/spectra.py +0 -0
  23. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/analysis/suggestion.py +0 -0
  24. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/cli.py +0 -0
  25. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/color.py +0 -0
  26. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/__init__.py +0 -0
  27. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/extract.py +0 -0
  28. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/finder.py +0 -0
  29. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/language.py +0 -0
  30. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/meta.py +0 -0
  31. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/python/__init__.py +0 -0
  32. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/python/extract.py +0 -0
  33. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/python/factory.py +0 -0
  34. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/python/finder.py +0 -0
  35. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/python/visitor.py +0 -0
  36. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/language/visitor.py +0 -0
  37. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/logger.py +0 -0
  38. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/model/__init__.py +0 -0
  39. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/model/event_file.py +0 -0
  40. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/model/model.py +0 -0
  41. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/model/scope.py +0 -0
  42. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/runners/__init__.py +0 -0
  43. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit/runners/run.py +0 -0
  44. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit.egg-info/SOURCES.txt +0 -0
  45. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit.egg-info/dependency_links.txt +0 -0
  46. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit.egg-info/entry_points.txt +0 -0
  47. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit.egg-info/requires.txt +0 -0
  48. {sflkit-0.2.17 → sflkit-0.2.18}/src/sflkit.egg-info/top_level.txt +0 -0
  49. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_analysis_objects.py +0 -0
  50. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_cli.py +0 -0
  51. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_color.py +0 -0
  52. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_coverage.py +0 -0
  53. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_events.py +0 -0
  54. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_execution.py +0 -0
  55. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_language.py +0 -0
  56. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_predicates.py +0 -0
  57. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_runner.py +0 -0
  58. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_scope.py +0 -0
  59. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_spectra.py +0 -0
  60. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_suggestions.py +0 -0
  61. {sflkit-0.2.17 → sflkit-0.2.18}/tests/test_visitors.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sflkit
3
- Version: 0.2.17
3
+ Version: 0.2.18
4
4
  Summary: SFLKit: : A Workbench for Statistical Fault Localization
5
5
  Author-email: Marius Smytzek <marius.smytzek@cispa.de>
6
6
  Project-URL: Homepage, https://github.com/uds-se/sflkit/
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "sflkit"
10
- version = "0.2.17"
10
+ version = "0.2.18"
11
11
  authors = [
12
12
  { name = "Marius Smytzek", email = "marius.smytzek@cispa.de" },
13
13
  ]
@@ -8,7 +8,7 @@ from sflkit.instrumentation.dir_instrumentation import DirInstrumentation
8
8
 
9
9
 
10
10
  def instrument_config(conf: Config):
11
- instrumentation = DirInstrumentation(conf.visitor)
11
+ instrumentation = DirInstrumentation(conf.visitor, conf.mapping.path)
12
12
  instrumentation.instrument(
13
13
  conf.target_path,
14
14
  conf.instrument_working,
@@ -77,6 +77,7 @@ class Config:
77
77
  self.instrument_working = None
78
78
  self.runner = None
79
79
  self.mapping = None
80
+ self.mapping_path = None
80
81
  if path:
81
82
  if isinstance(path, configparser.ConfigParser):
82
83
  config = path
@@ -143,10 +144,12 @@ class Config:
143
144
  self.metrics = [Spectrum.Ochiai]
144
145
 
145
146
  run_id_generator = IDGenerator()
147
+ if "mapping" in events:
148
+ self.mapping_path = Path(events["mapping"])
146
149
  try:
147
150
  self.mapping = EventMapping.load(self)
148
151
  except InstrumentationError:
149
- self.mapping = EventMapping()
152
+ self.mapping = EventMapping(path=self.mapping_path)
150
153
  if "passing" in events:
151
154
  self.passing = self.get_event_files(
152
155
  list(csv.reader([events["passing"]]))[0],
@@ -198,6 +201,7 @@ class Config:
198
201
  visitor: ASTVisitor = None,
199
202
  passing: List[EventFile] = None,
200
203
  failing: List[EventFile] = None,
204
+ mapping: EventMapping = None,
201
205
  instrument_include: List[str] = None,
202
206
  instrument_exclude: List[str] = None,
203
207
  instrument_working: str = None,
@@ -220,6 +224,10 @@ class Config:
220
224
  conf.instrument_exclude = instrument_exclude if instrument_exclude else list()
221
225
  conf.instrument_working = instrument_working
222
226
  conf.runner = runner
227
+ if mapping:
228
+ conf.mapping = mapping
229
+ if mapping.path:
230
+ conf.mapping_path = mapping.path
223
231
  return conf
224
232
 
225
233
  @staticmethod
@@ -263,6 +271,7 @@ class Config:
263
271
  metrics=None,
264
272
  passing=None,
265
273
  failing=None,
274
+ mapping_path=None,
266
275
  working=None,
267
276
  include=None,
268
277
  exclude=None,
@@ -288,6 +297,8 @@ class Config:
288
297
  conf["events"]["passing"] = passing
289
298
  if failing:
290
299
  conf["events"]["failing"] = failing
300
+ if mapping_path:
301
+ conf["events"]["mapping"] = mapping_path
291
302
  if working:
292
303
  conf["instrumentation"]["path"] = working
293
304
  if include:
@@ -320,6 +331,8 @@ class Config:
320
331
  conf["events"]["passing"] = ",".join(e.path for e in self.passing)
321
332
  if self.failing:
322
333
  conf["events"]["failing"] = ",".join(e.path for e in self.failing)
334
+ if self.mapping_path:
335
+ conf["events"]["mapping"] = str(self.mapping_path)
323
336
  if self.instrument_working:
324
337
  conf["instrumentation"]["path"] = str(self.instrument_working)
325
338
  if self.instrument_include:
@@ -1,8 +1,6 @@
1
- import json
2
1
  from abc import abstractmethod
3
- from typing import List
4
-
5
- from sflkitlib.events import event
2
+ from pathlib import Path
3
+ from typing import List, Optional
6
4
 
7
5
  from sflkit import Config
8
6
  from sflkit.language.visitor import ASTVisitor
@@ -10,9 +8,9 @@ from sflkit.mapping import EventMapping
10
8
 
11
9
 
12
10
  class Instrumentation:
13
- def __init__(self, visitor: ASTVisitor):
11
+ def __init__(self, visitor: ASTVisitor, mapping_path: Optional[Path] = None):
14
12
  self.visitor = visitor
15
- self.events = EventMapping()
13
+ self.events = EventMapping(path=mapping_path)
16
14
 
17
15
  @abstractmethod
18
16
  def instrument(
@@ -2,6 +2,7 @@ import os
2
2
  import queue
3
3
  import re
4
4
  import shutil
5
+ from pathlib import Path
5
6
  from typing import List, Optional, Iterable, Tuple
6
7
 
7
8
  from sflkit.instrumentation import Instrumentation
@@ -11,9 +12,9 @@ from sflkit.logger import LOGGER
11
12
 
12
13
 
13
14
  class DirInstrumentation(Instrumentation):
14
- def __init__(self, visitor: ASTVisitor):
15
- super().__init__(visitor)
16
- self.file_instrumentation = FileInstrumentation(visitor)
15
+ def __init__(self, visitor: ASTVisitor, mapping_path: Optional[Path] = None):
16
+ super().__init__(visitor, mapping_path)
17
+ self.file_instrumentation = FileInstrumentation(visitor, mapping_path)
17
18
 
18
19
  @staticmethod
19
20
  def check_included(element: str, includes: Optional[Iterable[str]]):
@@ -1,4 +1,5 @@
1
- from typing import List
1
+ from pathlib import Path
2
+ from typing import List, Optional
2
3
 
3
4
  from sflkit.instrumentation import Instrumentation
4
5
  from sflkit.language.visitor import ASTVisitor
@@ -6,13 +7,13 @@ from sflkit.mapping import EventMapping
6
7
 
7
8
 
8
9
  class FileInstrumentation(Instrumentation):
9
- def __init__(self, visitor: ASTVisitor):
10
- super().__init__(visitor)
10
+ def __init__(self, visitor: ASTVisitor, mapping_path: Optional[Path] = None):
11
+ super().__init__(visitor, mapping_path)
11
12
 
12
13
  def instrument(
13
14
  self, src: str, dst: str, suffixes: List[str] = None, file: str = ""
14
15
  ):
15
16
  self.visitor.instrument(src, dst, file)
16
17
  self.events = EventMapping(
17
- {event.event_id: event for event in self.visitor.events}
18
+ {event.event_id: event for event in self.visitor.events}, self.events.path
18
19
  )
@@ -13,37 +13,45 @@ class InstrumentationError(RuntimeError):
13
13
 
14
14
 
15
15
  class EventMapping:
16
- def __init__(self, mapping: Dict[int, Event] = None):
16
+ def __init__(
17
+ self, mapping: Dict[int, Event] = None, path: Optional[os.PathLike] = None
18
+ ):
17
19
  self.mapping = mapping or dict()
20
+ self.path = path
18
21
 
19
22
  def get(self, event_id) -> Optional[Event]:
20
23
  return self.mapping.get(event_id, None)
21
24
 
22
25
  @staticmethod
23
- def get_path(identifier: str):
26
+ def get_path(identifier: str) -> Path:
24
27
  return SFLKIT_PATH / f"{identifier}.json"
25
28
 
26
29
  @staticmethod
27
30
  def load(config: Any):
28
31
  if not hasattr(config, "identifier"):
29
32
  raise InstrumentationError(f"Argument does not have an identifier")
30
- return EventMapping.load_from_file(config.identifier())
33
+ return EventMapping.load_from_file(
34
+ config.mapping_path or EventMapping.get_path(config.identifier()),
35
+ config.target_path,
36
+ )
31
37
 
32
38
  @staticmethod
33
- def load_from_file(identifier: str):
34
- file = EventMapping.get_path(identifier)
39
+ def load_from_file(file: Path, path: os.PathLike):
35
40
  if file.exists():
36
- return EventMapping(load_json(file))
41
+ return EventMapping(load_json(file), file)
37
42
  else:
38
43
  raise InstrumentationError(
39
- f"Cannot find information about instrumentation of {identifier or file}"
44
+ f"Cannot find information about instrumentation of {path or file}"
40
45
  )
41
46
 
42
47
  def write(self, config):
43
48
  if not hasattr(config, "identifier"):
44
49
  raise InstrumentationError(f"Argument does not have an identifier")
45
- SFLKIT_PATH.mkdir(parents=True, exist_ok=True)
46
- file = self.get_path(config.identifier())
50
+ if self.path:
51
+ file = self.path
52
+ else:
53
+ SFLKIT_PATH.mkdir(parents=True, exist_ok=True)
54
+ file = self.get_path(config.identifier())
47
55
  with file.open("w") as fp:
48
56
  json.dump(list(self.mapping.values()), fp, cls=EventEncoder)
49
57
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sflkit
3
- Version: 0.2.17
3
+ Version: 0.2.18
4
4
  Summary: SFLKit: : A Workbench for Statistical Fault Localization
5
5
  Author-email: Marius Smytzek <marius.smytzek@cispa.de>
6
6
  Project-URL: Homepage, https://github.com/uds-se/sflkit/
@@ -93,6 +93,7 @@ class ConfigTests(unittest.TestCase):
93
93
  config.visitor,
94
94
  config.passing,
95
95
  config.failing,
96
+ config.mapping,
96
97
  config.instrument_include,
97
98
  config.instrument_exclude,
98
99
  config.instrument_working,
@@ -106,6 +106,21 @@ class TestInstrumentation(BaseTest):
106
106
  )
107
107
  )
108
108
 
109
+ def test_mapping_output(self):
110
+ instrument_config(
111
+ Config.create(
112
+ path=os.path.join(BaseTest.TEST_RESOURCES, "test_instrumentation"),
113
+ language="python",
114
+ events="line",
115
+ predicates="line",
116
+ working=BaseTest.TEST_DIR,
117
+ mapping_path="mapping.json",
118
+ )
119
+ )
120
+ mapping = Path("mapping.json")
121
+ self.assertTrue(mapping.exists())
122
+ self.assertTrue(mapping.is_file())
123
+
109
124
 
110
125
  class TestLib(BaseTest):
111
126
  @classmethod
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes