commit 148b137f1829d5b63cfdfdd2257b95bc9a022d28
parent 2383503c4eb7c9966b598f976bd36a3c7ef6d708
Author: Andrew Laack <andrew@laack.co>
Date: Thu, 1 Oct 2026 10:42:36 -0500
Use cwd instead of hardcoded paths
Diffstat:
4 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/benchmarking/render-bench.cpp b/benchmarking/render-bench.cpp
@@ -44,7 +44,7 @@ TEST_CASE("Benchmark web browsing") {
};
}
-TEST_CASE("Benchmarking huge file scrolling", "[.]") {
+TEST_CASE("Benchmarking huge file scrolling") {
setenv("EDITOR", "test" , 1);
writeStringToFile(genAlNumNlSp(10000000), "tests/example.out");
BENCHMARK("5 passes per iteration, 10m character file, load, scroll down 1000x, scroll up 1000x with 100x100 emulated terminal size") {
@@ -53,14 +53,15 @@ TEST_CASE("Benchmarking huge file scrolling", "[.]") {
Browser& b = *bPtr;
DrawState ds {};
ds.bPtr = bPtr;
- std::string st = "file:///home/andrew/gitRepos/gemini-browser/tests/example.out";
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/example.out";
REQUIRE(mainLoop(ds, b, 'o',100,100));
for(auto& ch: st) {
REQUIRE(mainLoop(ds, b, ch,100,100));
}
REQUIRE(mainLoop(ds, b, '\n',100,100));
- REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "file:///home/andrew/gitRepos/gemini-browser/tests/example.out");
+ REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == st);
for(int i = 0; i < 1000; ++i) {
REQUIRE(mainLoop(ds, b, KEY_DOWN,100,100));
@@ -82,14 +83,15 @@ TEST_CASE("Benchmarking large file scrolling", "[.]") {
Browser& b = *bPtr;
DrawState ds {};
ds.bPtr = bPtr;
- std::string st = "file:///home/andrew/gitRepos/gemini-browser/tests/example.out";
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/example.out";
REQUIRE(mainLoop(ds, b, 'o',100,100));
for(auto& ch: st) {
REQUIRE(mainLoop(ds, b, ch,100,100));
}
REQUIRE(mainLoop(ds, b, '\n',100,100));
- REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "file:///home/andrew/gitRepos/gemini-browser/tests/example.out");
+ REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == st);
for(int i = 0; i < 100; ++i) {
REQUIRE(mainLoop(ds, b, KEY_DOWN,100,100));
@@ -103,7 +105,7 @@ TEST_CASE("Benchmarking large file scrolling", "[.]") {
}
-TEST_CASE("Benchmarking small file", "[.]") {
+TEST_CASE("Benchmarking small file") {
setenv("EDITOR", "test" , 1);
@@ -114,7 +116,8 @@ TEST_CASE("Benchmarking small file", "[.]") {
Browser& b = *bPtr;
DrawState ds {};
ds.bPtr = bPtr;
- std::string st = "file:///home/andrew/gitRepos/gemini-browser/tests/sites/all_line_types.gmi";
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/all_line_types.gmi";
REQUIRE(mainLoop(ds, b, 'o',x,y));
@@ -125,7 +128,7 @@ TEST_CASE("Benchmarking small file", "[.]") {
REQUIRE(mainLoop(ds, b, '\n',x,y));
- REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "file:///home/andrew/gitRepos/gemini-browser/tests/sites/all_line_types.gmi");
+ REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == st);
delete bPtr;
};
}
diff --git a/tests/browser-test.cpp b/tests/browser-test.cpp
@@ -30,7 +30,10 @@ std::string genRandom(const int len) {
// TODO: Refactor this to use $HOME
TEST_CASE( "Basic rendering of all line types" ) {
Browser b{};
- b.goToSite("file:///home/andrew/gitRepos/gemini-browser/tests/sites/all_line_types.gmi", true);
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/sites/all_line_types.gmi";
+
+ b.goToSite(st, true);
REQUIRE(b.getCurrentSite()->getBody() == readFileToString("tests/sites/all_line_types.gmi"));
auto strLs = b.renderSite();
auto res = breakLines(strLs, 80,200);
@@ -45,9 +48,13 @@ TEST_CASE( "Basic rendering of all line types" ) {
TEST_CASE( "Basic navigation" ) {
Browser b{};
- b.goToSite("file:///home/andrew/gitRepos/gemini-browser/tests/sites/basic.gmi", true);
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/sites/basic.gmi";
+ std::string st2 = "file://" + cwd + "/tests/sites/basic_2.gmi";
+
+ b.goToSite(st, true);
REQUIRE(b.getCurrentSite()->getBody() == readFileToString("tests/sites/basic.gmi"));
- b.goToSite("file:///home/andrew/gitRepos/gemini-browser/tests/sites/basic_2.gmi", true);
+ b.goToSite(st2, true);
REQUIRE(b.getCurrentSite()->getBody() == readFileToString("tests/sites/basic_2.gmi"));
}
@@ -55,7 +62,10 @@ TEST_CASE( "Basic navigation" ) {
TEST_CASE( "Local filesystem relative navigation" ) {
Browser b{};
- b.goToSite("file:///home/andrew/gitRepos/gemini-browser/tests/sites/basic.gmi", true);
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/sites/basic.gmi";
+
+ b.goToSite(st, true);
REQUIRE(b.getCurrentSite()->getBody() == readFileToString("tests/sites/basic.gmi"));
b.goToSite("basic_2.gmi", true);
REQUIRE(b.getCurrentSite()->getBody() == readFileToString("tests/sites/basic_2.gmi"));
@@ -63,7 +73,10 @@ TEST_CASE( "Local filesystem relative navigation" ) {
TEST_CASE ("Local filesystems navigation via links") {
Browser b{};
- b.goToSite("file:///home/andrew/gitRepos/gemini-browser/tests/sites/basic.gmi", true);
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/sites/basic.gmi";
+
+ b.goToSite(st, true);
REQUIRE(b.getCurrentSite()->getBody() == readFileToString("tests/sites/basic.gmi"));
b.followLinkNumber(1);
REQUIRE(b.getCurrentSite()->getBody() == readFileToString("tests/sites/basic_2.gmi"));
@@ -174,7 +187,9 @@ TEST_CASE("Test encoding allows relative linking with : in parameter") {
TEST_CASE("Sanitize characters to draw tests") {
Browser b {};
- bool res = b.goToSite("file:///home/andrew/gitRepos/gemini-browser/tests/sites/line-return.gmi");
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/sites/line-return.gmi";
+ bool res = b.goToSite(st);
REQUIRE(res);
REQUIRE(b.getCurrentSite()->getStatusCode() >= 20);
diff --git a/tests/fetch-test.cpp b/tests/fetch-test.cpp
@@ -16,7 +16,10 @@ TEST_CASE("Link constructors") {
// this mostly exists in case utils.cpp is busted in some very obvious way.
TEST_CASE("Local Sanity Client") {
auto client = GeminiClient {};
- auto ln = Link{"=> file:///home/andrew/gitRepos/gemini-browser/tests/sites/basic_2.gmi"}; // TODO: Fix
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "=> file://" + cwd + "/tests/sites/basic_2.gmi";
+
+ auto ln = Link{st};
Site* s = client.fetchSite(ln);
std::string expectedSite =
@@ -33,7 +36,10 @@ TEST_CASE("Local Sanity Client") {
TEST_CASE("Match on all .gmi file headers in tests/sites") {
auto client = GeminiClient {};
for(const auto& current: std::filesystem::directory_iterator("tests/sites")) {
- std::string full = "=> file:///home/andrew/gitRepos/gemini-browser/" + current.path().string();
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "=> file://" + cwd + "/";
+
+ std::string full = st + current.path().string();
auto ln = Link{full};
Site* s = client.fetchSite(ln);
REQUIRE(s->getHeader() == "20 text/gemini");
@@ -45,7 +51,9 @@ TEST_CASE("Match on all .gmi file headers in tests/sites") {
TEST_CASE("Match on all .gmi files in tests/sites") {
auto client = GeminiClient {};
for(const auto& current: std::filesystem::directory_iterator("tests/sites")) {
- std::string full = "=> file:///home/andrew/gitRepos/gemini-browser/" + current.path().string();
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "=> file://" + cwd + "/";
+ std::string full = st + current.path().string();
auto ln = Link{full};
Site* s = client.fetchSite(ln);
std::string expectedSite = readFileToString(current.path().string());
diff --git a/tests/puppet-test.cpp b/tests/puppet-test.cpp
@@ -514,8 +514,9 @@ TEST_CASE("Basic usage with small screen sizes") {
Browser& b = *bPtr;
DrawState ds {};
ds.bPtr = bPtr;
- std::string st = "file:///home/andrew/gitRepos/gemini-browser/tests/sites/all_line_types.gmi";
+ std::string cwd = std::filesystem::current_path();
+ std::string st = "file://" + cwd + "/tests/sites/all_line_types.gmi";
REQUIRE(mainLoop(ds, b, 'o',x,y));
@@ -525,7 +526,7 @@ TEST_CASE("Basic usage with small screen sizes") {
REQUIRE(mainLoop(ds, b, '\n',x,y));
- REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "file:///home/andrew/gitRepos/gemini-browser/tests/sites/all_line_types.gmi");
+ REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == st);
delete bPtr;
}
}