|
36 | 36 | from scanpipe.models import CodebaseResource |
37 | 37 | from scanpipe.models import Project |
38 | 38 | from scanpipe.pipes import d2d |
| 39 | +from scanpipe.pipes import d2d_config |
39 | 40 | from scanpipe.pipes import flag |
40 | 41 | from scanpipe.pipes import scancode |
41 | 42 | from scanpipe.pipes.input import copy_input |
@@ -1531,6 +1532,51 @@ def test_scanpipe_pipes_d2d_map_go_paths(self): |
1531 | 1532 | ).count(), |
1532 | 1533 | ) |
1533 | 1534 |
|
| 1535 | + def test_scanpipe_pipes_d2d_map_ruby(self): |
| 1536 | + input_dir = self.project1.input_path |
| 1537 | + input_resources = [ |
| 1538 | + self.data / "d2d-ruby/to-sentry-delayed_job-5.22.1.gem", |
| 1539 | + self.data / "d2d-ruby/from-sentry-ruby-5.22.1.zip", |
| 1540 | + ] |
| 1541 | + copy_inputs(input_resources, input_dir) |
| 1542 | + self.from_files, self.to_files = d2d.get_inputs(self.project1) |
| 1543 | + inputs_with_codebase_path_destination = [ |
| 1544 | + (self.from_files, self.project1.codebase_path / d2d.FROM), |
| 1545 | + (self.to_files, self.project1.codebase_path / d2d.TO), |
| 1546 | + ] |
| 1547 | + for input_files, codebase_path in inputs_with_codebase_path_destination: |
| 1548 | + for input_file_path in input_files: |
| 1549 | + scancode.extract_archive(input_file_path, codebase_path) |
| 1550 | + |
| 1551 | + scancode.extract_archives( |
| 1552 | + self.project1.codebase_path, |
| 1553 | + recurse=True, |
| 1554 | + ) |
| 1555 | + pipes.collect_and_create_codebase_resources(self.project1) |
| 1556 | + buffer = io.StringIO() |
| 1557 | + d2d.map_checksum( |
| 1558 | + project=self.project1, checksum_field="sha1", logger=buffer.write |
| 1559 | + ) |
| 1560 | + ruby_config = d2d_config.get_ecosystem_config(ecosystem="Ruby") |
| 1561 | + d2d.ignore_unmapped_resources_from_config( |
| 1562 | + project=self.project1, |
| 1563 | + patterns_to_ignore=ruby_config.deployed_resource_path_exclusions, |
| 1564 | + logger=buffer.write, |
| 1565 | + ) |
| 1566 | + d2d.flag_undeployed_resources(project=self.project1) |
| 1567 | + self.assertEqual( |
| 1568 | + 39, |
| 1569 | + CodebaseRelation.objects.filter( |
| 1570 | + project=self.project1, map_type="sha1" |
| 1571 | + ).count(), |
| 1572 | + ) |
| 1573 | + self.assertEqual( |
| 1574 | + 0, |
| 1575 | + CodebaseResource.objects.filter( |
| 1576 | + project=self.project1, status="requires-review" |
| 1577 | + ).count(), |
| 1578 | + ) |
| 1579 | + |
1534 | 1580 | @skipIf(sys.platform == "darwin", "Test is failing on macOS") |
1535 | 1581 | def test_scanpipe_pipes_d2d_map_rust_symbols(self): |
1536 | 1582 | input_dir = self.project1.input_path |
|
0 commit comments