ScriptCollection 4.4.7__py3-none-any.whl → 4.4.9__py3-none-any.whl

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.
@@ -39,7 +39,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
39
39
  from .ProgramRunnerPopen import ProgramRunnerPopen
40
40
  from .SCLog import SCLog, LogLevel
41
41
 
42
- version = "4.4.7"
42
+ version = "4.4.9"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -80,7 +80,6 @@ class TFCPS_CodeUnitSpecific_Go_Functions(TFCPS_CodeUnitSpecific_Base):
80
80
  @GeneralUtilities.check_arguments
81
81
  def run_testcases(self) -> None:
82
82
  codeunit_name = self.get_codeunit_name()
83
- go_module_folder = self.get_go_module_folder()
84
83
  coverprofile_file = os.path.join(GeneralUtilities.get_temp_folder(), f"{codeunit_name}.coverprofile")
85
84
  GeneralUtilities.ensure_file_does_not_exist(coverprofile_file)
86
85
  coverage_file = os.path.join(self.get_artifacts_folder(), "TestCoverage", "TestCoverage.xml")
@@ -270,6 +270,19 @@ class TFCPS_CodeUnitSpecific_Base(ABC):
270
270
  shutil.copyfile(source_version_file, target_version_file)
271
271
 
272
272
 
273
+ @staticmethod
274
+ @GeneralUtilities.check_arguments
275
+ def __docfx_configuration_declares_metadata(docfx_configuration_file: str) -> bool:
276
+ # States whether the given docfx-configuration declares something to generate metadata from. The metadata-step is
277
+ # only executed in that case, because docfx aborts with a NullReferenceException when the "metadata"-section is
278
+ # missing, while the default-command tolerates its absence. A codeunit which is not implemented in a language docfx
279
+ # can read (a python- or a docker-codeunit for example) has no such section.
280
+ # The trailing commas are removed before the content is parsed: docfx accepts them, but they are not valid json, so
281
+ # without removing them a configuration which docfx itself reads without complaining would be rejected here.
282
+ content: str = GeneralUtilities.read_text_from_file(docfx_configuration_file)
283
+ content_without_trailing_commas: str = re.sub(r",(\s*[}\]])", r"\1", content)
284
+ return 0 < len(json.loads(content_without_trailing_commas).get("metadata", []))
285
+
273
286
  @GeneralUtilities.check_arguments
274
287
  def generate_reference_using_docfx(self, generate_class_reference:bool=False):
275
288
  reference_folder =os.path.join( self.get_codeunit_folder(),"Other","Reference")
@@ -283,7 +296,17 @@ class TFCPS_CodeUnitSpecific_Base(ABC):
283
296
  GeneralUtilities.ensure_directory_exists(generated_reference_folder)
284
297
  obj_folder = os.path.join(reference_folder, "obj")
285
298
  GeneralUtilities.ensure_folder_exists_and_is_empty(obj_folder)
286
- self._protected_sc.run_program("docfx", "-t default,templates/darkfx docfx.json", reference_folder)
299
+ # The metadata-step and the build-step are executed separately instead of using the default-command which runs both
300
+ # of them at once, because only the metadata-command accepts "--property". That property is required because docfx
301
+ # restores the project before it reads it (which is what its option "--noRestore" switches off): that restore does
302
+ # not know the name of the lock-file which belongs to the runtime the build restored for, so it would write one
303
+ # under the default-name besides them (see
304
+ # TFCPS_CodeUnitSpecific_DotNet.__get_arguments_which_prevent_writing_a_lock_file). The restore itself is kept
305
+ # (instead of passing "--noRestore"), because the reference of a codeunit can also be generated on its own, without
306
+ # a build before it.
307
+ if self.__docfx_configuration_declares_metadata(os.path.join(reference_folder, "docfx.json")):
308
+ self._protected_sc.run_program("docfx", "metadata docfx.json --property RestorePackagesWithLockFile=false", reference_folder)
309
+ self._protected_sc.run_program("docfx", "build -t default,templates/darkfx docfx.json", reference_folder)
287
310
  GeneralUtilities.ensure_directory_does_not_exist(obj_folder)
288
311
 
289
312
  if generate_class_reference:# this codeunit has a class-reference, so a human-readable table-of-content can be generated for it
@@ -43,6 +43,13 @@ class TFCPS_VisualRegressionTests:
43
43
  # beginning of every run.
44
44
  __test_results_folder_relative_path: str = "Other/Artifacts/VisualRegressionTestResults"
45
45
 
46
+ # The file which maps a domain to an address inside a container. It belongs to the container which owns the
47
+ # network-namespace, so the playwright-container uses the one of this container when it joins it.
48
+ __hosts_file: str = "/etc/hosts"
49
+
50
+ # The address the application under test listens on when it was started by this process.
51
+ __loopback_address: str = "127.0.0.1"
52
+
46
53
  # The folder the screenshots of failed testcases are preserved in. Both folders are located in
47
54
  # "Other/Artifacts", which is ignored by git.
48
55
  __failed_testcases_folder_relative_path: str = "Other/Artifacts/VisualRegressionTestFailures"
@@ -325,14 +332,38 @@ class TFCPS_VisualRegressionTests:
325
332
  # loopback-interface of that container. Sharing its network-namespace is the only way to reach it:
326
333
  # its ports are not published to the host, and publishing them would additionally make two parallel
327
334
  # builds on the same host collide with each other.
328
- address_of_application: str = "127.0.0.1"
335
+ # The domain can not be passed as "--add-host" in this case: a container which joins the
336
+ # network-namespace of another one uses the hosts-file of that other container and therefore can not
337
+ # have entries of its own, which docker refuses with "conflicting options: custom host-to-IP mapping
338
+ # and the network mode". The mapping is therefore written into the hosts-file of this container, which
339
+ # the playwright-container sees through exactly that sharing.
340
+ self.__ensure_domain_is_mapped_in_the_own_hosts_file(domain_of_application)
329
341
  result: list[str] = ["--network", f"container:{self.__get_own_container_id()}"]
330
342
  else:
331
343
  # The application runs directly on the host of the container, which docker makes reachable under the
332
- # address "host-gateway".
333
- address_of_application: str = "host-gateway"
334
- result: list[str] = []
335
- return result+["--add-host", f"{domain_of_application}:{address_of_application}", "-e", f"{self.__environment_variable_name_of_application_host}={domain_of_application}"]
344
+ # address "host-gateway". The playwright-container has a hosts-file of its own in this case, so the
345
+ # mapping can be passed as an argument.
346
+ result: list[str] = ["--add-host", f"{domain_of_application}:host-gateway"]
347
+ return result+["-e", f"{self.__environment_variable_name_of_application_host}={domain_of_application}"]
348
+
349
+ @GeneralUtilities.check_arguments
350
+ def __ensure_domain_is_mapped_in_the_own_hosts_file(self, domain_of_application: str) -> None:
351
+ """Maps the given domain to the loopback-interface in the hosts-file of the container this process runs in.
352
+
353
+ The playwright-container joins the network-namespace of this container and therefore uses its hosts-file, so
354
+ this is the only place where the mapping can be put for the browser to resolve the domain.
355
+ The mapping is appended instead of the file being rewritten, because the file is a bind-mount of the
356
+ docker-daemon (which is also how __get_own_container_id recognizes the own container): replacing it would
357
+ break that mount and the mapping would not reach the playwright-container.
358
+ A mapping which is already there is not appended a second time, so that the runs for the further browsers of
359
+ the codeunit do not add it again."""
360
+ for line in GeneralUtilities.read_text_from_file(self.__hosts_file).splitlines():
361
+ # Everything behind a "#" is a comment, and a line maps its first field (the address) to all further
362
+ # fields (the names it is reachable under).
363
+ fields: list[str] = line.split("#", 1)[0].split()
364
+ if 1 < len(fields) and fields[0] == self.__loopback_address and domain_of_application in fields[1:]:
365
+ return
366
+ GeneralUtilities.append_line_to_file(self.__hosts_file, f"{self.__loopback_address}\t{domain_of_application}")
336
367
 
337
368
  @GeneralUtilities.check_arguments
338
369
  def __get_mount_arguments(self, codeunit_folder: str, codeunit_folder_in_container: str, playwright_project_folder_relative_path: str) -> list[str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.4.7
3
+ Version: 4.4.9
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=ot9Ib-plQ8wejR9M2XXfnx6GR-va9k8SH1gAC5kjaJ0,5123
11
11
  ScriptCollection/SCLog.py,sha256=Fjf8Pdi63cXHGMxL_aI6A0dwGm7QIfrv3czjvpSUlaM,4705
12
- ScriptCollection/ScriptCollectionCore.py,sha256=4IN5E65UNrDvVHGsY3_sJwvQDG8KD6CT8P-GncKGCnU,261810
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=rldvIi9zD5BgzRFqgmou-1P0alxEEouWky3w-PV46Pw,261810
13
13
  ScriptCollection/TestKind.py,sha256=EBTLR8yBz5VmWA2NZIpDTbQNg6tkfv_kAsIzEJ--mCI,1756
14
14
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
15
15
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -37,7 +37,7 @@ ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz
37
37
  ScriptCollection/TFCPS/PackageSource.py,sha256=tQoMbxrIbV3mYHKH2wgOoGzIHY1TvBH8EAFpWGhryrQ,1311
38
38
  ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=rpuwSsQ6YQfZS2LGnvOH5ql8zs_-cHU4LQttS7XNT60,11272
39
39
  ScriptCollection/TFCPS/TFCPS_BuildCodeUnitsHook.py,sha256=67_DQwoH5bhxxSmwtuAeoW1NOCMiLMzOy48OqlJX-KY,1744
40
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=ahRpBESHO9CMqjy6jGFTiPluUmt9biHlO6Wa0VEftJw,36835
40
+ ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=N6hOkfts6g61dhrQyrWx64Nxe0nInMtzyVNKyqHvUfk,38992
41
41
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Mj9t1SyRpkYZE74cLsGWYv4xB89gXL2ld-RX3xvvGdw,9835
42
42
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=PHu13UCn3xj3UBneGk5DDkYZ9iGdJ80IKIte3ewwKfI,49143
43
43
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=kpEmSnfzfgB4OjcCuS_X6jgW_ftcphxEnjjoLoAHTLY,6582
@@ -48,7 +48,7 @@ ScriptCollection/TFCPS/TFCPS_OCIImageSecretScan.py,sha256=rhw0glr4gZ5enG9faOD51x
48
48
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=XLVsFTA1jvfDbZ7wYJgIdEByZhF_bYVbA5jkisuvK4k,2322
49
49
  ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=Z8Gw-j5I7VPafHEsVeQJ2gTTKVLAnnhwZhY8IVTi2Qk,11867
50
50
  ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=6oi5vdng6wMx2inbj8KTwIFOPvZAO4ekIVLQcq4pZ9Y,162988
51
- ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py,sha256=iTsgZgUGeJMpFgYC8NDMep7xb0Ad53VXlrA2Q1gD6rs,34565
51
+ ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py,sha256=6_63udxHnPlu_TMk_ftLZTnzriJO8MCxVCVAsweZqHs,37073
52
52
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=919mNfzVRurTJhWi8WV0oEAFoH-yd4a6m2Rbxcf2oZ4,19927
54
54
  ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -59,7 +59,7 @@ ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=9KUJLrYqEX
59
59
  ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=cAE_OFJBU0M3L2Ov5PUUMH7aOVVzKtnKlFoXSw43fng,8759
61
61
  ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
- ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py,sha256=zhFvSA60sZq2s1cI9zDa-vhnQqtiICr2-pX1nUtJz8c,9067
62
+ ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py,sha256=m4Pax-U6o5XuspLnLfnWjyQMtoC7zBDDNJW9EhLWjeE,9012
63
63
  ScriptCollection/TFCPS/Go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  ScriptCollection/TFCPS/Maven/TFCPS_CodeUnitSpecific_Maven.py,sha256=HDZlU70lF4nxUgsi7-TaFrFpbw_imw6dBagfgL6tDW8,10593
65
65
  ScriptCollection/TFCPS/Maven/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -71,8 +71,8 @@ ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=yyjWPMHQjPLkML
71
71
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  ScriptCollection/TFCPS/TypeScript/TFCPS_CodeUnitSpecific_TypeScript.py,sha256=5z990qyO5durX07xRWRwju1hl6wpjQAy2f-yRwJ-7s0,11856
73
73
  ScriptCollection/TFCPS/TypeScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- scriptcollection-4.4.7.dist-info/METADATA,sha256=5y2_0Sm-72umOq5J_sIxlr1jUHBkojCPxY12-H_NfEY,7647
75
- scriptcollection-4.4.7.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
- scriptcollection-4.4.7.dist-info/entry_points.txt,sha256=Aj6CHuJxASMe52fK_O6-bNJ_uhxcDb-AgRxFOeTojyE,6069
77
- scriptcollection-4.4.7.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
- scriptcollection-4.4.7.dist-info/RECORD,,
74
+ scriptcollection-4.4.9.dist-info/METADATA,sha256=h2-_3VwdzABZM0Qyi5VJvL_Ret6DA_KiVFyDzpd6MXo,7647
75
+ scriptcollection-4.4.9.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
+ scriptcollection-4.4.9.dist-info/entry_points.txt,sha256=Aj6CHuJxASMe52fK_O6-bNJ_uhxcDb-AgRxFOeTojyE,6069
77
+ scriptcollection-4.4.9.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
+ scriptcollection-4.4.9.dist-info/RECORD,,