summaryrefslogtreecommitdiff
path: root/test/source/screenshot_test.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-03-06 11:22:08 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-03-06 11:22:08 +0100
commitd15ff312ad80e4d1f210636e3374a81c14c229a2 (patch)
treea09de20b84bafa647b9d6e1aebf683a7912235c6 /test/source/screenshot_test.cxx
parenta9ef943769b06e6bdffe7326f288b27e08a95698 (diff)
Normalize computation of directory and file-in-directory URLs
There are occasional failures of Jenkins "Daily Screenshot Build on Windows" like <https://ci.libreoffice.org/job/lo_tb_master_win_screenshot/324/console> and <https://ci.libreoffice.org/job/lo_tb_master_win_screenshot/332/console>, always failing with > C:/cygwin/home/tdf/lode/jenkins/workspace/lo_tb_master_win_screenshot/test/source/screenshot_test.cxx(84) : error : Assertion > Test name: ReportdesignDialogsTest::openAnyDialog > assertion failed > - Expression: aNew.IsOpen() > - Failed to open <C:/cygwin/home/tdf/lode/jenkins/workspace/lo_tb_master_win_screenshot/workdir/screenshots/modules/dbreport/ui/condformatdialog/CondFormat.png>: 796 (where 796 is ERRCODE_IO_NOTEXISTSPATH). Beats me how that can happen, when ScreenshotTest::implSaveScreenshot first creates the dir and then the file-in- dir (and it is rather unlikely that something else deletes the dir in the meantime, for various builds of that Jenkins bot, always for the same dir workdir/screenshots/modules/dbreport/ui/condformatdialog/), and why it always happens for exactly the same file, workdir/screenshots/modules/dbreport/ui/condformatdialog/CondFormat.png during CppunitTest_reportdesign_dialogs_test. However, one curiosity was that the dir's URL was computed with m_directories.getURLFromWorkdir(aDirname); (without a leading slash inserted before aDirname) while the file's pathname was computed with m_directories.getPathFromWorkdir("/" + aDirname + ...) (with a leading slash inserted before aDirname). Turns out that SvFileStream accepts a URL as well as a pathname, so normalize the computation of the dir's and the file's URL. Maybe that will give a clue why that Jenkins bot sometimes fails. Change-Id: I53b59b51ffc4355c45aa0ca72f6e187cf2010f92
Diffstat (limited to 'test/source/screenshot_test.cxx')
-rw-r--r--test/source/screenshot_test.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx
index 2e7575b0f48d..558e4f160890 100644
--- a/test/source/screenshot_test.cxx
+++ b/test/source/screenshot_test.cxx
@@ -70,18 +70,18 @@ void ScreenshotTest::implSaveScreenshot(const Bitmap& rScreenshot, const OString
aDirname = m_aScreenshotDirectory + "/" + aDirname +
( (maCurrentLanguage == "en-US") ? OUString() : "/" + maCurrentLanguage );
- auto const path = m_directories.getURLFromWorkdir(aDirname);
- auto const e = osl::Directory::createPath(path);
+ auto const dirUrl = m_directories.getURLFromWorkdir(aDirname);
+ auto const e = osl::Directory::createPath(dirUrl);
if (e != osl::FileBase::E_EXIST) {
CPPUNIT_ASSERT_EQUAL_MESSAGE(
OUStringToOString(
- "Failed to create " + path, RTL_TEXTENCODING_UTF8).getStr(),
+ "Failed to create " + dirUrl, RTL_TEXTENCODING_UTF8).getStr(),
osl::FileBase::E_None, e);
}
- OUString aFullPath = m_directories.getPathFromWorkdir("/" + aDirname + "/" + aBasename + ".png");
- SvFileStream aNew(aFullPath, StreamMode::WRITE | StreamMode::TRUNC);
- CPPUNIT_ASSERT_MESSAGE(OUStringToOString("Failed to open <" + aFullPath + ">: " + OUString::number(sal_uInt32(aNew.GetErrorCode())), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen());
+ auto const pngUrl = OUString(dirUrl + "/" + aBasename + ".png");
+ SvFileStream aNew(pngUrl, StreamMode::WRITE | StreamMode::TRUNC);
+ CPPUNIT_ASSERT_MESSAGE(OUStringToOString("Failed to open <" + pngUrl + ">: " + OUString::number(sal_uInt32(aNew.GetErrorCode())), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen());
vcl::PNGWriter aPNGWriter(rScreenshot);
aPNGWriter.Write(aNew);