MCPcopy Create free account
hub / github.com/nodejs/node / _get_resources_for_file

Method _get_resources_for_file

deps/v8/tools/testrunner/objects/testcase.py:588–619  ·  view source on GitHub ↗

Returns for a given file a list of absolute paths of files needed by the given file.

(self, file)

Source from the content-addressed store, hash-verified

586 return self.processor.name
587
588 def _get_resources_for_file(self, file):
589 """Returns for a given file a list of absolute paths of files needed by the
590 given file.
591 """
592 source = read_file(file)
593 result = []
594 def add_path(path):
595 result.append(Path(path).resolve())
596 def add_import_path(import_path):
597 add_path(file.parent / import_path)
598 def strip_test262_frontmatter(input):
599 return TEST262_FRONTMATTER_PATTERN.sub('', input)
600 for match in RESOURCES_PATTERN.finditer(source):
601 # There are several resources per line. Relative to base dir.
602 for path in match.group(1).strip().split():
603 add_path(path)
604 # Strip test262 frontmatter before looking for load() and import/export
605 # statements.
606 source = strip_test262_frontmatter(source)
607 for match in LOAD_PATTERN.finditer(source):
608 # Files in load statements are relative to base dir.
609 add_path(match.group(1))
610 # Imported files are relative to the file importing them.
611 for match in MODULE_FROM_RESOURCES_PATTERN.finditer(source):
612 add_import_path(match.group(1))
613 for match in MODULE_IMPORT_RESOURCES_PATTERN.finditer(source):
614 add_import_path(match.group(1))
615 for match in MODULE_IMPORT_SOURCE_RESOURCES_PATTERN.finditer(source):
616 add_import_path(match.group(1))
617 for match in SHADOWREALM_IMPORTVALUE_RESOURCES_PATTERN.finditer(source):
618 add_import_path(match.group(1))
619 return result
620
621 def get_android_resources(self):
622 """Returns a list of absolute paths with additional files needed by the

Callers 1

get_android_resourcesMethod · 0.95

Calls 2

read_fileFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected