alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
288 stars 49 forks source link

Testsuite runs any `alr` in `$PATH` #1260

Closed 0rzech closed 1 year ago

0rzech commented 1 year ago

When I run the testsuite on my computer, lots of tests fail. Some do because the output has additional spaces at the end of lines (probably some whitespace alignment when printing process output on my computer), some expect slightly different messages (eg. Fetch a published crate instead of Fetches a crate release or last_build_profile=xxx=DEVELOPMENT instead of last_build_profile=DEVELOPMENT) and so on.

When I change expected values in problematic tests, they work fine on my computer, but fail on CI for this reason.

If the tests are expected to work the same way locally and on CI, I can provide you with more details.

mosteo commented 1 year ago

The testsuite runs properly locally. By the looks of it you're using mismatched versions of alr and the testsuite.

0rzech commented 1 year ago

So the testsuite runs alr from $PATH instead of the one from build directory?

mosteo commented 1 year ago

Right. In fact we probably should check this.

0rzech commented 1 year ago

I have created a PR to fix the issue.

Now the only problem I have is that init/user-input-validation fails, because user credentials are not being set at all. The alr-config/config.toml contains only:

[toolchain]
assistant = false

Consequently, the test project's alire.toml has authors = ["Your Name"].

Even if I do:

diff --git a/testsuite/tests/init/user-input-validation/test.py b/testsuite/tests/init/user-input-validation/test.py
index f4c0c4e4..00dcd1a0 100644
--- a/testsuite/tests/init/user-input-validation/test.py
+++ b/testsuite/tests/init/user-input-validation/test.py
@@ -8,14 +8,16 @@ from drivers.alr import run_alr
 from drivers.asserts import assert_match
 from drivers.helpers import content_of

+config_dir = os.environ['ALR_CONFIG']
+
 # Preconfigure needed fields
 name = "Äl O'Reilly O\"Raro"
-run_alr("config", "--global", "--set", "user.email", "abc@de.com")
-run_alr("config", "--global", "--set", "user.github_login", "abcde")
-run_alr("config", "--global", "--set", "user.name", name)
+run_alr("-c", config_dir, "config", "--global", "--set", "user.email", "abc@de.com")
+run_alr("-c", config_dir, "config", "--global", "--set", "user.github_login", "abcde")
+run_alr("-c", config_dir, "config", "--global", "--set", "user.name", name)

 # Create crate
-run_alr("init", "--bin", "xxx")
+run_alr("-c", config_dir, "init", "--bin", "xxx")

 # Check that it can be shown, which will load the manifest
 os.chdir("xxx")

it doesn't write and read the value as expected. The run_alr command does not fail itself, though.

And it looks like it doesn't write the values anywhere, nor it reads my $HOME/.config/alire/config.toml, because I don't see my own credentials in test alire.toml.

The test does not fail when I run it using alr 1.2.1.

And finally, the test works fine after I build alr with gprbuild -j0 -P alr_env or with alr build, but having project-files = ["alr_env.gpr"] in alire.toml.

I think this is where it fails. It looks like some encoding issues make alire built with alr build unable to read the config. Additionally, when I put some Polish letters into name, I get:

raised CONSTRAINT_ERROR : Ada.Text_IO.Get_Upper_Half_Char_Immed: invalid wide character in Text_'I'O input

from inside of this call. Might these issues happen because of #1220?

mosteo commented 1 year ago

There's a mix of issues here that I cannot untangle. I'd suggest to concentrate on a concrete reproducer of a single problem so we can better help.