diff options
Diffstat (limited to 'vespalib/src/tests/tutorial/make_tutorial.cpp')
-rw-r--r-- | vespalib/src/tests/tutorial/make_tutorial.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/vespalib/src/tests/tutorial/make_tutorial.cpp b/vespalib/src/tests/tutorial/make_tutorial.cpp index 3f83caef67c..a18c33afeeb 100644 --- a/vespalib/src/tests/tutorial/make_tutorial.cpp +++ b/vespalib/src/tests/tutorial/make_tutorial.cpp @@ -1,5 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> +#include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/slaveproc.h> #include <vespa/vespalib/util/stringfmt.h> #include <sys/mman.h> @@ -29,20 +30,20 @@ std::string runCommand(const std::string &cmd) { return out; } -void insertExample(const std::string &name) { - std::string str = runCommand(make_string("./make_example.sh %s", +void insertExample(const std::string &name, const std::string &src_dir) { + std::string str = runCommand(make_string("%s/make_example.sh %s", src_dir.c_str(), name.c_str())); fprintf(stdout, "%s", str.c_str()); } -void insertSource(const std::string &name) { - std::string str = runCommand(make_string("./make_source.sh %s", +void insertSource(const std::string &name, const std::string &src_dir) { + std::string str = runCommand(make_string("%s/make_source.sh %s", src_dir.c_str(), name.c_str())); fprintf(stdout, "%s", str.c_str()); } -void insertFile(const std::string &name) { - std::string str = readFile(name); +void insertFile(const std::string &name, const std::string &src_dir) { + std::string str = readFile(src_dir + "/" + name); fprintf(stdout, "%s", str.c_str()); } @@ -56,7 +57,7 @@ TEST_MAIN_WITH_PROCESS_PROXY() { size_t pos = 0; size_t end = 0; size_t cursor = 0; - std::string input = readFile("tutorial_source.html"); + std::string input = readFile(vespalib::TestApp::GetSourceDirectory() + "tutorial_source.html"); while ((pos = input.find(pre, cursor)) < input.size() && (end = input.find(post, pos)) < input.size()) { @@ -64,13 +65,16 @@ TEST_MAIN_WITH_PROCESS_PROXY() { pos += pre.size(); if (input.find(example, pos) == pos) { pos += example.size(); - insertExample(std::string((input.data() + pos), (end - pos))); + insertExample(std::string((input.data() + pos), (end - pos)), + vespalib::TestApp::GetSourceDirectory()); } else if (input.find(source, pos) == pos) { pos += source.size(); - insertSource(std::string((input.data() + pos), (end - pos))); + insertSource(std::string((input.data() + pos), (end - pos)), + vespalib::TestApp::GetSourceDirectory()); } else if (input.find(file, pos) == pos) { pos += file.size(); - insertFile(std::string((input.data() + pos), (end - pos))); + insertFile(std::string((input.data() + pos), (end - pos)), + vespalib::TestApp::GetSourceDirectory()); } else { std::string str((input.data() + pos), (end - pos)); TEST_FATAL(make_string("invalid directive >%s<", str.c_str()).c_str()); |