forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectRoot.t.sol
25 lines (21 loc) · 910 Bytes
/
ProjectRoot.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity 0.8.18;
import "ds-test/test.sol";
import "cheats/Vm.sol";
contract ProjectRootTest is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);
bytes public manifestDirBytes;
function testProjectRoot() public {
manifestDirBytes = bytes(vm.envString("CARGO_MANIFEST_DIR"));
for (uint256 i = 0; i < 7; i++) {
manifestDirBytes.pop();
}
// replace "forge" suffix with "testdata" suffix to get expected project root from manifest dir
bytes memory expectedRootSuffix = bytes("testd");
for (uint256 i = 1; i < 6; i++) {
manifestDirBytes[manifestDirBytes.length - i] = expectedRootSuffix[expectedRootSuffix.length - i];
}
bytes memory expectedRootDir = abi.encodePacked(manifestDirBytes, "ata");
assertEq(vm.projectRoot(), string(expectedRootDir));
}
}