Browse Source

run kdbx4 tests in CI

pull/3/head
Herbert Poul 4 years ago
parent
commit
cd22ab328c
  1. 8
      .github/workflows/dart.yml
  2. 3
      .gitignore
  3. 33
      _tool/test-coverage.sh
  4. 20
      lib/src/kdbx_deleted_object.dart

8
.github/workflows/dart.yml

@ -25,3 +25,11 @@ jobs:
run: pub get run: pub get
- name: Run tests - name: Run tests
run: pub run test run: pub run test
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cedx/setup-dart@v2
with:
release-channel: dev
- run: _tool/test-coverage.sh

3
.gitignore vendored

@ -46,3 +46,6 @@ doc/api/
/test_v4.kdbx /test_v4.kdbx
/test_v4x.kdbx /test_v4x.kdbx
/test_output*.kdbx /test_output*.kdbx
/coverage

33
_tool/test-coverage.sh

@ -1,24 +1,51 @@
#!/bin/bash #!/bin/bash
# WARNING: # WARNING:
# Running coverage tests with kdbx 3 seems to be too slow right now, so we only run kdbx 4 tests
# (kdbx4 with argon2 runs on native code, so no code coverage is collected there, vs.
# kdbx3's AES KDF runs in dart).
#
# This is way too slow. Probably because of cryptography with coverage colleciton. # This is way too slow. Probably because of cryptography with coverage colleciton.
# https://github.com/dart-lang/coverage/issues/261 # https://github.com/dart-lang/coverage/issues/261
#
# This script requires `jq`, `curl`, `git`.
set -xeu set -xeu
cd "${0%/*}"/.. cd "${0%/*}"/..
pub get pub get
pub global activate test_coverage pub global activate coverage
fail=false fail=false
pub global run test_coverage || fail=true dart test --exclude-tags kdbx4 --coverage coverage || fail=true
echo "fail=$fail" echo "fail=$fail"
# shellcheck disable=SC2038
# shellcheck disable=SC2046
jq -s '{coverage: [.[].coverage] | flatten}' $(find coverage -name '*.json' | xargs) > coverage/merged_json.cov
pub global run coverage:format_coverage --packages=.packages -i coverage/merged_json.cov -l > coverage/lcov.info
bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info
test "$fail" == "true" && exit 1 test "$fail" == "true" && exit 1
echo "Success 🎉" echo "Success 🎉"
exit 0 exit 0
#pub get
#pub global activate test_coverage
#
#fail=false
#pub global run test_coverage || fail=true
#echo "fail=$fail"
#bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info
#
#test "$fail" == "true" && exit 1
#
#echo "Success 🎉"
#
#exit 0

20
lib/src/kdbx_deleted_object.dart

@ -0,0 +1,20 @@
import 'package:kdbx/kdbx.dart';
import 'package:kdbx/src/kdbx_xml.dart';
import 'package:xml/xml.dart';
class KdbxDeletedObject extends KdbxNode implements KdbxNodeContext {
KdbxDeletedObject.create(this.ctx, KdbxUuid uuid)
: super.create('DeletedObject') {
_uuid.set(uuid);
deletionTime.setToNow();
}
KdbxDeletedObject.read(XmlElement node, this.ctx) : super.read(node);
@override
final KdbxReadWriteContext ctx;
KdbxUuid get uuid => _uuid.get();
UuidNode get _uuid => UuidNode(this, KdbxXml.NODE_UUID);
DateTimeUtcNode get deletionTime => DateTimeUtcNode(this, 'DeletionTime');
}
Loading…
Cancel
Save