... |
... |
@@ -616,3 +616,82 @@ def test_mirror_junction_from_includes(cli, tmpdir, datafiles, kind): |
616
|
616
|
os.rename('{}.bak'.format(upstream_repo.repo), upstream_repo.repo)
|
617
|
617
|
result = cli.run(project=project_dir, args=['fetch', element_name])
|
618
|
618
|
result.assert_success()
|
|
619
|
+
|
|
620
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
621
|
+def test_mirror_git_submodule_fetch(cli, tmpdir, datafiles):
|
|
622
|
+ # Test that it behaves as expected with submodules, both defined in config
|
|
623
|
+ # and discovered when fetching.
|
|
624
|
+ foo_file = os.path.join(str(datafiles), 'files', 'foo')
|
|
625
|
+ bar_file = os.path.join(str(datafiles), 'files', 'bar')
|
|
626
|
+ bin_files_path = os.path.join(str(datafiles), 'files', 'bin-files', 'usr')
|
|
627
|
+ dev_files_path = os.path.join(str(datafiles), 'files', 'dev-files', 'usr')
|
|
628
|
+ mirror_dir = os.path.join(str(datafiles), 'mirror')
|
|
629
|
+
|
|
630
|
+ defined_subrepo = create_repo('git', str(tmpdir), 'defined_subrepo')
|
|
631
|
+ defined_mirror_ref = defined_subrepo.create(bin_files_path)
|
|
632
|
+ defined_mirror = defined_subrepo.copy(mirror_dir)
|
|
633
|
+ defined_subref = defined_subrepo.add_file(foo_file)
|
|
634
|
+
|
|
635
|
+ found_subrepo = create_repo('git', str(tmpdir), 'found_subrepo')
|
|
636
|
+ found_subref = found_subrepo.create(dev_files_path)
|
|
637
|
+
|
|
638
|
+ main_repo = create_repo('git', str(tmpdir))
|
|
639
|
+ main_mirror_ref = main_repo.create(bin_files_path)
|
|
640
|
+ main_repo.add_submodule('defined', 'file://' + defined_subrepo.repo)
|
|
641
|
+ main_repo.add_submodule('found', 'file://' + found_subrepo.repo)
|
|
642
|
+ main_mirror = main_repo.copy(mirror_dir)
|
|
643
|
+ main_ref = main_repo.add_file(bar_file)
|
|
644
|
+
|
|
645
|
+ project_dir = os.path.join(str(tmpdir), 'project')
|
|
646
|
+ os.makedirs(project_dir)
|
|
647
|
+ element_dir = os.path.join(project_dir, 'elements')
|
|
648
|
+ os.makedirs(element_dir)
|
|
649
|
+ element = {
|
|
650
|
+ 'kind': 'import',
|
|
651
|
+ 'sources': [
|
|
652
|
+ main_repo.source_config(ref=main_mirror_ref)
|
|
653
|
+ ]
|
|
654
|
+ }
|
|
655
|
+ element_name = 'test.bst'
|
|
656
|
+ element_path = os.path.join(element_dir, element_name)
|
|
657
|
+
|
|
658
|
+ # Alias the main repo
|
|
659
|
+ full_repo = element['sources'][0]['url']
|
|
660
|
+ _, repo_name = os.path.split(full_repo)
|
|
661
|
+ alias = 'foo'
|
|
662
|
+ aliased_repo = alias + ':' + repo_name
|
|
663
|
+ element['sources'][0]['url'] = aliased_repo
|
|
664
|
+
|
|
665
|
+ # Hide the found subrepo
|
|
666
|
+ del element['sources'][0]['submodules']['found']
|
|
667
|
+
|
|
668
|
+ # Alias the defined subrepo
|
|
669
|
+ subrepo = element['sources'][0]['submodules']['defined']['url']
|
|
670
|
+ _, repo_name = os.path.split(subrepo)
|
|
671
|
+ aliased_repo = alias + ':' + repo_name
|
|
672
|
+ element['sources'][0]['submodules']['defined']['url'] = aliased_repo
|
|
673
|
+
|
|
674
|
+ _yaml.dump(element, element_path)
|
|
675
|
+
|
|
676
|
+ full_mirror = main_mirror.source_config()['url']
|
|
677
|
+ mirror_map, _ = os.path.split(full_mirror)
|
|
678
|
+ project = {
|
|
679
|
+ 'name': 'test',
|
|
680
|
+ 'element-path': 'elements',
|
|
681
|
+ 'aliases': {
|
|
682
|
+ alias: 'http://www.example.com/'
|
|
683
|
+ },
|
|
684
|
+ 'mirrors': [
|
|
685
|
+ {
|
|
686
|
+ 'name': 'middle-earth',
|
|
687
|
+ 'aliases': {
|
|
688
|
+ alias: [mirror_map + "/"],
|
|
689
|
+ },
|
|
690
|
+ },
|
|
691
|
+ ]
|
|
692
|
+ }
|
|
693
|
+ project_file = os.path.join(project_dir, 'project.conf')
|
|
694
|
+ _yaml.dump(project, project_file)
|
|
695
|
+
|
|
696
|
+ result = cli.run(project=project_dir, args=['fetch', element_name])
|
|
697
|
+ result.assert_success()
|