Kaydet (Commit) d15ff312 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst a9ef9437
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment