From 13f969b0a74dd0593a7187ef17268b7d9f5dce97 Mon Sep 17 00:00:00 2001 From: Sebastian M'Caw Date: Mon, 16 Sep 2024 15:32:00 +0000 Subject: [PATCH 1/4] Add test for offline build --- .../air-gapping/my_index/crates/hello/HEAD | 1 + .../air-gapping/my_index/crates/hello/config | 4 + .../my_index/crates/hello/description | 1 + .../15/cb23051f1ff3a6684a57531e46df799d5824f2 | Bin 0 -> 124 bytes .../2b/5f082653488d19f6108867e493b657e75320ce | Bin 0 -> 54 bytes .../62/36aa7e1dbdd096427ed632c7d4755983c12d33 | Bin 0 -> 77 bytes .../69/e7a181416f665433500caf06d9d4b9b897b133 | Bin 0 -> 83 bytes .../cd/89b04bec4c8580f565b34a3aef11716e3ce963 | 2 + .../my_index/crates/hello/packed-refs | 2 + .../my_index/crates/hello/refs/.emptydir | 0 .../air-gapping/my_index/crates/libhello/HEAD | 1 + .../my_index/crates/libhello/config | 4 + .../my_index/crates/libhello/description | 1 + .../10/dbaf3d2d4ceaad2d7f4785b4aa0d1f912b38e5 | Bin 0 -> 82 bytes .../23/1e491e1a187b52dd5e94238e5170cb4de37ce1 | Bin 0 -> 69 bytes .../33/053304cbc00068c0963822cd51a309ae42ff00 | Bin 0 -> 87 bytes .../60/cb127eb6ba5c883490c4c8ada38e4a15347092 | Bin 0 -> 154 bytes .../82/65f7ebea39d73db9675fc91495b448ed5960ec | 2 + .../c6/a9c4c3965544f12ce8cc39e8c14a55f43dde91 | Bin 0 -> 122 bytes .../my_index/crates/libhello/packed-refs | 2 + .../my_index/crates/libhello/refs/.emptydir | 0 .../my_index/index/he/hello/hello-1.0.1.toml | 12 +++ .../air-gapping/my_index/index/index.toml | 1 + .../index/li/libhello/libhello-1.0.0.toml | 9 ++ testsuite/tests/workflows/air-gapping/test.py | 90 ++++++++++++++++++ .../tests/workflows/air-gapping/test.yaml | 4 + 26 files changed, 136 insertions(+) create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/config create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/description create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/15/cb23051f1ff3a6684a57531e46df799d5824f2 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/2b/5f082653488d19f6108867e493b657e75320ce create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/62/36aa7e1dbdd096427ed632c7d4755983c12d33 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/69/e7a181416f665433500caf06d9d4b9b897b133 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/refs/.emptydir create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/HEAD create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/config create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/description create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/10/dbaf3d2d4ceaad2d7f4785b4aa0d1f912b38e5 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/23/1e491e1a187b52dd5e94238e5170cb4de37ce1 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/33/053304cbc00068c0963822cd51a309ae42ff00 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/60/cb127eb6ba5c883490c4c8ada38e4a15347092 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/c6/a9c4c3965544f12ce8cc39e8c14a55f43dde91 create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/refs/.emptydir create mode 100644 testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml create mode 100644 testsuite/tests/workflows/air-gapping/my_index/index/index.toml create mode 100644 testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml create mode 100644 testsuite/tests/workflows/air-gapping/test.py create mode 100644 testsuite/tests/workflows/air-gapping/test.yaml diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/config b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/config new file mode 100644 index 000000000..07d359d07 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/config @@ -0,0 +1,4 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/description b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/15/cb23051f1ff3a6684a57531e46df799d5824f2 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/15/cb23051f1ff3a6684a57531e46df799d5824f2 new file mode 100644 index 0000000000000000000000000000000000000000..da7b004a27a3e709e38e3913cd3942757bc6febd GIT binary patch literal 124 zcmV-?0E7Q{0ZYosPf{>6F=Z&vEXhz%%E?U1NX^N~*Gn%bQnKdaDk#d&N=+_N@Bj%a zWEOLADJUqU0kaD`{H8&|1vN_m literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/2b/5f082653488d19f6108867e493b657e75320ce b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/2b/5f082653488d19f6108867e493b657e75320ce new file mode 100644 index 0000000000000000000000000000000000000000..a54124a71c4cef50e93078af47e1c7d166ee8bed GIT binary patch literal 54 zcmV-60LlM&0V^p=O;s>9XD~D{Ff%bx$Vkn}$=6FvNn%JcTU95!_rf%%x@$(quarhM MAJjDl08G#j$QbbzI{*Lx literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/62/36aa7e1dbdd096427ed632c7d4755983c12d33 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/62/36aa7e1dbdd096427ed632c7d4755983c12d33 new file mode 100644 index 0000000000000000000000000000000000000000..634f0ada746ae568a78aef7a239e2577131309c4 GIT binary patch literal 77 zcmV-T0J8sh0ZYosPf{?qU?|Tl$x!ggOv*^j$;r3o;wmW0PfkrKElO4J0EsAM7ISeW jrKV@*aVaRk)#-ud;=}Wca#F0hQu9(EimkZ-)qWgm#Y!fc literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/69/e7a181416f665433500caf06d9d4b9b897b133 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/69/e7a181416f665433500caf06d9d4b9b897b133 new file mode 100644 index 0000000000000000000000000000000000000000..4f957550368f7ebb5b9f1c6e6104e756f204a82b GIT binary patch literal 83 zcmV-Z0IdIb0V^p=O;s>6XD~D{Ff%bx$Vkn}$=6FSC}I#jt;{Mf|9M%4S9q|T+x^P9 p5h|Zd41hqPxG0%HJDx)=*rQkSn?OhUlgZn{p9d?P0|0+T8W45BBLDyZ literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 new file mode 100644 index 000000000..a9e8db0e0 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 @@ -0,0 +1,2 @@ +x= +1Fs,g"'$` ^߀'+Z=z3h-YCdNhC619D?Y<$} N%v̩69ZΣ:9AA[=u{} 4 \ No newline at end of file diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs new file mode 100644 index 000000000..ea2add0f1 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +cd89b04bec4c8580f565b34a3aef11716e3ce963 refs/heads/master diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/refs/.emptydir b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/refs/.emptydir new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/HEAD b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/config b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/config new file mode 100644 index 000000000..07d359d07 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/config @@ -0,0 +1,4 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/description b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/10/dbaf3d2d4ceaad2d7f4785b4aa0d1f912b38e5 b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/10/dbaf3d2d4ceaad2d7f4785b4aa0d1f912b38e5 new file mode 100644 index 0000000000000000000000000000000000000000..acc1322e714d3a5d3d0efe5eed373385cf62b939 GIT binary patch literal 82 zcmV-Y0ImOc0V^p=O;xZkU@$Z=Ff%bx$jMB~NX^N~*Go)EVn{eGRJUzcOoz#YBPZ4_ o?(-5gDVT(*u9!ht&QnfGqB`hq+!W=$z=G4hk82(R07RuAI&)4VXaE2J literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/23/1e491e1a187b52dd5e94238e5170cb4de37ce1 b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/23/1e491e1a187b52dd5e94238e5170cb4de37ce1 new file mode 100644 index 0000000000000000000000000000000000000000..6a77d313b7fba8d217732bfd1bc8709f3e7c0ef8 GIT binary patch literal 69 zcmV-L0J{Hp0ZYosPf{>5Vkk&V&Q45ERmjOq%1F)0$ydlM=HgONP$($MPfkrKElO4J b013y3=NILqSaWfu=B2>ZT5|yaHgFe7DpekJ literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/33/053304cbc00068c0963822cd51a309ae42ff00 b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/33/053304cbc00068c0963822cd51a309ae42ff00 new file mode 100644 index 0000000000000000000000000000000000000000..ec6a491275170dfb5a5d83fd48b9e2531887a621 GIT binary patch literal 87 zcmV-d0I2_X0V^p=O;s>AU@$Z=Ff%bx$jMB~NX^N~*Gn%bVmP+)$l++}3ILXGp0ZYosPf{>4wqPjFEXh!COi9!WNv$Y}_w={s;wnf?&Q45ERY=NDsZ_|x zOv*^j$;ns9Eau`;P*BiC2M|F850Ikx@cg2j6rdXHDnX(JMfu68DWyfJC^~?K1Lc6A zv^W*jH9)bX)bz|esC+sOUib|T+AQh>3DahsmJp&Sf`N5hC I0M+nC1W89oz5oCK literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec new file mode 100644 index 000000000..321d28649 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec @@ -0,0 +1,2 @@ +xA +0P9\24)+6Gh!$x%FjwoE>ZBwOv*^j$;ns9Eau`;P*6zAFH#83FD*(= zjd#f`Dpn{hPF2uQDlSS^(zJ%j`zL|4g5<%{O8H4yO4e}QKog4+iz?&&5_3}_@?Z;q cDxk*06u|Z8WF~?1r{<-=ode_o01y*3VogmrSpWb4 literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs new file mode 100644 index 000000000..4cceaabf1 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +8265f7ebea39d73db9675fc91495b448ed5960ec refs/heads/master diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/refs/.emptydir b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/refs/.emptydir new file mode 100644 index 000000000..e69de29bb diff --git a/testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml b/testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml new file mode 100644 index 000000000..b5ab4c848 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml @@ -0,0 +1,12 @@ +description = "\"Hello, world!\" demonstration project" +name = "hello" +version = "1.0.1" +maintainers = ["alejandro@mosteo.com", "bob@example.com"] +maintainers-logins = ["mylogin"] + +[[depends-on]] +libhello = "^1.0" + +[origin] +url = "git+file:../../../crates/hello" +commit = "cd89b04bec4c8580f565b34a3aef11716e3ce963" diff --git a/testsuite/tests/workflows/air-gapping/my_index/index/index.toml b/testsuite/tests/workflows/air-gapping/my_index/index/index.toml new file mode 100644 index 000000000..bad265e4f --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/index/index.toml @@ -0,0 +1 @@ +version = "1.1" diff --git a/testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml b/testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml new file mode 100644 index 000000000..a5b2604c8 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml @@ -0,0 +1,9 @@ +description = "\"Hello, world!\" demonstration project support library" +name = "libhello" +version = "1.0.0" +maintainers = ["alejandro@mosteo.com"] +maintainers-logins = ["mylogin"] + +[origin] +url = "git+file:../../../crates/libhello" +commit = "8265f7ebea39d73db9675fc91495b448ed5960ec" diff --git a/testsuite/tests/workflows/air-gapping/test.py b/testsuite/tests/workflows/air-gapping/test.py new file mode 100644 index 000000000..31e4f1f82 --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/test.py @@ -0,0 +1,90 @@ +""" +Test fetching a crate online, and subsequently building offline. +""" + + +import os +import shutil +import subprocess +import sys + +from drivers.alr import run_alr +from drivers.helpers import init_git_repo, on_windows +from drivers.asserts import assert_eq, assert_match + + +# Mock git, curl, gprbuild etc. with dummy scripts +if on_windows(): + print('SKIP: command mocking unavailable on Windows') + sys.exit(0) +os.mkdir("path-dir") +os.chdir("path-dir") +for executable in ("git", "hg", "svn", "curl", "gprbuild"): + with open(executable, "w") as f: + f.write("\n".join([ + "#!/usr/bin/env python", + "import sys", + "print('Mocked command called')", + "sys.exit(1)" + ])) + os.chmod(executable, 0o764) +os.environ["PATH"] = f'{os.getcwd()}{os.pathsep}{os.environ["PATH"]}' +os.chdir("..") + + +# 'dependencies.shared=false' is required to ensure dependencies are packaged +# inside the workspace (at ./alire/cache/dependencies) +run_alr("settings", "--global", "--set", "dependencies.shared", "false") + +# Run `alr get hello`. This will fail because git is unavailable. +p = run_alr("get", "hello", quiet=False, complain_on_error=False) +assert_match(".*Mocked command called", p.out) +assert_match(".*Deployment of commit .* from .* to .* failed", p.out) + +# Disable git mocking and run `alr get hello` to 'download' the crate and its +# dependencies. +os.remove(os.path.join("path-dir", "git")) +p = run_alr("get", "hello", quiet=False) +assert_match(r".*hello=1\.0\.1 successfully retrieved", p.out) +assert_match(r".*\+ libhello 1\.0\.0 \(new\)", p.out) + +# Re-enable git mocking and make the index unavailable to simulate disconnection +# from the network +shutil.copy(os.path.join("path-dir", "curl"), os.path.join("path-dir", "git")) +shutil.move("my_index", "somewhere_else") + +# Simulate transferring to a different system by clearing the alr-config +# directory (we keep settings.toml, since it just does various things to isolate +# the test environment) and changing the absolute path of the crate directory. +for f in os.listdir("alr-config"): + if f != "settings.toml": + shutil.rmtree(os.path.join("alr-config", f)) +shutil.move(f"hello_1.0.1_cd89b04b", "hello") + +# Run `alr build`. This will fail because gprbuild is unavailable. +os.chdir(f"hello") +p = run_alr("build", quiet=False, complain_on_error=False) +assert_match(".*Mocked command called", p.out) +assert_match(r'.*Command \["gprbuild", .*\] exited with code 1', p.out) + +# Disable gprbuild mocking and run `alr build` to build the crate (with git +# mocking still enabled to check it doesn't try to fetch anything else) +os.remove(os.path.join("..", "path-dir", "gprbuild")) +p = run_alr("build", quiet=False) +assert_match(".*Build finished successfully in .* seconds", p.out) + +# Check the built binary works as expected +assert_eq( + b"Hello, world!\n", + subprocess.run([os.path.join("obj", "hello")], capture_output=True).stdout +) + +# Clear out the downloaded dependencies, and verify that `alr build` then +# attempts (and fails) to re-fetch them +shutil.rmtree(os.path.join("alire", "cache", "dependencies")) +p = run_alr("build", quiet=False, complain_on_error=False) +assert_match(".*Mocked command called", p.out) +assert_match(".*Deployment of commit .* from .* to .* failed", p.out) + + +print("SUCCESS") diff --git a/testsuite/tests/workflows/air-gapping/test.yaml b/testsuite/tests/workflows/air-gapping/test.yaml new file mode 100644 index 000000000..0a859639c --- /dev/null +++ b/testsuite/tests/workflows/air-gapping/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + my_index: + in_fixtures: false From b8e6d3c58597e897de1f89c1465503bfed9fcd58 Mon Sep 17 00:00:00 2001 From: Seb M'Caw Date: Mon, 23 Sep 2024 09:33:11 +0000 Subject: [PATCH 2/4] Move constraints to YAML file --- testsuite/tests/workflows/air-gapping/test.py | 9 --------- testsuite/tests/workflows/air-gapping/test.yaml | 6 ++++++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/testsuite/tests/workflows/air-gapping/test.py b/testsuite/tests/workflows/air-gapping/test.py index 31e4f1f82..82773f318 100644 --- a/testsuite/tests/workflows/air-gapping/test.py +++ b/testsuite/tests/workflows/air-gapping/test.py @@ -6,17 +6,12 @@ import os import shutil import subprocess -import sys from drivers.alr import run_alr -from drivers.helpers import init_git_repo, on_windows from drivers.asserts import assert_eq, assert_match # Mock git, curl, gprbuild etc. with dummy scripts -if on_windows(): - print('SKIP: command mocking unavailable on Windows') - sys.exit(0) os.mkdir("path-dir") os.chdir("path-dir") for executable in ("git", "hg", "svn", "curl", "gprbuild"): @@ -32,10 +27,6 @@ os.chdir("..") -# 'dependencies.shared=false' is required to ensure dependencies are packaged -# inside the workspace (at ./alire/cache/dependencies) -run_alr("settings", "--global", "--set", "dependencies.shared", "false") - # Run `alr get hello`. This will fail because git is unavailable. p = run_alr("get", "hello", quiet=False, complain_on_error=False) assert_match(".*Mocked command called", p.out) diff --git a/testsuite/tests/workflows/air-gapping/test.yaml b/testsuite/tests/workflows/air-gapping/test.yaml index 0a859639c..ec0413f72 100644 --- a/testsuite/tests/workflows/air-gapping/test.yaml +++ b/testsuite/tests/workflows/air-gapping/test.yaml @@ -1,4 +1,10 @@ driver: python-script +# We need 'dependencies.shared=false' anyway for dependencies to be packaged +# inside the workspace, so we only run in sandboxed mode. +build_mode: sandboxed +control: + # Mocking commands this way doesn't work on Windows + - [SKIP, "skip_unix", "Test is Unix-only"] indexes: my_index: in_fixtures: false From b8b05066951810ac2dc0960520a3c0a246386c12 Mon Sep 17 00:00:00 2001 From: Seb M'Caw Date: Mon, 23 Sep 2024 09:34:49 +0000 Subject: [PATCH 3/4] Remove redundant build check --- testsuite/tests/workflows/air-gapping/test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testsuite/tests/workflows/air-gapping/test.py b/testsuite/tests/workflows/air-gapping/test.py index 82773f318..dd59545bd 100644 --- a/testsuite/tests/workflows/air-gapping/test.py +++ b/testsuite/tests/workflows/air-gapping/test.py @@ -62,7 +62,6 @@ # mocking still enabled to check it doesn't try to fetch anything else) os.remove(os.path.join("..", "path-dir", "gprbuild")) p = run_alr("build", quiet=False) -assert_match(".*Build finished successfully in .* seconds", p.out) # Check the built binary works as expected assert_eq( From e44265e94d87b1903f4be004f2980c579aae9308 Mon Sep 17 00:00:00 2001 From: Seb M'Caw Date: Mon, 23 Sep 2024 09:38:36 +0000 Subject: [PATCH 4/4] Change crates from git repos to .tgz archives --- .../air-gapping/my_index/crates/hello.tgz | Bin 0 -> 334 bytes .../air-gapping/my_index/crates/hello/HEAD | 1 - .../air-gapping/my_index/crates/hello/config | 4 --- .../my_index/crates/hello/description | 1 - .../15/cb23051f1ff3a6684a57531e46df799d5824f2 | Bin 124 -> 0 bytes .../2b/5f082653488d19f6108867e493b657e75320ce | Bin 54 -> 0 bytes .../62/36aa7e1dbdd096427ed632c7d4755983c12d33 | Bin 77 -> 0 bytes .../69/e7a181416f665433500caf06d9d4b9b897b133 | Bin 83 -> 0 bytes .../cd/89b04bec4c8580f565b34a3aef11716e3ce963 | 2 -- .../my_index/crates/hello/packed-refs | 2 -- .../my_index/crates/hello/refs/.emptydir | 0 .../air-gapping/my_index/crates/libhello.tgz | Bin 0 -> 428 bytes .../air-gapping/my_index/crates/libhello/HEAD | 1 - .../my_index/crates/libhello/config | 4 --- .../my_index/crates/libhello/description | 1 - .../10/dbaf3d2d4ceaad2d7f4785b4aa0d1f912b38e5 | Bin 82 -> 0 bytes .../23/1e491e1a187b52dd5e94238e5170cb4de37ce1 | Bin 69 -> 0 bytes .../33/053304cbc00068c0963822cd51a309ae42ff00 | Bin 87 -> 0 bytes .../60/cb127eb6ba5c883490c4c8ada38e4a15347092 | Bin 154 -> 0 bytes .../82/65f7ebea39d73db9675fc91495b448ed5960ec | 2 -- .../c6/a9c4c3965544f12ce8cc39e8c14a55f43dde91 | Bin 122 -> 0 bytes .../my_index/crates/libhello/packed-refs | 2 -- .../my_index/crates/libhello/refs/.emptydir | 0 .../my_index/index/he/hello/hello-1.0.1.toml | 3 +- .../index/li/libhello/libhello-1.0.0.toml | 3 +- testsuite/tests/workflows/air-gapping/test.py | 27 ++++++++++-------- 26 files changed, 17 insertions(+), 36 deletions(-) create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello.tgz delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/config delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/description delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/15/cb23051f1ff3a6684a57531e46df799d5824f2 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/2b/5f082653488d19f6108867e493b657e75320ce delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/62/36aa7e1dbdd096427ed632c7d4755983c12d33 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/69/e7a181416f665433500caf06d9d4b9b897b133 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/hello/refs/.emptydir create mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello.tgz delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/HEAD delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/config delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/description delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/10/dbaf3d2d4ceaad2d7f4785b4aa0d1f912b38e5 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/23/1e491e1a187b52dd5e94238e5170cb4de37ce1 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/33/053304cbc00068c0963822cd51a309ae42ff00 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/60/cb127eb6ba5c883490c4c8ada38e4a15347092 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/c6/a9c4c3965544f12ce8cc39e8c14a55f43dde91 delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs delete mode 100644 testsuite/tests/workflows/air-gapping/my_index/crates/libhello/refs/.emptydir diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello.tgz b/testsuite/tests/workflows/air-gapping/my_index/crates/hello.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a39010d27cf1902c1153f4a9ddc7cd3d7570ed4c GIT binary patch literal 334 zcmV-U0kQrciwFP!000001MStlZi6rs1z=`Bg~ik^DK=mR)(#z7b?DGB;>Qg{6e0u4 z>(@4fMp4@+RY+9zd<%$sEkK8B3RzXnoii&>i=xmRSri82QP}GvhXo=EI2XRqeasWO zjfV3+)}U{@L{aLzXUX=bzGL-2s<8RDDx2{eI4S>->HJyX3*>(ZpZVLfMUtmyzlRA} zh~V4&850Nj``n8h>Ye>bzVOfU-)*`>wIXA$+h1GPBqN`km_oqX1T|)`RAM+%s&r8%>PB$`FE?`VCzr79d?1W z%(}fjKu`Z$qv%W1t4uEMOV!f8mGs8dzYg~{-qoK|v(D6Q*=^FbI~AXjvL07WKO3`l ge+R)90ssI20000000000008hiA3Kd7F90Y20A9796#xJL literal 0 HcmV?d00001 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/config b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/config deleted file mode 100644 index 07d359d07..000000000 --- a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/config +++ /dev/null @@ -1,4 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = true diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/description b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/description deleted file mode 100644 index 498b267a8..000000000 --- a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/15/cb23051f1ff3a6684a57531e46df799d5824f2 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/15/cb23051f1ff3a6684a57531e46df799d5824f2 deleted file mode 100644 index da7b004a27a3e709e38e3913cd3942757bc6febd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 124 zcmV-?0E7Q{0ZYosPf{>6F=Z&vEXhz%%E?U1NX^N~*Gn%bQnKdaDk#d&N=+_N@Bj%a zWEOLADJUqU0kaD`{H8&|1vN_m diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/2b/5f082653488d19f6108867e493b657e75320ce b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/2b/5f082653488d19f6108867e493b657e75320ce deleted file mode 100644 index a54124a71c4cef50e93078af47e1c7d166ee8bed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmV-60LlM&0V^p=O;s>9XD~D{Ff%bx$Vkn}$=6FvNn%JcTU95!_rf%%x@$(quarhM MAJjDl08G#j$QbbzI{*Lx diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/62/36aa7e1dbdd096427ed632c7d4755983c12d33 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/62/36aa7e1dbdd096427ed632c7d4755983c12d33 deleted file mode 100644 index 634f0ada746ae568a78aef7a239e2577131309c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 77 zcmV-T0J8sh0ZYosPf{?qU?|Tl$x!ggOv*^j$;r3o;wmW0PfkrKElO4J0EsAM7ISeW jrKV@*aVaRk)#-ud;=}Wca#F0hQu9(EimkZ-)qWgm#Y!fc diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/69/e7a181416f665433500caf06d9d4b9b897b133 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/69/e7a181416f665433500caf06d9d4b9b897b133 deleted file mode 100644 index 4f957550368f7ebb5b9f1c6e6104e756f204a82b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 83 zcmV-Z0IdIb0V^p=O;s>6XD~D{Ff%bx$Vkn}$=6FSC}I#jt;{Mf|9M%4S9q|T+x^P9 p5h|Zd41hqPxG0%HJDx)=*rQkSn?OhUlgZn{p9d?P0|0+T8W45BBLDyZ diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 deleted file mode 100644 index a9e8db0e0..000000000 --- a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/objects/cd/89b04bec4c8580f565b34a3aef11716e3ce963 +++ /dev/null @@ -1,2 +0,0 @@ -x= -1Fs,g"'$` ^߀'+Z=z3h-YCdNhC619D?Y<$} N%v̩69ZΣ:9AA[=u{} 4 \ No newline at end of file diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs deleted file mode 100644 index ea2add0f1..000000000 --- a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/packed-refs +++ /dev/null @@ -1,2 +0,0 @@ -# pack-refs with: peeled fully-peeled sorted -cd89b04bec4c8580f565b34a3aef11716e3ce963 refs/heads/master diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/hello/refs/.emptydir b/testsuite/tests/workflows/air-gapping/my_index/crates/hello/refs/.emptydir deleted file mode 100644 index e69de29bb..000000000 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello.tgz b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello.tgz new file mode 100644 index 0000000000000000000000000000000000000000..c5882e61a64bcdbdd93a0e082d77f0fedb4cad96 GIT binary patch literal 428 zcmV;d0aN}TiwFP!000001MQVhPlGTR#yRsTUOCM~=YUcUoJ>4uvN#h>Jdy%+W3sUn z$lSNLWk4JYE{kl&`2H@y`=@R4^m$3*V8)Xqz0pp`NaDJVdYZ07swXYu6`Dz?ODv1J z@_l5QwoNo}PI#tJA*EKc%+R-;x&q^*;wY`qv*r z7G*u|p#-LsbnEZZmi~lTrUs)P&(O&~*MG&rcQ)lvOAm3T>j1D4X~?5OaJW}t|1}j! zc#X|&m! z3)gM7!LL&S>R`LFbFQexp`^(8?rCH!;L~_n<)4b&AID1$1EcJ}g0))U!niC;)pWvn zbqtOF8}Cn7qUSvh`QIW|%l|ed6#ah=q#x%z%wgQ}`CBUBIW0uU{kvFXr7;JF{7F5Vkk&V&Q45ERmjOq%1F)0$ydlM=HgONP$($MPfkrKElO4J b013y3=NILqSaWfu=B2>ZT5|yaHgFe7DpekJ diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/33/053304cbc00068c0963822cd51a309ae42ff00 b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/33/053304cbc00068c0963822cd51a309ae42ff00 deleted file mode 100644 index ec6a491275170dfb5a5d83fd48b9e2531887a621..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 87 zcmV-d0I2_X0V^p=O;s>AU@$Z=Ff%bx$jMB~NX^N~*Gn%bVmP+)$l++}3ILXGp0ZYosPf{>4wqPjFEXh!COi9!WNv$Y}_w={s;wnf?&Q45ERY=NDsZ_|x zOv*^j$;ns9Eau`;P*BiC2M|F850Ikx@cg2j6rdXHDnX(JMfu68DWyfJC^~?K1Lc6A zv^W*jH9)bX)bz|esC+sOUib|T+AQh>3DahsmJp&Sf`N5hC I0M+nC1W89oz5oCK diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec deleted file mode 100644 index 321d28649..000000000 --- a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/objects/82/65f7ebea39d73db9675fc91495b448ed5960ec +++ /dev/null @@ -1,2 +0,0 @@ -xA -0P9\24)+6Gh!$x%FjwoE>ZBwOv*^j$;ns9Eau`;P*6zAFH#83FD*(= zjd#f`Dpn{hPF2uQDlSS^(zJ%j`zL|4g5<%{O8H4yO4e}QKog4+iz?&&5_3}_@?Z;q cDxk*06u|Z8WF~?1r{<-=ode_o01y*3VogmrSpWb4 diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs deleted file mode 100644 index 4cceaabf1..000000000 --- a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/packed-refs +++ /dev/null @@ -1,2 +0,0 @@ -# pack-refs with: peeled fully-peeled sorted -8265f7ebea39d73db9675fc91495b448ed5960ec refs/heads/master diff --git a/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/refs/.emptydir b/testsuite/tests/workflows/air-gapping/my_index/crates/libhello/refs/.emptydir deleted file mode 100644 index e69de29bb..000000000 diff --git a/testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml b/testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml index b5ab4c848..05221fc60 100644 --- a/testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml +++ b/testsuite/tests/workflows/air-gapping/my_index/index/he/hello/hello-1.0.1.toml @@ -8,5 +8,4 @@ maintainers-logins = ["mylogin"] libhello = "^1.0" [origin] -url = "git+file:../../../crates/hello" -commit = "cd89b04bec4c8580f565b34a3aef11716e3ce963" +url = "file:../../../crates/hello.tgz" diff --git a/testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml b/testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml index a5b2604c8..b1d856d2a 100644 --- a/testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml +++ b/testsuite/tests/workflows/air-gapping/my_index/index/li/libhello/libhello-1.0.0.toml @@ -5,5 +5,4 @@ maintainers = ["alejandro@mosteo.com"] maintainers-logins = ["mylogin"] [origin] -url = "git+file:../../../crates/libhello" -commit = "8265f7ebea39d73db9675fc91495b448ed5960ec" +url = "file:../../../crates/libhello.tgz" diff --git a/testsuite/tests/workflows/air-gapping/test.py b/testsuite/tests/workflows/air-gapping/test.py index dd59545bd..396688547 100644 --- a/testsuite/tests/workflows/air-gapping/test.py +++ b/testsuite/tests/workflows/air-gapping/test.py @@ -11,10 +11,10 @@ from drivers.asserts import assert_eq, assert_match -# Mock git, curl, gprbuild etc. with dummy scripts +# Mock tar, git, curl, gprbuild etc. with dummy scripts os.mkdir("path-dir") os.chdir("path-dir") -for executable in ("git", "hg", "svn", "curl", "gprbuild"): +for executable in ("tar", "git", "hg", "svn", "curl", "gprbuild"): with open(executable, "w") as f: f.write("\n".join([ "#!/usr/bin/env python", @@ -27,21 +27,21 @@ os.chdir("..") -# Run `alr get hello`. This will fail because git is unavailable. +# Run `alr get hello`. This will fail because tar is unavailable. p = run_alr("get", "hello", quiet=False, complain_on_error=False) assert_match(".*Mocked command called", p.out) -assert_match(".*Deployment of commit .* from .* to .* failed", p.out) +assert_match(".*Deployment of path .* to .* failed", p.out) -# Disable git mocking and run `alr get hello` to 'download' the crate and its +# Disable tar mocking and run `alr get hello` to 'download' the crate and its # dependencies. -os.remove(os.path.join("path-dir", "git")) +os.remove(os.path.join("path-dir", "tar")) p = run_alr("get", "hello", quiet=False) assert_match(r".*hello=1\.0\.1 successfully retrieved", p.out) assert_match(r".*\+ libhello 1\.0\.0 \(new\)", p.out) -# Re-enable git mocking and make the index unavailable to simulate disconnection +# Re-enable tar mocking and make the index unavailable to simulate disconnection # from the network -shutil.copy(os.path.join("path-dir", "curl"), os.path.join("path-dir", "git")) +shutil.copy(os.path.join("path-dir", "curl"), os.path.join("path-dir", "tar")) shutil.move("my_index", "somewhere_else") # Simulate transferring to a different system by clearing the alr-config @@ -50,7 +50,7 @@ for f in os.listdir("alr-config"): if f != "settings.toml": shutil.rmtree(os.path.join("alr-config", f)) -shutil.move(f"hello_1.0.1_cd89b04b", "hello") +shutil.move(f"hello_1.0.1_filesystem", "hello") # Run `alr build`. This will fail because gprbuild is unavailable. os.chdir(f"hello") @@ -58,7 +58,7 @@ assert_match(".*Mocked command called", p.out) assert_match(r'.*Command \["gprbuild", .*\] exited with code 1', p.out) -# Disable gprbuild mocking and run `alr build` to build the crate (with git +# Disable gprbuild mocking and run `alr build` to build the crate (with tar # mocking still enabled to check it doesn't try to fetch anything else) os.remove(os.path.join("..", "path-dir", "gprbuild")) p = run_alr("build", quiet=False) @@ -73,8 +73,11 @@ # attempts (and fails) to re-fetch them shutil.rmtree(os.path.join("alire", "cache", "dependencies")) p = run_alr("build", quiet=False, complain_on_error=False) -assert_match(".*Mocked command called", p.out) -assert_match(".*Deployment of commit .* from .* to .* failed", p.out) +assert_match( + ".*Filesystem crate is neither a folder nor a source archive: ", + p.out +) +assert_match(".*Deployment of path .* to .* failed", p.out) print("SUCCESS")