gitignore was keeping it off the repository, and we hadn't noticed.
The file weighs 1.6MB, but it's a great way to test with a real index
with the right size and signature. Moreover, we likely won't be updating
this file often - perhaps once every couple of years, as the index
format progresses.
Most importantly, the file is not part of any importable Go package, so
it should never find its way to a vendor folder or a module archive.
The F-Droid index format contains absolute download urls, so setting up
a custom config for the tests with the original index file won't work
when dowlnoading APKs. Those will still get downloaded from f-droid.org.
To fix that, use http.Client.Transport instead of a custom config. This
requires less code, introduces less test code in non-test files, and
means we can use the default config in the tests.
This has multiple advantages. For one, we can simplify our code, as we
can use globals like os.Stdout and flagsets directly.
It will also be easier to write parallel tests which will run faster, as
each testscript runs concurrently.
While at it, start using $HOME if set, as that is often better than
blindly relying on the current user's home directory via cgo.
Go 1.11 and 1.12 add os.UserCacheDir and os.UserHomeDir respectively, so
soon enough we'll be able to replace most of basedir with those.
Finally, stop having the tests require on the f-droid.org repository to
work. Committing under 2MB of data is plenty to get the files we need in
a static local http server, which makes the tests much faster and not
depend on an internet connection.
Follow-up commits will finish porting the rest of the tests.
This way, users can simply do:
go get mvdan.cc/fdroidcl
Instead of the repetitive:
go get mvdan.cc/fdroidcl/cmd/fdroidcl
The cmd/... pattern only makes sense if the repository has many
commands, or if the name of the repository and command don't match.
Neither is the case here.
That is, downloading /index-v1.jar instead of /index.jar.
This lets us clean up some code, as the old format was a bit more
complex and made use of some slightly weird encodings. But most
importantly, the new index format includes some extra information that
we might start using soon.
Now, install handles upgrades too. It will succeed if it can install a
new app, upgrade an existing app, or if an app is already up to date.
For the time being, this removes the "upgrade only if already installed"
and "install only if not already installed" features, but those are very
specific and likely not useful. They can be re-added as options if
necessary.
Fixes#23.
This way, we avoid linking an executable, and running the tests is also
faster. This shaves the test time by half, from ~9s to ~4s.
This also means we can use tooling better. For example, the cover tool
now works properly, reporting a coverage of nearly 60%.
The tool had very little test coverage up until this point, so end to
end tests will be the best way to add proper coverage without unit
testing every single piece.
When done, the tests will only run what they can, skipping certain
subtests if they can't connect to f-droid.org or if there is no Android
device attached.
I have been moving all github.com/mvdan/... packages to mvdan.cc/...
recently - do this one too.
basedir was only really used by these packages, so merge it in to
simplify building and packaging the tool.
When trying to uninstall an app that is not installed adb prints just
"Failure". This causes output parsing to fail and results in "panic:
runtime error: index out of range" in adb.getFailureCode().
Check whether an app is installed first and print an appropriate message
if it's not.
Adb can print error in the following format:
Failed to install example.apk: Failure [INSTALL_...: Explanation.]
So we should not expect "Failure" at the beginning of output.
The new cache format didn't encode the repos properly, which lead to
crashes. Since we're modifying the cache format, introduce a version and
discard all previous caches (defaulting to version 0).
Fixes#19.