mirror of
https://github.com/NixOS/nix.git
synced 2025-11-23 18:59:35 +01:00
Separate headers from source files
The short answer for why we need to do this is so we can consistently do `#include "nix/..."`. Without this change, there are ways to still make that work, but they are hacky, and they have downsides such as making it harder to make sure headers from the wrong Nix library (e..g. `libnixexpr` headers in `libnixutil`) aren't being used. The C API alraedy used `nix_api_*`, so its headers are *not* put in subdirectories accordingly. Progress on #7876 We resisted doing this for a while because it would be annoying to not have the header source file pairs close by / easy to change file path/name from one to the other. But I am ameliorating that with symlinks in the next commit.
This commit is contained in:
parent
326548bae5
commit
f3e1c47f47
664 changed files with 2974 additions and 2913 deletions
80
src/libstore-test-support/path.cc
Normal file
80
src/libstore-test-support/path.cc
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#include <rapidcheck/gen/Arbitrary.h>
|
||||
#include <regex>
|
||||
|
||||
#include <rapidcheck.h>
|
||||
|
||||
#include "nix/path-regex.hh"
|
||||
#include "nix/store-api.hh"
|
||||
|
||||
#include "nix/tests/hash.hh"
|
||||
#include "nix/tests/path.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
void showValue(const StorePath & p, std::ostream & os)
|
||||
{
|
||||
os << p.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace rc {
|
||||
using namespace nix;
|
||||
|
||||
Gen<char> storePathChar()
|
||||
{
|
||||
return rc::gen::apply([](uint8_t i) -> char {
|
||||
switch (i) {
|
||||
case 0 ... 9:
|
||||
return '0' + i;
|
||||
case 10 ... 35:
|
||||
return 'A' + (i - 10);
|
||||
case 36 ... 61:
|
||||
return 'a' + (i - 36);
|
||||
case 62:
|
||||
return '+';
|
||||
case 63:
|
||||
return '-';
|
||||
case 64:
|
||||
return '.';
|
||||
case 65:
|
||||
return '_';
|
||||
case 66:
|
||||
return '?';
|
||||
case 67:
|
||||
return '=';
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
},
|
||||
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<StorePath> Arbitrary<StorePath>::arbitrary()
|
||||
{
|
||||
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