tests: add fakedroid as flake app

This commit is contained in:
Tobias Happ 2022-10-28 19:57:03 +02:00
parent 1c88e73c78
commit 0a3b09df75
3 changed files with 51 additions and 27 deletions

View file

@ -206,6 +206,45 @@ Use `nix-on-droid switch --flake .#device` to build and activate your configurat
Therefore, every evaluation of a flake configuration will be executed with `--impure` flag. (This behaviour will be
dropped as soon as the default setup does not require it anymore.)
## Emulate `nix-on-droid`-like environment with `fakedroid`
For easier debugging and testing, there is a so-called `fakedroid` environment which
emulates the on-device environment including proot as good as possible.
You can enter this emulated environment with
```sh
nix run --impure ".#fakedroid"
```
This will install nix-on-droid with initial channel setup and save the state of
this session in the `.fakedroid` directory in the project directory. To enter this
environment with initial flake setup, set `USE_FLAKE=1` as environment variable.
Channel and flake setups can co-exist in the `.fakedroid` state directory. To
rebuild/re-test the bootstrap process, remove the `.fakedroid` directory.
To only run a command in fakedroid and not enter an interactive shell, just call it
with the command as arguments:
```sh
nix run --impure ".#fakedroid" -- ls -l
```
## Testing
In the [./tests/on-device](./tests/on-device) directory, there is small set
of [bats](https://github.com/bats-core/bats-core) tests that can be executed on the
android device or run in the `fakedroid` environment.
To run the tests (on device or in fakedroid), run
```sh
nix-on-droid on-device-test
```
**Note:** This currently requires a channel setup and should only be executed on
clean installations.
## Tips
* To grant the app access to the storage, use the toggle in the app settings