Commit 2936e33c authored by Z Duong Nguyen-Huu's avatar Z Duong Nguyen-Huu Committed by Commit Bot

Bytecode expectation rebaseline autodiscovery should work on Window

Change-Id: Ie946870fc46aeeca36924f20dc82d4ea2a0c756f
Reviewed-on: https://chromium-review.googlesource.com/c/1446143Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#59375}
parent b44dbe71
...@@ -25,9 +25,7 @@ using v8::internal::interpreter::BytecodeExpectationsPrinter; ...@@ -25,9 +25,7 @@ using v8::internal::interpreter::BytecodeExpectationsPrinter;
namespace { namespace {
#ifdef V8_OS_POSIX
const char* kGoldenFilesPath = "test/cctest/interpreter/bytecode_expectations/"; const char* kGoldenFilesPath = "test/cctest/interpreter/bytecode_expectations/";
#endif
class ProgramOptions final { class ProgramOptions final {
public: public:
...@@ -129,24 +127,23 @@ bool ParseBoolean(const char* string) { ...@@ -129,24 +127,23 @@ bool ParseBoolean(const char* string) {
const char* BooleanToString(bool value) { return value ? "yes" : "no"; } const char* BooleanToString(bool value) { return value ? "yes" : "no"; }
#ifdef V8_OS_POSIX
bool StrEndsWith(const char* string, const char* suffix) {
int string_size = i::StrLength(string);
int suffix_size = i::StrLength(suffix);
if (string_size < suffix_size) return false;
return strcmp(string + (string_size - suffix_size), suffix) == 0;
}
bool CollectGoldenFiles(std::vector<std::string>* golden_file_list, bool CollectGoldenFiles(std::vector<std::string>* golden_file_list,
const char* directory_path) { const char* directory_path) {
#ifdef V8_OS_POSIX
DIR* directory = opendir(directory_path); DIR* directory = opendir(directory_path);
if (!directory) return false; if (!directory) return false;
auto str_ends_with = [](const char* string, const char* suffix) {
int string_size = i::StrLength(string);
int suffix_size = i::StrLength(suffix);
if (string_size < suffix_size) return false;
return strcmp(string + (string_size - suffix_size), suffix) == 0;
};
dirent* entry = readdir(directory); dirent* entry = readdir(directory);
while (entry) { while (entry) {
if (StrEndsWith(entry->d_name, ".golden")) { if (str_ends_with(entry->d_name, ".golden")) {
std::string golden_filename(kGoldenFilesPath); std::string golden_filename(kGoldenFilesPath);
golden_filename += entry->d_name; golden_filename += entry->d_name;
golden_file_list->push_back(golden_filename); golden_file_list->push_back(golden_filename);
...@@ -155,12 +152,24 @@ bool CollectGoldenFiles(std::vector<std::string>* golden_file_list, ...@@ -155,12 +152,24 @@ bool CollectGoldenFiles(std::vector<std::string>* golden_file_list,
} }
closedir(directory); closedir(directory);
#elif V8_OS_WIN
std::string search_path(directory_path + std::string("/*.golden"));
WIN32_FIND_DATAA fd;
HANDLE find_handle = FindFirstFileA(search_path.c_str(), &fd);
if (find_handle == INVALID_HANDLE_VALUE) return false;
do {
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
std::string golden_filename(kGoldenFilesPath);
std::string temp_filename(fd.cFileName);
golden_filename += temp_filename;
golden_file_list->push_back(golden_filename);
}
} while (FindNextFileA(find_handle, &fd));
FindClose(find_handle);
#endif // V8_OS_POSIX
return true; return true;
} }
#endif // V8_OS_POSIX
// static // static
ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) { ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) {
ProgramOptions options; ProgramOptions options;
...@@ -210,7 +219,7 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) { ...@@ -210,7 +219,7 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) {
} }
if (options.rebaseline_ && options.input_filenames_.empty()) { if (options.rebaseline_ && options.input_filenames_.empty()) {
#ifdef V8_OS_POSIX #if defined(V8_OS_POSIX) || defined(V8_OS_WIN)
if (options.verbose_) { if (options.verbose_) {
std::cout << "Looking for golden files in " << kGoldenFilesPath << '\n'; std::cout << "Looking for golden files in " << kGoldenFilesPath << '\n';
} }
...@@ -219,7 +228,8 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) { ...@@ -219,7 +228,8 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) {
options.parsing_failed_ = true; options.parsing_failed_ = true;
} }
#else #else
REPORT_ERROR("Golden files autodiscovery requires a POSIX OS, sorry."); REPORT_ERROR(
"Golden files autodiscovery requires a POSIX or Window OS, sorry.");
options.parsing_failed_ = true; options.parsing_failed_ = true;
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment