Accepting request 1238757 from science
OBS-URL: https://build.opensuse.org/request/show/1238757 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/FreeCAD?expand=0&rev=52
This commit is contained in:
commit
b1131d6b92
51
Add-property-read-write-test.patch
Normal file
51
Add-property-read-write-test.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From 6f23f01e509348a6755ad3c465a3d7ffd758ee03 Mon Sep 17 00:00:00 2001
|
||||
From: wmayer <wmayer@freecad.org>
|
||||
Date: Sat, 28 Sep 2024 00:29:40 +0200
|
||||
Subject: [PATCH] Tests: Add unit test for PR #16763
|
||||
|
||||
---
|
||||
tests/src/App/Property.cpp | 27 +++++++++++++++++++++++++++
|
||||
1 file changed, 27 insertions(+)
|
||||
|
||||
diff --git a/tests/src/App/Property.cpp b/tests/src/App/Property.cpp
|
||||
index 9ab8aeffa6c1..528ca56f2fa1 100644
|
||||
--- a/tests/src/App/Property.cpp
|
||||
+++ b/tests/src/App/Property.cpp
|
||||
@@ -1,6 +1,9 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "App/PropertyLinks.h"
|
||||
+#include <App/PropertyStandard.h>
|
||||
+#include <Base/Writer.h>
|
||||
+#include <Base/Reader.h>
|
||||
|
||||
TEST(PropertyLink, TestSetValues)
|
||||
{
|
||||
@@ -13,3 +16,27 @@ TEST(PropertyLink, TestSetValues)
|
||||
EXPECT_EQ(sub[0], "Sub1");
|
||||
EXPECT_EQ(sub[1], "Sub2");
|
||||
}
|
||||
+
|
||||
+TEST(PropertyFloatTest, testWriteRead)
|
||||
+{
|
||||
+#if defined(FC_OS_LINUX) || defined(FC_OS_BSD)
|
||||
+ setlocale(LC_ALL, "");
|
||||
+ setlocale(LC_NUMERIC, "C"); // avoid rounding of floating point numbers
|
||||
+#endif
|
||||
+ double value = 1.2345;
|
||||
+ App::PropertyFloat prop;
|
||||
+ prop.setValue(value);
|
||||
+ Base::StringWriter writer;
|
||||
+ prop.Save(writer);
|
||||
+
|
||||
+ std::string str = "<?xml version='1.0' encoding='utf-8'?>\n";
|
||||
+ str.append("<Property name='Length' type='App::PropertyFloat'>\n");
|
||||
+ str.append(writer.getString());
|
||||
+ str.append("</Property>\n");
|
||||
+
|
||||
+ std::stringstream data(str);
|
||||
+ Base::XMLReader reader("Document.xml", data);
|
||||
+ App::PropertyFloat prop2;
|
||||
+ prop2.Restore(reader);
|
||||
+ EXPECT_DOUBLE_EQ(prop2.getValue(), value);
|
||||
+}
|
461
Fix-test-failure-temporary-file-race.patch
Normal file
461
Fix-test-failure-temporary-file-race.patch
Normal file
@ -0,0 +1,461 @@
|
||||
From a0e1a31623e334d7186e687c33fad3887e91ee2e Mon Sep 17 00:00:00 2001
|
||||
From: wwmayer <wmayer@freecad.org>
|
||||
Date: Fri, 20 Dec 2024 17:42:02 +0100
|
||||
Subject: [PATCH] Test: Support of parallel execution of reader tests (#18587)
|
||||
|
||||
* Tests: Initialize xerces sub-system in order to parse XML files
|
||||
|
||||
* Test: Support of parallel execution of reader tests
|
||||
|
||||
Fixes #18549
|
||||
---
|
||||
tests/src/App/Property.cpp | 12 +-
|
||||
tests/src/Base/Reader.cpp | 222 ++++++++++++++++------------
|
||||
tests/src/Mod/Mesh/App/Importer.cpp | 12 +-
|
||||
3 files changed, 146 insertions(+), 100 deletions(-)
|
||||
|
||||
diff --git a/tests/src/App/Property.cpp b/tests/src/App/Property.cpp
|
||||
index 528ca56f2fa1..4589f5b8b981 100644
|
||||
--- a/tests/src/App/Property.cpp
|
||||
+++ b/tests/src/App/Property.cpp
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
+#include <xercesc/util/PlatformUtils.hpp>
|
||||
|
||||
TEST(PropertyLink, TestSetValues)
|
||||
{
|
||||
@@ -17,7 +18,16 @@ TEST(PropertyLink, TestSetValues)
|
||||
EXPECT_EQ(sub[1], "Sub2");
|
||||
}
|
||||
|
||||
-TEST(PropertyFloatTest, testWriteRead)
|
||||
+class PropertyFloatTest: public ::testing::Test
|
||||
+{
|
||||
+protected:
|
||||
+ static void SetUpTestSuite()
|
||||
+ {
|
||||
+ XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+TEST_F(PropertyFloatTest, testWriteRead)
|
||||
{
|
||||
#if defined(FC_OS_LINUX) || defined(FC_OS_BSD)
|
||||
setlocale(LC_ALL, "");
|
||||
diff --git a/tests/src/Base/Reader.cpp b/tests/src/Base/Reader.cpp
|
||||
index 79038059d077..da308a41c89b 100644
|
||||
--- a/tests/src/Base/Reader.cpp
|
||||
+++ b/tests/src/Base/Reader.cpp
|
||||
@@ -15,18 +15,16 @@
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
-class ReaderTest: public ::testing::Test
|
||||
+class ReaderXML
|
||||
{
|
||||
-protected:
|
||||
- void SetUp() override
|
||||
+public:
|
||||
+ ReaderXML()
|
||||
{
|
||||
- XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
|
||||
_tempDir = fs::temp_directory_path();
|
||||
- std::string filename = "unit_test_Reader.xml";
|
||||
+ fs::path filename = fs::unique_path("unit_test_Reader-%%%%.xml");
|
||||
_tempFile = _tempDir / filename;
|
||||
}
|
||||
-
|
||||
- void TearDown() override
|
||||
+ ~ReaderXML()
|
||||
{
|
||||
if (inputStream.is_open()) {
|
||||
inputStream.close();
|
||||
@@ -36,6 +34,11 @@ class ReaderTest: public ::testing::Test
|
||||
}
|
||||
}
|
||||
|
||||
+ Base::XMLReader* Reader()
|
||||
+ {
|
||||
+ return _reader.get();
|
||||
+ }
|
||||
+
|
||||
void givenDataAsXMLStream(const std::string& data)
|
||||
{
|
||||
auto stringData =
|
||||
@@ -48,11 +51,6 @@ class ReaderTest: public ::testing::Test
|
||||
_reader = std::make_unique<Base::XMLReader>(_tempFile.string().c_str(), inputStream);
|
||||
}
|
||||
|
||||
- Base::XMLReader* Reader()
|
||||
- {
|
||||
- return _reader.get();
|
||||
- }
|
||||
-
|
||||
private:
|
||||
std::unique_ptr<Base::XMLReader> _reader;
|
||||
fs::path _tempDir;
|
||||
@@ -60,14 +58,27 @@ class ReaderTest: public ::testing::Test
|
||||
std::ifstream inputStream;
|
||||
};
|
||||
|
||||
+class ReaderTest: public ::testing::Test
|
||||
+{
|
||||
+protected:
|
||||
+ void SetUp() override
|
||||
+ {
|
||||
+ XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
|
||||
+ }
|
||||
+
|
||||
+ void TearDown() override
|
||||
+ {}
|
||||
+};
|
||||
+
|
||||
TEST_F(ReaderTest, beginCharStreamNormal)
|
||||
{
|
||||
// Arrange
|
||||
- givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
- Reader()->readElement("data");
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
|
||||
// Act
|
||||
- auto& result = Reader()->beginCharStream();
|
||||
+ auto& result = xml.Reader()->beginCharStream();
|
||||
|
||||
// Assert
|
||||
EXPECT_TRUE(result.good());
|
||||
@@ -76,11 +87,12 @@ TEST_F(ReaderTest, beginCharStreamNormal)
|
||||
TEST_F(ReaderTest, beginCharStreamOpenClose)
|
||||
{
|
||||
// Arrange
|
||||
- givenDataAsXMLStream("<data id='12345' />");
|
||||
- Reader()->readElement("data");
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data id='12345' />");
|
||||
+ xml.Reader()->readElement("data");
|
||||
|
||||
// Act
|
||||
- auto& result = Reader()->beginCharStream(); // Not an error, even though there is no data
|
||||
+ auto& result = xml.Reader()->beginCharStream(); // Not an error, even though there is no data
|
||||
|
||||
// Assert
|
||||
EXPECT_TRUE(result.good());
|
||||
@@ -89,23 +101,25 @@ TEST_F(ReaderTest, beginCharStreamOpenClose)
|
||||
TEST_F(ReaderTest, beginCharStreamAlreadyBegun)
|
||||
{
|
||||
// Arrange
|
||||
- givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
- Reader()->readElement("data");
|
||||
- Reader()->beginCharStream();
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
+ xml.Reader()->beginCharStream();
|
||||
|
||||
// Act & Assert
|
||||
- EXPECT_THROW(Reader()->beginCharStream(), Base::XMLParseException); // NOLINT
|
||||
+ EXPECT_THROW(xml.Reader()->beginCharStream(), Base::XMLParseException); // NOLINT
|
||||
}
|
||||
|
||||
TEST_F(ReaderTest, charStreamGood)
|
||||
{
|
||||
// Arrange
|
||||
- givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
- Reader()->readElement("data");
|
||||
- Reader()->beginCharStream();
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
+ xml.Reader()->beginCharStream();
|
||||
|
||||
// Act
|
||||
- auto& result = Reader()->charStream();
|
||||
+ auto& result = xml.Reader()->charStream();
|
||||
|
||||
// Assert
|
||||
EXPECT_TRUE(result.good());
|
||||
@@ -114,33 +128,36 @@ TEST_F(ReaderTest, charStreamGood)
|
||||
TEST_F(ReaderTest, charStreamBad)
|
||||
{
|
||||
// Arrange
|
||||
- givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
- Reader()->readElement("data");
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
|
||||
// Act & Assert
|
||||
- EXPECT_THROW(Reader()->charStream(), Base::XMLParseException); // NOLINT
|
||||
+ EXPECT_THROW(xml.Reader()->charStream(), Base::XMLParseException); // NOLINT
|
||||
}
|
||||
|
||||
TEST_F(ReaderTest, endCharStreamGood)
|
||||
{
|
||||
// Arrange
|
||||
- givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
- Reader()->readElement("data");
|
||||
- Reader()->beginCharStream();
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
+ xml.Reader()->beginCharStream();
|
||||
|
||||
// Act & Assert
|
||||
- Reader()->endCharStream(); // Does not throw
|
||||
+ xml.Reader()->endCharStream(); // Does not throw
|
||||
}
|
||||
|
||||
TEST_F(ReaderTest, endCharStreamBad)
|
||||
{
|
||||
// Arrange
|
||||
- givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
- Reader()->readElement("data");
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>Test ASCII data</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
// Do not open the stream...
|
||||
|
||||
// Act & Assert
|
||||
- Reader()->endCharStream(); // Does not throw, even with no open stream
|
||||
+ xml.Reader()->endCharStream(); // Does not throw, even with no open stream
|
||||
}
|
||||
|
||||
TEST_F(ReaderTest, readDataSmallerThanBuffer)
|
||||
@@ -148,13 +165,14 @@ TEST_F(ReaderTest, readDataSmallerThanBuffer)
|
||||
// Arrange
|
||||
constexpr size_t bufferSize {20};
|
||||
std::string expectedData {"Test ASCII data"};
|
||||
- givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
- Reader()->readElement("data");
|
||||
- Reader()->beginCharStream();
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
+ xml.Reader()->beginCharStream();
|
||||
std::array<char, bufferSize> buffer {};
|
||||
|
||||
// Act
|
||||
- auto bytesRead = Reader()->read(buffer.data(), bufferSize);
|
||||
+ auto bytesRead = xml.Reader()->read(buffer.data(), bufferSize);
|
||||
|
||||
// Assert
|
||||
EXPECT_STREQ(expectedData.c_str(), buffer.data());
|
||||
@@ -166,13 +184,14 @@ TEST_F(ReaderTest, readDataLargerThanBuffer)
|
||||
// Arrange
|
||||
constexpr size_t bufferSize {5};
|
||||
std::string expectedData {"Test ASCII data"};
|
||||
- givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
- Reader()->readElement("data");
|
||||
- Reader()->beginCharStream();
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
+ xml.Reader()->beginCharStream();
|
||||
std::array<char, bufferSize> buffer {};
|
||||
|
||||
// Act
|
||||
- auto bytesRead = Reader()->read(buffer.data(), bufferSize);
|
||||
+ auto bytesRead = xml.Reader()->read(buffer.data(), bufferSize);
|
||||
|
||||
// Assert
|
||||
for (size_t i = 0; i < bufferSize; ++i) {
|
||||
@@ -186,14 +205,15 @@ TEST_F(ReaderTest, readDataLargerThanBufferSecondRead)
|
||||
// Arrange
|
||||
constexpr size_t bufferSize {5};
|
||||
std::string expectedData {"Test ASCII data"};
|
||||
- givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
- Reader()->readElement("data");
|
||||
- Reader()->beginCharStream();
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
+ xml.Reader()->beginCharStream();
|
||||
std::array<char, bufferSize> buffer {};
|
||||
- Reader()->read(buffer.data(), bufferSize); // Read the first five bytes
|
||||
+ xml.Reader()->read(buffer.data(), bufferSize); // Read the first five bytes
|
||||
|
||||
// Act
|
||||
- auto bytesRead = Reader()->read(buffer.data(), bufferSize); // Second five bytes
|
||||
+ auto bytesRead = xml.Reader()->read(buffer.data(), bufferSize); // Second five bytes
|
||||
|
||||
// Assert
|
||||
for (size_t i = 0; i < bufferSize; ++i) {
|
||||
@@ -207,12 +227,13 @@ TEST_F(ReaderTest, readDataNotStarted)
|
||||
// Arrange
|
||||
constexpr size_t bufferSize {20};
|
||||
std::string expectedData {"Test ASCII data"};
|
||||
- givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
- Reader()->readElement("data");
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>" + expectedData + "</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
std::array<char, bufferSize> buffer {};
|
||||
|
||||
// Act
|
||||
- auto bytesRead = Reader()->read(buffer.data(), bufferSize);
|
||||
+ auto bytesRead = xml.Reader()->read(buffer.data(), bufferSize);
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(-1, bytesRead); // Because we didn't call beginCharStream
|
||||
@@ -225,28 +246,29 @@ TEST_F(ReaderTest, readNextStartElement)
|
||||
<node2 attr='2'>Node2</node2>
|
||||
)";
|
||||
|
||||
- givenDataAsXMLStream(xmlBody);
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream(xmlBody);
|
||||
|
||||
// start of document
|
||||
- EXPECT_TRUE(Reader()->isStartOfDocument());
|
||||
- Reader()->readElement("document");
|
||||
- EXPECT_STREQ(Reader()->localName(), "document");
|
||||
+ EXPECT_TRUE(xml.Reader()->isStartOfDocument());
|
||||
+ xml.Reader()->readElement("document");
|
||||
+ EXPECT_STREQ(xml.Reader()->localName(), "document");
|
||||
|
||||
// next element
|
||||
- EXPECT_TRUE(Reader()->readNextElement());
|
||||
- EXPECT_STREQ(Reader()->localName(), "node1");
|
||||
- EXPECT_STREQ(Reader()->getAttribute("attr"), "1");
|
||||
- Reader()->readEndElement("node1");
|
||||
- EXPECT_TRUE(Reader()->isEndOfElement());
|
||||
+ EXPECT_TRUE(xml.Reader()->readNextElement());
|
||||
+ EXPECT_STREQ(xml.Reader()->localName(), "node1");
|
||||
+ EXPECT_STREQ(xml.Reader()->getAttribute("attr"), "1");
|
||||
+ xml.Reader()->readEndElement("node1");
|
||||
+ EXPECT_TRUE(xml.Reader()->isEndOfElement());
|
||||
|
||||
// next element
|
||||
- EXPECT_TRUE(Reader()->readNextElement());
|
||||
- EXPECT_STREQ(Reader()->localName(), "node2");
|
||||
- EXPECT_STREQ(Reader()->getAttribute("attr"), "2");
|
||||
- Reader()->readEndElement("node2");
|
||||
- EXPECT_TRUE(Reader()->isEndOfElement());
|
||||
- Reader()->readEndElement("document");
|
||||
- EXPECT_TRUE(Reader()->isEndOfDocument());
|
||||
+ EXPECT_TRUE(xml.Reader()->readNextElement());
|
||||
+ EXPECT_STREQ(xml.Reader()->localName(), "node2");
|
||||
+ EXPECT_STREQ(xml.Reader()->getAttribute("attr"), "2");
|
||||
+ xml.Reader()->readEndElement("node2");
|
||||
+ EXPECT_TRUE(xml.Reader()->isEndOfElement());
|
||||
+ xml.Reader()->readEndElement("document");
|
||||
+ EXPECT_TRUE(xml.Reader()->isEndOfDocument());
|
||||
}
|
||||
|
||||
TEST_F(ReaderTest, readNextStartEndElement)
|
||||
@@ -256,24 +278,25 @@ TEST_F(ReaderTest, readNextStartEndElement)
|
||||
<node2 attr='2'/>
|
||||
)";
|
||||
|
||||
- givenDataAsXMLStream(xmlBody);
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream(xmlBody);
|
||||
|
||||
// start of document
|
||||
- EXPECT_TRUE(Reader()->isStartOfDocument());
|
||||
- Reader()->readElement("document");
|
||||
- EXPECT_STREQ(Reader()->localName(), "document");
|
||||
+ EXPECT_TRUE(xml.Reader()->isStartOfDocument());
|
||||
+ xml.Reader()->readElement("document");
|
||||
+ EXPECT_STREQ(xml.Reader()->localName(), "document");
|
||||
|
||||
// next element
|
||||
- EXPECT_TRUE(Reader()->readNextElement());
|
||||
- EXPECT_STREQ(Reader()->localName(), "node1");
|
||||
- EXPECT_STREQ(Reader()->getAttribute("attr"), "1");
|
||||
+ EXPECT_TRUE(xml.Reader()->readNextElement());
|
||||
+ EXPECT_STREQ(xml.Reader()->localName(), "node1");
|
||||
+ EXPECT_STREQ(xml.Reader()->getAttribute("attr"), "1");
|
||||
|
||||
// next element
|
||||
- EXPECT_TRUE(Reader()->readNextElement());
|
||||
- EXPECT_STREQ(Reader()->localName(), "node2");
|
||||
- EXPECT_STREQ(Reader()->getAttribute("attr"), "2");
|
||||
- EXPECT_FALSE(Reader()->readNextElement());
|
||||
- EXPECT_TRUE(Reader()->isEndOfDocument());
|
||||
+ EXPECT_TRUE(xml.Reader()->readNextElement());
|
||||
+ EXPECT_STREQ(xml.Reader()->localName(), "node2");
|
||||
+ EXPECT_STREQ(xml.Reader()->getAttribute("attr"), "2");
|
||||
+ EXPECT_FALSE(xml.Reader()->readNextElement());
|
||||
+ EXPECT_TRUE(xml.Reader()->isEndOfDocument());
|
||||
}
|
||||
|
||||
TEST_F(ReaderTest, charStreamBase64Encoded)
|
||||
@@ -281,13 +304,14 @@ TEST_F(ReaderTest, charStreamBase64Encoded)
|
||||
// Arrange
|
||||
static constexpr size_t bufferSize {100};
|
||||
std::array<char, bufferSize> buffer {};
|
||||
- givenDataAsXMLStream("<data>RnJlZUNBRCByb2NrcyEg8J+qqPCfqqjwn6qo\n</data>");
|
||||
- Reader()->readElement("data");
|
||||
- Reader()->beginCharStream(Base::CharStreamFormat::Base64Encoded);
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream("<data>RnJlZUNBRCByb2NrcyEg8J+qqPCfqqjwn6qo\n</data>");
|
||||
+ xml.Reader()->readElement("data");
|
||||
+ xml.Reader()->beginCharStream(Base::CharStreamFormat::Base64Encoded);
|
||||
|
||||
// Act
|
||||
- Reader()->charStream().getline(buffer.data(), bufferSize);
|
||||
- Reader()->endCharStream();
|
||||
+ xml.Reader()->charStream().getline(buffer.data(), bufferSize);
|
||||
+ xml.Reader()->endCharStream();
|
||||
|
||||
// Assert
|
||||
// Conversion done using https://www.base64encode.org for testing purposes
|
||||
@@ -302,22 +326,23 @@ TEST_F(ReaderTest, validDefaults)
|
||||
<node2 attr='2'/>
|
||||
)";
|
||||
|
||||
- givenDataAsXMLStream(xmlBody);
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream(xmlBody);
|
||||
|
||||
// Act
|
||||
- const char* value2 = Reader()->getAttribute("missing", "expected value");
|
||||
- int value4 = Reader()->getAttributeAsInteger("missing", "-123");
|
||||
- unsigned value6 = Reader()->getAttributeAsUnsigned("missing", "123");
|
||||
- double value8 = Reader()->getAttributeAsFloat("missing", "1.234");
|
||||
+ const char* value2 = xml.Reader()->getAttribute("missing", "expected value");
|
||||
+ int value4 = xml.Reader()->getAttributeAsInteger("missing", "-123");
|
||||
+ unsigned value6 = xml.Reader()->getAttributeAsUnsigned("missing", "123");
|
||||
+ double value8 = xml.Reader()->getAttributeAsFloat("missing", "1.234");
|
||||
|
||||
// Assert
|
||||
- EXPECT_THROW({ Reader()->getAttributeAsInteger("missing"); }, Base::XMLBaseException);
|
||||
+ EXPECT_THROW({ xml.Reader()->getAttributeAsInteger("missing"); }, Base::XMLBaseException);
|
||||
EXPECT_EQ(value2, "expected value");
|
||||
- EXPECT_THROW({ Reader()->getAttributeAsInteger("missing"); }, Base::XMLBaseException);
|
||||
+ EXPECT_THROW({ xml.Reader()->getAttributeAsInteger("missing"); }, Base::XMLBaseException);
|
||||
EXPECT_EQ(value4, -123);
|
||||
- EXPECT_THROW({ Reader()->getAttributeAsUnsigned("missing"); }, Base::XMLBaseException);
|
||||
+ EXPECT_THROW({ xml.Reader()->getAttributeAsUnsigned("missing"); }, Base::XMLBaseException);
|
||||
EXPECT_EQ(value6, 123);
|
||||
- EXPECT_THROW({ Reader()->getAttributeAsFloat("missing"); }, Base::XMLBaseException);
|
||||
+ EXPECT_THROW({ xml.Reader()->getAttributeAsFloat("missing"); }, Base::XMLBaseException);
|
||||
EXPECT_NEAR(value8, 1.234, 0.001);
|
||||
}
|
||||
|
||||
@@ -329,16 +354,17 @@ TEST_F(ReaderTest, invalidDefaults)
|
||||
<node2 attr='2'/>
|
||||
)";
|
||||
|
||||
- givenDataAsXMLStream(xmlBody);
|
||||
+ ReaderXML xml;
|
||||
+ xml.givenDataAsXMLStream(xmlBody);
|
||||
|
||||
// Act / Assert
|
||||
EXPECT_THROW(
|
||||
- { Reader()->getAttributeAsInteger("missing", "Not an Integer"); },
|
||||
+ { xml.Reader()->getAttributeAsInteger("missing", "Not an Integer"); },
|
||||
std::invalid_argument);
|
||||
EXPECT_THROW(
|
||||
- { Reader()->getAttributeAsInteger("missing", "Not an Unsigned"); },
|
||||
+ { xml.Reader()->getAttributeAsInteger("missing", "Not an Unsigned"); },
|
||||
std::invalid_argument);
|
||||
EXPECT_THROW(
|
||||
- { Reader()->getAttributeAsInteger("missing", "Not a Float"); },
|
||||
+ { xml.Reader()->getAttributeAsInteger("missing", "Not a Float"); },
|
||||
std::invalid_argument);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package FreeCAD-test
|
||||
#
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
|
@ -1,3 +1,18 @@
|
||||
-------------------------------------------------------------------
|
||||
Sat Jan 18 07:29:36 UTC 2025 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
|
||||
|
||||
- Update smesh-Fix-build-failure-with-vtk-9_4.patch to final
|
||||
version, fix OBS reject due to source mismatch.
|
||||
- Fix spurious failures of ReaderTest, add
|
||||
* Add-property-read-write-test.patch
|
||||
* Fix-test-failure-temporary-file-race.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 17 20:48:54 UTC 2024 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
|
||||
|
||||
- Fix build with VTK 9.4, add
|
||||
smesh-Fix-build-failure-with-vtk-9_4.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 19 17:58:13 UTC 2024 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package FreeCAD
|
||||
#
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -56,6 +56,12 @@ Patch9: 0001-Fix-variable-name-for-OpenGL-library.patch
|
||||
# PATCH-FIX-OPENSUSE
|
||||
Patch14: freecad-opengl.patch
|
||||
# PATCH-FIX-UPSTREAM
|
||||
Patch15: https://github.com/FreeCAD/FreeCAD/commit/3b502359353e2a74dee8a8bcfed5750b69f32cdc.patch#/smesh-Fix-build-failure-with-vtk-9_4.patch
|
||||
# PATCH-FIX-UPSTREAM -- Prereq for Fix-test-failure-temporary-file-race.patch
|
||||
Patch16: https://github.com/FreeCAD/FreeCAD/commit/6f23f01e509348a6755ad3c465a3d7ffd758ee03.patch#/Add-property-read-write-test.patch
|
||||
# PATCH-FIX-UPSTREAM -- https://github.com/FreeCAD/FreeCAD/commit/a0e1a31623e334d7186e687c33fad3887e91ee2e -- rebased
|
||||
Patch17: Fix-test-failure-temporary-file-race.patch
|
||||
# PATCH-FIX-UPSTREAM
|
||||
Patch50: https://github.com/Ondsel-Development/OndselSolver/commit/2e3659c4bce3e6885269e0cb3d640261b2a91108.patch#/ondselsolver_fix_gcc_75_filesystem.patch
|
||||
|
||||
# Test suite fails on 32bit and I don't want to debug that anymore
|
||||
@ -165,6 +171,7 @@ This package contains the files needed for development with FreeCAD.
|
||||
%prep
|
||||
%autosetup -c -N
|
||||
%autopatch -p1 -M 49
|
||||
|
||||
# Run manually, have to inject the 3rdParty path
|
||||
cat %{P:50} | patch --verbose -d src/3rdParty/OndselSolver -p1
|
||||
|
||||
|
71
smesh-Fix-build-failure-with-vtk-9_4.patch
Normal file
71
smesh-Fix-build-failure-with-vtk-9_4.patch
Normal file
@ -0,0 +1,71 @@
|
||||
From 3b502359353e2a74dee8a8bcfed5750b69f32cdc Mon Sep 17 00:00:00 2001
|
||||
From: wmayer <wmayer@freecad.org>
|
||||
Date: Mon, 16 Dec 2024 10:56:43 +0100
|
||||
Subject: [PATCH] smesh: Fix build failure with vtk 9.4
|
||||
|
||||
Fixes #18423
|
||||
---
|
||||
.../src/SMDS/SMDS_UnstructuredGrid.cpp | 17 ++++++++++-------
|
||||
1 file changed, 10 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/3rdParty/salomesmesh/src/SMDS/SMDS_UnstructuredGrid.cpp b/src/3rdParty/salomesmesh/src/SMDS/SMDS_UnstructuredGrid.cpp
|
||||
index e9895d615717..4e9d6dc05764 100644
|
||||
--- a/src/3rdParty/salomesmesh/src/SMDS/SMDS_UnstructuredGrid.cpp
|
||||
+++ b/src/3rdParty/salomesmesh/src/SMDS/SMDS_UnstructuredGrid.cpp
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <vtkDoubleArray.h>
|
||||
#include <vtkIdTypeArray.h>
|
||||
#include <vtkUnsignedCharArray.h>
|
||||
+#include <vtkVersionMacros.h>
|
||||
|
||||
#include <list>
|
||||
#include <climits>
|
||||
@@ -249,14 +250,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
}
|
||||
}
|
||||
|
||||
- if (this->FaceLocations)
|
||||
+ vtkIdTypeArray* thisFaceLocations = GetFaceLocations();
|
||||
+ vtkIdTypeArray* thisFaces = GetFaces();
|
||||
+ if (thisFaceLocations)
|
||||
{
|
||||
vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New();
|
||||
newFaceLocations->Initialize();
|
||||
newFaceLocations->Allocate(newTypes->GetSize());
|
||||
vtkIdTypeArray *newFaces = vtkIdTypeArray::New();
|
||||
newFaces->Initialize();
|
||||
- newFaces->Allocate(this->Faces->GetSize());
|
||||
+ newFaces->Allocate(thisFaces->GetSize());
|
||||
for (int i = 0; i < oldCellSize; i++)
|
||||
{
|
||||
if (this->Types->GetValue(i) == VTK_EMPTY_CELL)
|
||||
@@ -265,16 +268,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
if (newTypes->GetValue(newCellId) == VTK_POLYHEDRON)
|
||||
{
|
||||
newFaceLocations->InsertNextValue(newFaces->GetMaxId()+1);
|
||||
- int oldFaceLoc = this->FaceLocations->GetValue(i);
|
||||
- int nCellFaces = this->Faces->GetValue(oldFaceLoc++);
|
||||
+ int oldFaceLoc = thisFaceLocations->GetValue(i);
|
||||
+ int nCellFaces = thisFaces->GetValue(oldFaceLoc++);
|
||||
newFaces->InsertNextValue(nCellFaces);
|
||||
for (int n=0; n<nCellFaces; n++)
|
||||
{
|
||||
- int nptsInFace = this->Faces->GetValue(oldFaceLoc++);
|
||||
+ int nptsInFace = thisFaces->GetValue(oldFaceLoc++);
|
||||
newFaces->InsertNextValue(nptsInFace);
|
||||
for (int k=0; k<nptsInFace; k++)
|
||||
{
|
||||
- int oldpt = this->Faces->GetValue(oldFaceLoc++);
|
||||
+ int oldpt = thisFaces->GetValue(oldFaceLoc++);
|
||||
newFaces->InsertNextValue(idNodesOldToNew[oldpt]);
|
||||
}
|
||||
}
|
||||
@@ -292,7 +295,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
}
|
||||
else
|
||||
{
|
||||
- this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces);
|
||||
+ this->SetCells(newTypes, newLocations, newConnectivity, thisFaceLocations, thisFaces);
|
||||
}
|
||||
|
||||
newPoints->Delete();
|
Loading…
x
Reference in New Issue
Block a user