How to test a opam install using the `url` in the opam file?

I would like to test my opam file with a url {src:} in it, to see if it’s published on opam-repository, other users can install it successfully.

So I would like to use my local opam file but I want opam to download the file via the src.

Currently, before I use opam install . I have to manually download and unzip the file.

How should I use the local opam file and let opam retrieves the code for me?

If you have the opam repository repo cloned locally, you can add it as a local repository (via opam repo add <name> <path-to-repo>), and then try opam install-ing the latest version of your repo to have opam try and download and install the package for you.

I see. Your solution sounds good to me.
I do have a local (and a remote) opam repository repo for making PR.

Are there some required steps to make the new repo work? Do I have to make a new switch?

I clone my opam repository locally and add it to the opam repo.

I add some new versions for some packages, however opam update, opam upgrade, opam info, opam install <pkg> seems to ignore my repo. I even tried removing the default one but it still doesn’t work.

$ opam repo list                                                                                                03:14:12
[NOTE] These are the repositories in use by the current switch. Use '--all' to see all configured repositories.

<><> Repository configuration for switch 4.12.0.many ><><><><><><><><><><><><><>
 1 devel git+file:///home/exx/code/opam-repository

Make sure your new versions are actually part of your local repository, i.e., git add the files and git commit them (on the master branch, unless otherwise specified). Otherwise, Opam will just ignore them.

Currently, before I use opam install . I have to manually download and unzip the file.

Note that you can do opam pin URL directly, granted the archive includes opam file(s).

I see! Thanks!
I saw the prompt on adding your change to git or use -w when I was opam install but I was not aware it’s also the case for opam repo

Do you mean the opam file is in the archive? This may not work in my case. The archive is the source code provided by others e.g. llvm. which I can not put the files (opam, install, patches) I would like to test in it.