Fix unit test for kfileplacesmodeltest
ClosedPublic

Authored by renatoo on May 21 2018, 1:59 PM.

Details

Test Plan

Run "kiofilewidgets-kfileplacesmodeltest" make sure that "testRemoteUrls" is passing

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
renatoo created this revision.May 21 2018, 1:59 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 21 2018, 1:59 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
renatoo requested review of this revision.May 21 2018, 1:59 PM
renatoo updated this revision to Diff 34581.May 21 2018, 2:26 PM

Add missing url

Hmm, still seems to fail here:

$ ctest -R kfileplacesmodeltest
Test project /home/elvis/dev/kde/kio/local-build
    Start 50: kiofilewidgets-kfileplacesmodeltest
1/1 Test #50: kiofilewidgets-kfileplacesmodeltest ...***Failed    0.60 sec
********* Start testing of KFilePlacesModelTest *********
Config: Using QtTest library 5.11.0, Qt 5.11.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 8.1.0)
QDEBUG : KFilePlacesModelTest::initTestCase() void Solid::Backends::Fake::FakeManager::parseMachineFile() Parsing fake computer XML:  "/home/elvis/dev/kde/kio/autotests/fakecomputer.xml" 

PASS   : KFilePlacesModelTest::initTestCase()
FAIL!  : KFilePlacesModelTest::testInitialState() Compared values are not the same
   Actual   (m_places->rowCount()): 6
   Expected (4)                   : 4
   Loc: [../autotests/kfileplacesmodeltest.cpp(200)]
QDEBUG : KFilePlacesModelTest::testInitialList() Expected: ("/home/elvis", "/", "trash:/", "remote:/", "/media/nfs", "/foreign", "/media/floppy0", "/media/XO-Y4", "/media/cdrom")
QDEBUG : KFilePlacesModelTest::testInitialList() Got: ("/home/elvis", "/home/elvis/Desktop", "/home/elvis/Downloads", "/", "trash:/", "remote:/")
FAIL!  : KFilePlacesModelTest::testInitialList() Compared lists have different sizes.
   Actual   (placesUrls()) size: 6
   Expected (urls) size: 9
   Loc: [../autotests/kfileplacesmodeltest.cpp(236)]

Hmm, still seems to fail here:

$ ctest -R kfileplacesmodeltest
Test project /home/elvis/dev/kde/kio/local-build
    Start 50: kiofilewidgets-kfileplacesmodeltest
1/1 Test #50: kiofilewidgets-kfileplacesmodeltest ...***Failed    0.60 sec
********* Start testing of KFilePlacesModelTest *********
Config: Using QtTest library 5.11.0, Qt 5.11.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 8.1.0)
QDEBUG : KFilePlacesModelTest::initTestCase() void Solid::Backends::Fake::FakeManager::parseMachineFile() Parsing fake computer XML:  "/home/elvis/dev/kde/kio/autotests/fakecomputer.xml" 

PASS   : KFilePlacesModelTest::initTestCase()
FAIL!  : KFilePlacesModelTest::testInitialState() Compared values are not the same
   Actual   (m_places->rowCount()): 6
   Expected (4)                   : 4
   Loc: [../autotests/kfileplacesmodeltest.cpp(200)]
QDEBUG : KFilePlacesModelTest::testInitialList() Expected: ("/home/elvis", "/", "trash:/", "remote:/", "/media/nfs", "/foreign", "/media/floppy0", "/media/XO-Y4", "/media/cdrom")
QDEBUG : KFilePlacesModelTest::testInitialList() Got: ("/home/elvis", "/home/elvis/Desktop", "/home/elvis/Downloads", "/", "trash:/", "remote:/")
FAIL!  : KFilePlacesModelTest::testInitialList() Compared lists have different sizes.
   Actual   (placesUrls()) size: 6
   Expected (urls) size: 9
   Loc: [../autotests/kfileplacesmodeltest.cpp(236)]

That's a different test (from the same file). That part of the test assumes that you have a clean home directory. I run this tests with a wrapper, something like:

HOMETMP=$(mktemp -d)
trap 'rm -rf $HOMETMP' EXIT
export HOME="$HOMETMP"

xvfb-run -a dbus-run-session -- obj-x86_64-linux-gnu/bin/kfileplacesmodeltest

The complete version can be seen here:
https://salsa.debian.org/qt-kde-team/kde/kio/tree/master/debian/tests

That's after applying the patches:
https://salsa.debian.org/qt-kde-team/kde/kio/tree/master/debian/patches

The Debian test results can be seen here:
https://ci.debian.net/data/autopkgtest/unstable/amd64/k/kio/342727/log.gz

There is an error in a different part of this test, it seems that kio strips the -full part of the trash icon name but not always. (see src/filewidgets/kfileplacesitem.cpp : 418)

renatoo updated this revision to Diff 34644.May 22 2018, 1:24 PM
renatoo updated this revision to Diff 34645.

Fixed all tests

renatoo updated this revision to Diff 34646.May 22 2018, 1:26 PM

Fixed code style

ok it should work now.

ngraham requested changes to this revision.May 22 2018, 6:42 PM
ngraham added a subscriber: ngraham.

kiofilewidgets-kfileplacesmodeltest still fails for me with this patch:

grep 'FAIL!  : KFilePlacesModelTest' -A 3 Testing/Temporary/LastTest.log 
FAIL!  : KFilePlacesModelTest::testInitialState() Compared values are not the same
   Actual   (m_places->rowCount()): 6
   Expected (4)                   : 4
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(200)]
--
FAIL!  : KFilePlacesModelTest::testInitialList() Compared lists have different sizes.
   Actual   (placesUrls()) size: 6
   Expected (urls) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(236)]
--
FAIL!  : KFilePlacesModelTest::testReparse() Compared lists have different sizes.
   Actual   (placesUrls()) size: 7
   Expected (urls) size: 10
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(252)]
--
FAIL!  : KFilePlacesModelTest::testMove() Compared lists have different sizes.
   Actual   (placesUrls()) size: 7
   Expected (urls) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(396)]
--
FAIL!  : KFilePlacesModelTest::testPlacesLifecycle() Compared lists have different sizes.
   Actual   (placesUrls()) size: 8
   Expected (urls) size: 10
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(552)]
--
FAIL!  : KFilePlacesModelTest::testDevicePlugging() Compared lists differ at index 1.
   Actual   (placesUrls()): "/home/dev/Downloads"
   Expected (urls): "/"
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(665)]
--
FAIL!  : KFilePlacesModelTest::testDragAndDrop() Compared lists have different sizes.
   Actual   (placesUrls()) size: 8
   Expected (urls) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(472)]
FAIL!  : KFilePlacesModelTest::testDeviceSetupTeardown() Compared values are not the same
   Actual   (spy_changed.count()): 0
   Expected (1)                  : 1
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(786)]
--
FAIL!  : KFilePlacesModelTest::testRemoteUrls(Ftp) Compared lists have different sizes.
   Actual   (placesUrls()) size: 9
   Expected (urls) size: 10
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(853)]
--
FAIL!  : KFilePlacesModelTest::testRemoteUrls(Samba) Compared lists differ at index 2.
   Actual   (placesUrls()): "/home/dev/Downloads"
   Expected (urls): "trash:/"
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(853)]
--
FAIL!  : KFilePlacesModelTest::testRemoteUrls(Sftp) Compared lists have different sizes.
   Actual   (placesUrls()) size: 11
   Expected (urls) size: 10
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(853)]
--
FAIL!  : KFilePlacesModelTest::testRemoteUrls(Fish) Compared lists have different sizes.
   Actual   (placesUrls()) size: 12
   Expected (urls) size: 10
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(853)]
--
FAIL!  : KFilePlacesModelTest::testRemoteUrls(Webdav) Compared lists have different sizes.
   Actual   (placesUrls()) size: 13
   Expected (urls) size: 10
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(853)]
--
FAIL!  : KFilePlacesModelTest::testIconRole(Places - Trash) 'index.data(KFilePlacesModel::IconNameRole).toString().startsWith(expectedIconName)' returned FALSE. ()
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(999)]
FAIL!  : KFilePlacesModelTest::testIconRole(Remote - Network) 'index.data(KFilePlacesModel::IconNameRole).toString().startsWith(expectedIconName)' returned FALSE. ()
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(999)]
FAIL!  : KFilePlacesModelTest::testIconRole(Devices - Nfs) 'index.data(KFilePlacesModel::IconNameRole).toString().startsWith(expectedIconName)' returned FALSE. ()
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(999)]
FAIL!  : KFilePlacesModelTest::testIconRole(Devices - foreign) 'index.data(KFilePlacesModel::IconNameRole).toString().startsWith(expectedIconName)' returned FALSE. ()
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(999)]
FAIL!  : KFilePlacesModelTest::testIconRole(Devices - Floppy) 'index.data(KFilePlacesModel::IconNameRole).toString().startsWith(expectedIconName)' returned FALSE. ()
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(999)]
FAIL!  : KFilePlacesModelTest::testIconRole(Devices - cdrom) 'index.data(KFilePlacesModel::IconNameRole).toString().startsWith(expectedIconName)' returned FALSE. ()
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(999)]
FAIL!  : KFilePlacesModelTest::testMoveFunction() Compared lists have different sizes.
   Actual   (placesUrls()) size: 13
   Expected (urls) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(1016)]
--
FAIL!  : KFilePlacesModelTest::testPlaceGroupHidden() Compared lists have different sizes.
   Actual   (placesUrls()) size: 13
   Expected (urls) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(1090)]
--
FAIL!  : KFilePlacesModelTest::testPlaceGroupHiddenAndShownWithHiddenChild() Compared lists have different sizes.
   Actual   (placesUrls()) size: 13
   Expected (urls) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(1157)]
FAIL!  : KFilePlacesModelTest::testPlaceGroupHiddenGroupIndexesIntegrity() Compared values are not the same
   Actual   (m_places->groupIndexes(KFilePlacesModel::PlacesType).count()): 7
   Expected (initialListOfPlaces().count())                               : 3
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(1193)]
--
FAIL!  : KFilePlacesModelTest::testPlaceGroupHiddenRole() Compared values are not the same
   Actual   (index.data(KFilePlacesModel::GroupHiddenRole).toBool()): 1
   Expected (false)                                                 : 0
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(1241)]
--
FAIL!  : KFilePlacesModelTest::testFilterWithAlternativeApplicationName() Compared lists have different sizes.
   Actual   (placesUrls()) size: 13
   Expected (urls) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(1282)]
FAIL!  : KFilePlacesModelTest::testSupportedSchemes() Compared lists have different sizes.
   Actual   (placesUrls()) size: 17
   Expected (initialListOfUrls()) size: 9
   Loc: [/home/dev/repos/kio/autotests/kfileplacesmodeltest.cpp(1295)]
This revision now requires changes to proceed.May 22 2018, 6:42 PM
renatoo added a comment.EditedMay 22 2018, 7:03 PM

as maximilianocuria said, before run the tests you need to create a temporary home path:

HOMETMP=$(mktemp -d)
trap 'rm -rf $HOMETMP' EXIT
export HOME="$HOMETMP"

this test expect an empty home path.

Shouldn't that be a part of the test itself? I don't think it's reasonable to require that testers and testing platforms manually run that every time.

Shouldn't that be a part of the test itself? I don't think it's reasonable to require that testers and testing platforms manually run that every time.

I am not sure, this is how this test works, I never changed that. Maybe ask the maintainers guys.

I know you didn't change that, but it might be a nice enhancement (hint hint). :)

renatoo updated this revision to Diff 34666.May 22 2018, 7:22 PM

Run tests in an empty home dir

I know you didn't change that, but it might be a nice enhancement (hint hint). :)

I know you didn't change that, but it might be a nice enhancement (hint hint). :)

as you wish ;)

ngraham accepted this revision.May 22 2018, 7:30 PM

Much better, thanks for indulging me. :)

Now onto kfileplacesviewtest...

This revision is now accepted and ready to land.May 22 2018, 7:30 PM

this is different "setTestModeEnabled" sets the XDG_* dirs but the KIO tests expects an empty home dir without subfolders like Downloads, Documents, etc..

Closed by commit R241:2c478f4e429b: Fix unit test for kfileplacesmodeltest (authored by Renato Araujo Oliveira Filho <renato.araujo@kdab.com>). · Explain WhyMay 23 2018, 11:33 AM
This revision was automatically updated to reflect the committed changes.