mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 16:59:35 +01:00
Apply clang-format universally.
* It is tough to contribute to a project that doesn't use a formatter, * It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files * Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose, Let's rip the bandaid off? Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
This commit is contained in:
parent
41bf87ec70
commit
e4f62e4608
587 changed files with 23258 additions and 23135 deletions
|
|
@ -68,4 +68,4 @@ Gen<DerivedPath> Arbitrary<DerivedPath>::arbitrary()
|
|||
});
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace rc
|
||||
|
|
|
|||
|
|
@ -12,28 +12,33 @@ namespace rc {
|
|||
using namespace nix;
|
||||
|
||||
template<>
|
||||
struct Arbitrary<SingleDerivedPath::Opaque> {
|
||||
struct Arbitrary<SingleDerivedPath::Opaque>
|
||||
{
|
||||
static Gen<SingleDerivedPath::Opaque> arbitrary();
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Arbitrary<SingleDerivedPath::Built> {
|
||||
struct Arbitrary<SingleDerivedPath::Built>
|
||||
{
|
||||
static Gen<SingleDerivedPath::Built> arbitrary();
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Arbitrary<SingleDerivedPath> {
|
||||
struct Arbitrary<SingleDerivedPath>
|
||||
{
|
||||
static Gen<SingleDerivedPath> arbitrary();
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Arbitrary<DerivedPath::Built> {
|
||||
struct Arbitrary<DerivedPath::Built>
|
||||
{
|
||||
static Gen<DerivedPath::Built> arbitrary();
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Arbitrary<DerivedPath> {
|
||||
struct Arbitrary<DerivedPath>
|
||||
{
|
||||
static Gen<DerivedPath> arbitrary();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace rc
|
||||
|
|
|
|||
|
|
@ -44,8 +44,9 @@ protected:
|
|||
// no `mkdtemp` with MinGW
|
||||
auto tmpl = nix::defaultTempDir() + "/tests_nix-store.";
|
||||
for (size_t i = 0; true; ++i) {
|
||||
nixDir = tmpl + std::string { i };
|
||||
if (std::filesystem::create_directory(nixDir)) break;
|
||||
nixDir = tmpl + std::string{i};
|
||||
if (std::filesystem::create_directory(nixDir))
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// resolve any symlinks in i.e. on macOS /tmp -> /private/tmp
|
||||
|
|
@ -72,4 +73,4 @@ protected:
|
|||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace nixC
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ namespace rc {
|
|||
using namespace nix;
|
||||
|
||||
template<>
|
||||
struct Arbitrary<OutputsSpec> {
|
||||
struct Arbitrary<OutputsSpec>
|
||||
{
|
||||
static Gen<OutputsSpec> arbitrary();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace rc
|
||||
|
|
|
|||
|
|
@ -7,26 +7,29 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
struct StorePathName {
|
||||
struct StorePathName
|
||||
{
|
||||
std::string name;
|
||||
};
|
||||
|
||||
// For rapidcheck
|
||||
void showValue(const StorePath & p, std::ostream & os);
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
||||
namespace rc {
|
||||
using namespace nix;
|
||||
|
||||
template<>
|
||||
struct Arbitrary<StorePathName> {
|
||||
struct Arbitrary<StorePathName>
|
||||
{
|
||||
static Gen<StorePathName> arbitrary();
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Arbitrary<StorePath> {
|
||||
struct Arbitrary<StorePath>
|
||||
{
|
||||
static Gen<StorePath> arbitrary();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace rc
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@ class ProtoTest : public CharacterizationTest, public LibStoreTest
|
|||
{
|
||||
std::filesystem::path unitTestData = getUnitTestData() / protocolDir;
|
||||
|
||||
std::filesystem::path goldenMaster(std::string_view testStem) const override {
|
||||
return unitTestData / (std::string { testStem + ".bin" });
|
||||
std::filesystem::path goldenMaster(std::string_view testStem) const override
|
||||
{
|
||||
return unitTestData / (std::string{testStem + ".bin"});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -31,10 +32,10 @@ public:
|
|||
{
|
||||
CharacterizationTest::readTest(testStem, [&](const auto & encoded) {
|
||||
T got = ({
|
||||
StringSource from { encoded };
|
||||
StringSource from{encoded};
|
||||
Proto::template Serialise<T>::read(
|
||||
*LibStoreTest::store,
|
||||
typename Proto::ReadConn {
|
||||
typename Proto::ReadConn{
|
||||
.from = from,
|
||||
.version = version,
|
||||
});
|
||||
|
|
@ -54,7 +55,7 @@ public:
|
|||
StringSink to;
|
||||
Proto::template Serialise<T>::write(
|
||||
*LibStoreTest::store,
|
||||
typename Proto::WriteConn {
|
||||
typename Proto::WriteConn{
|
||||
.to = to,
|
||||
.version = version,
|
||||
},
|
||||
|
|
@ -65,11 +66,13 @@ public:
|
|||
};
|
||||
|
||||
#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
|
||||
TEST_F(FIXTURE, NAME ## _read) { \
|
||||
readProtoTest(STEM, VERSION, VALUE); \
|
||||
} \
|
||||
TEST_F(FIXTURE, NAME ## _write) { \
|
||||
writeProtoTest(STEM, VERSION, VALUE); \
|
||||
TEST_F(FIXTURE, NAME##_read) \
|
||||
{ \
|
||||
readProtoTest(STEM, VERSION, VALUE); \
|
||||
} \
|
||||
TEST_F(FIXTURE, NAME##_write) \
|
||||
{ \
|
||||
writeProtoTest(STEM, VERSION, VALUE); \
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ Gen<OutputsSpec> Arbitrary<OutputsSpec>::arbitrary()
|
|||
});
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace rc
|
||||
|
|
|
|||
|
|
@ -16,15 +16,16 @@ void showValue(const StorePath & p, std::ostream & os)
|
|||
os << p.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
||||
namespace rc {
|
||||
using namespace nix;
|
||||
|
||||
Gen<char> storePathChar()
|
||||
{
|
||||
return rc::gen::apply([](uint8_t i) -> char {
|
||||
switch (i) {
|
||||
return rc::gen::apply(
|
||||
[](uint8_t i) -> char {
|
||||
switch (i) {
|
||||
case 0 ... 9:
|
||||
return '0' + i;
|
||||
case 10 ... 35:
|
||||
|
|
@ -45,36 +46,23 @@ Gen<char> storePathChar()
|
|||
return '=';
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
},
|
||||
gen::inRange<uint8_t>(0, 10 + 2 * 26 + 6));
|
||||
}
|
||||
},
|
||||
gen::inRange<uint8_t>(0, 10 + 2 * 26 + 6));
|
||||
}
|
||||
|
||||
Gen<StorePathName> Arbitrary<StorePathName>::arbitrary()
|
||||
{
|
||||
return gen::construct<StorePathName>(
|
||||
gen::suchThat(
|
||||
gen::container<std::string>(storePathChar()),
|
||||
[](const std::string & s) {
|
||||
return
|
||||
!( s == ""
|
||||
|| s == "."
|
||||
|| s == ".."
|
||||
|| s.starts_with(".-")
|
||||
|| s.starts_with("..-")
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
gen::suchThat(gen::container<std::string>(storePathChar()), [](const std::string & s) {
|
||||
return !(s == "" || s == "." || s == ".." || s.starts_with(".-") || s.starts_with("..-"));
|
||||
}));
|
||||
}
|
||||
|
||||
Gen<StorePath> Arbitrary<StorePath>::arbitrary()
|
||||
{
|
||||
return
|
||||
gen::construct<StorePath>(
|
||||
gen::arbitrary<Hash>(),
|
||||
gen::apply([](StorePathName n){ return n.name; }, gen::arbitrary<StorePathName>())
|
||||
);
|
||||
return gen::construct<StorePath>(
|
||||
gen::arbitrary<Hash>(), gen::apply([](StorePathName n) { return n.name; }, gen::arbitrary<StorePathName>()));
|
||||
}
|
||||
|
||||
} // namespace rc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue