diff options
author | Christian Lindeberg <christian.lindeberg@axis.com> | 2024-09-06 11:27:39 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-09-10 13:05:00 +0100 |
commit | 87c29b5a947956ab64c3fe881dfbc7eee5fef9e4 (patch) | |
tree | a9e82dc5b5fb14230bb62d07d32eccc348cf9399 /bitbake/lib/bb/tests/fetch.py | |
parent | dd7631426c1a7d0e6777540c81646777e712be26 (diff) | |
download | poky-87c29b5a947956ab64c3fe881dfbc7eee5fef9e4.tar.gz |
bitbake: fetch2: Add gomodgit fetcher
Add a go module fetcher for downloading module dependencies to the
module cache directly from a git repository. The fetcher can be used
with the go-mod class in OE-Core.
A module dependency can be specified with:
SRC_URI += "gomodgit://golang.org/x/net;version=v0.9.0;srcrev=..."
(Bitbake rev: 29ff38ccf0d5389a5bee81e252a78548361a9d7c)
Signed-off-by: Christian Lindeberg <christian.lindeberg@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 2365a50960..832e0dd6a4 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -3455,3 +3455,92 @@ class GoModTest(FetcherTest): | |||
3455 | downloaddir = os.path.join(self.unpackdir, 'pkg/mod/cache/download') | 3455 | downloaddir = os.path.join(self.unpackdir, 'pkg/mod/cache/download') |
3456 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.zip'))) | 3456 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.zip'))) |
3457 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.mod'))) | 3457 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.mod'))) |
3458 | |||
3459 | class GoModGitTest(FetcherTest): | ||
3460 | |||
3461 | @skipIfNoNetwork() | ||
3462 | def test_gomodgit_url_repo(self): | ||
3463 | urls = ['gomodgit://golang.org/x/net;version=v0.9.0;' | ||
3464 | 'repo=go.googlesource.com/net;' | ||
3465 | 'srcrev=694cff8668bac64e0864b552bffc280cd27f21b1'] | ||
3466 | |||
3467 | fetcher = bb.fetch2.Fetch(urls, self.d) | ||
3468 | ud = fetcher.ud[urls[0]] | ||
3469 | self.assertEqual(ud.host, 'go.googlesource.com') | ||
3470 | self.assertEqual(ud.path, '/net') | ||
3471 | self.assertEqual(ud.names, ['golang.org/x/net@v0.9.0']) | ||
3472 | self.assertEqual(self.d.getVar('SRCREV_golang.org/x/net@v0.9.0'), '694cff8668bac64e0864b552bffc280cd27f21b1') | ||
3473 | |||
3474 | fetcher.download() | ||
3475 | self.assertTrue(os.path.exists(ud.localpath)) | ||
3476 | |||
3477 | fetcher.unpack(self.unpackdir) | ||
3478 | vcsdir = os.path.join(self.unpackdir, 'pkg/mod/cache/vcs') | ||
3479 | self.assertTrue(os.path.exists(os.path.join(vcsdir, 'ed42bd05533fd84ae290a5d33ebd3695a0a2b06131beebd5450825bee8603aca'))) | ||
3480 | downloaddir = os.path.join(self.unpackdir, 'pkg/mod/cache/download') | ||
3481 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'golang.org/x/net/@v/v0.9.0.zip'))) | ||
3482 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'golang.org/x/net/@v/v0.9.0.mod'))) | ||
3483 | |||
3484 | @skipIfNoNetwork() | ||
3485 | def test_gomodgit_url_subdir(self): | ||
3486 | urls = ['gomodgit://github.com/Azure/azure-sdk-for-go/sdk/storage/azblob;version=v1.0.0;' | ||
3487 | 'repo=github.com/Azure/azure-sdk-for-go;subdir=sdk/storage/azblob;' | ||
3488 | 'srcrev=ec928e0ed34db682b3f783d3739d1c538142e0c3'] | ||
3489 | |||
3490 | fetcher = bb.fetch2.Fetch(urls, self.d) | ||
3491 | ud = fetcher.ud[urls[0]] | ||
3492 | self.assertEqual(ud.host, 'github.com') | ||
3493 | self.assertEqual(ud.path, '/Azure/azure-sdk-for-go') | ||
3494 | self.assertEqual(ud.parm['subpath'], 'sdk/storage/azblob') | ||
3495 | self.assertEqual(ud.names, ['github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@v1.0.0']) | ||
3496 | self.assertEqual(self.d.getVar('SRCREV_github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@v1.0.0'), 'ec928e0ed34db682b3f783d3739d1c538142e0c3') | ||
3497 | |||
3498 | fetcher.download() | ||
3499 | self.assertTrue(os.path.exists(ud.localpath)) | ||
3500 | |||
3501 | fetcher.unpack(self.unpackdir) | ||
3502 | vcsdir = os.path.join(self.unpackdir, 'pkg/mod/cache/vcs') | ||
3503 | self.assertTrue(os.path.exists(os.path.join(vcsdir, 'd31d6145676ed3066ce573a8198f326dea5be45a43b3d8f41ce7787fd71d66b3'))) | ||
3504 | downloaddir = os.path.join(self.unpackdir, 'pkg/mod/cache/download') | ||
3505 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'github.com/!azure/azure-sdk-for-go/sdk/storage/azblob/@v/v1.0.0.zip'))) | ||
3506 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'github.com/!azure/azure-sdk-for-go/sdk/storage/azblob/@v/v1.0.0.mod'))) | ||
3507 | |||
3508 | @skipIfNoNetwork() | ||
3509 | def test_gomodgit_url_srcrev_var(self): | ||
3510 | urls = ['gomodgit://gopkg.in/ini.v1;version=v1.67.0'] | ||
3511 | self.d.setVar('SRCREV_gopkg.in/ini.v1@v1.67.0', 'b2f570e5b5b844226bbefe6fb521d891f529a951') | ||
3512 | |||
3513 | fetcher = bb.fetch2.Fetch(urls, self.d) | ||
3514 | ud = fetcher.ud[urls[0]] | ||
3515 | self.assertEqual(ud.host, 'gopkg.in') | ||
3516 | self.assertEqual(ud.path, '/ini.v1') | ||
3517 | self.assertEqual(ud.names, ['gopkg.in/ini.v1@v1.67.0']) | ||
3518 | self.assertEqual(ud.parm['srcrev'], 'b2f570e5b5b844226bbefe6fb521d891f529a951') | ||
3519 | |||
3520 | fetcher.download() | ||
3521 | fetcher.unpack(self.unpackdir) | ||
3522 | vcsdir = os.path.join(self.unpackdir, 'pkg/mod/cache/vcs') | ||
3523 | self.assertTrue(os.path.exists(os.path.join(vcsdir, 'b7879a4be9ba8598851b8278b14c4f71a8316be64913298d1639cce6bde59bc3'))) | ||
3524 | downloaddir = os.path.join(self.unpackdir, 'pkg/mod/cache/download') | ||
3525 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.zip'))) | ||
3526 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.mod'))) | ||
3527 | |||
3528 | @skipIfNoNetwork() | ||
3529 | def test_gomodgit_url_no_go_mod_in_module(self): | ||
3530 | urls = ['gomodgit://gopkg.in/ini.v1;version=v1.67.0;' | ||
3531 | 'srcrev=b2f570e5b5b844226bbefe6fb521d891f529a951'] | ||
3532 | |||
3533 | fetcher = bb.fetch2.Fetch(urls, self.d) | ||
3534 | ud = fetcher.ud[urls[0]] | ||
3535 | self.assertEqual(ud.host, 'gopkg.in') | ||
3536 | self.assertEqual(ud.path, '/ini.v1') | ||
3537 | self.assertEqual(ud.names, ['gopkg.in/ini.v1@v1.67.0']) | ||
3538 | self.assertEqual(self.d.getVar('SRCREV_gopkg.in/ini.v1@v1.67.0'), 'b2f570e5b5b844226bbefe6fb521d891f529a951') | ||
3539 | |||
3540 | fetcher.download() | ||
3541 | fetcher.unpack(self.unpackdir) | ||
3542 | vcsdir = os.path.join(self.unpackdir, 'pkg/mod/cache/vcs') | ||
3543 | self.assertTrue(os.path.exists(os.path.join(vcsdir, 'b7879a4be9ba8598851b8278b14c4f71a8316be64913298d1639cce6bde59bc3'))) | ||
3544 | downloaddir = os.path.join(self.unpackdir, 'pkg/mod/cache/download') | ||
3545 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.zip'))) | ||
3546 | self.assertTrue(os.path.exists(os.path.join(downloaddir, 'gopkg.in/ini.v1/@v/v1.67.0.mod'))) | ||