[libcxx-commits] [libcxx] 50cd964 - [libc++] Rewrite the tests for cin, cout, clog, cerr and friends
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 5 10:27:29 PDT 2020
Author: Louis Dionne
Date: 2020-05-05T13:27:17-04:00
New Revision: 50cd964e6111cfb5026b3948fd5361cd42462f5e
URL: https://github.com/llvm/llvm-project/commit/50cd964e6111cfb5026b3948fd5361cd42462f5e
DIFF: https://github.com/llvm/llvm-project/commit/50cd964e6111cfb5026b3948fd5361cd42462f5e.diff
LOG: [libc++] Rewrite the tests for cin, cout, clog, cerr and friends
The tests were disabled with `#if 0`, most likely because there was no
way of writing shell tests when they were first written.
Added:
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
Modified:
Removed:
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
################################################################################
diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
similarity index 85%
rename from libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
index 5b01f33bf4b0..650537dcb20c 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
@@ -10,6 +10,11 @@
// istream cerr;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} %t.exe 2> %t.err
+// RUN: grep -e 'Hello World!' %t.err
+
#include <iostream>
#include <cassert>
@@ -17,16 +22,15 @@
int main(int, char**)
{
-#if 0
+
std::cerr << "Hello World!\n";
-#else
+
#ifdef _LIBCPP_HAS_NO_STDOUT
assert(std::cerr.tie() == NULL);
#else
assert(std::cerr.tie() == &std::cout);
#endif
assert(std::cerr.flags() & std::ios_base::unitbuf);
-#endif // 0
return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
similarity index 78%
rename from libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
index 0b3672a4585c..386dbbd4721d 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
@@ -12,6 +12,11 @@
// istream cin;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} echo "123" | %t.exe > %t.out
+// RUN: grep -e 'The number is 123!' %t.out
+
#include <iostream>
#include <cassert>
@@ -19,18 +24,14 @@
int main(int, char**)
{
-#if 0
- std::cout << "Hello World!\n";
int i;
- std::cout << "Enter a number: ";
std::cin >> i;
- std::cout << "The number is : " << i << '\n';
-#else // 0
+ std::cout << "The number is " << i << "!";
+
#ifdef _LIBCPP_HAS_NO_STDOUT
assert(std::cin.tie() == NULL);
#else
assert(std::cin.tie() == &std::cout);
-#endif
#endif
return 0;
diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
similarity index 79%
rename from libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
index 68e372947501..32e23bf61c34 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
@@ -10,17 +10,18 @@
// istream clog;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} %t.exe 2> %t.err
+// RUN: grep -e 'Hello World!' %t.err
+
#include <iostream>
#include "test_macros.h"
int main(int, char**)
{
-#if 0
std::clog << "Hello World!\n";
-#else
- (void)std::clog;
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
similarity index 75%
rename from libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
index f1d53b773ac1..f4a066b5c50d 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
@@ -12,21 +12,18 @@
// istream cout;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} %t.exe > %t.out
+// RUN: grep -e 'Hello World!' %t.out
+
#include <iostream>
#include "test_macros.h"
int main(int, char**)
{
-#if 0
std::cout << "Hello World!\n";
- int i;
- std::cout << "Enter a number: ";
- std::cin >> i;
- std::cout << "The number is : " << i << '\n';
-#else // 0
- (void)std::cout;
-#endif
-
- return 0;
+
+ return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
similarity index 84%
rename from libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
index 1683c49fbf6d..30974df3951f 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
@@ -10,6 +10,11 @@
// istream wcerr;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} %t.exe 2> %t.err
+// RUN: grep -e 'Hello World!' %t.err
+
#include <iostream>
#include <cassert>
@@ -17,16 +22,14 @@
int main(int, char**)
{
-#if 0
std::wcerr << L"Hello World!\n";
-#else
+
#ifdef _LIBCPP_HAS_NO_STDOUT
assert(std::wcerr.tie() == NULL);
#else
assert(std::wcerr.tie() == &std::wcout);
#endif
assert(std::wcerr.flags() & std::ios_base::unitbuf);
-#endif // 0
- return 0;
+ return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
similarity index 77%
rename from libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
index c653b2f60678..9d24a37233a8 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
@@ -12,6 +12,11 @@
// istream wcin;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} echo "123" | %t.exe > %t.out
+// RUN: grep -e 'The number is 123!' %t.out
+
#include <iostream>
#include <cassert>
@@ -19,19 +24,15 @@
int main(int, char**)
{
-#if 0
- std::wcout << L"Hello World!\n";
int i;
- std::wcout << L"Enter a number: ";
std::wcin >> i;
- std::wcout << L"The number is : " << i << L'\n';
-#else // 0
+ std::wcout << L"The number is " << i << L"!";
+
#ifdef _LIBCPP_HAS_NO_STDOUT
assert(std::wcin.tie() == NULL);
#else
assert(std::wcin.tie() == &std::wcout);
-#endif
#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
similarity index 79%
rename from libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
index f396500890d8..d1b126067155 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
@@ -10,17 +10,18 @@
// istream wclog;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} %t.exe 2> %t.err
+// RUN: grep -e 'Hello World!' %t.err
+
#include <iostream>
#include "test_macros.h"
int main(int, char**)
{
-#if 0
std::wclog << L"Hello World!\n";
-#else
- (void)std::wclog;
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
similarity index 80%
rename from libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
rename to libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
index b6bd1ef4ea18..0a14f898baa2 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
@@ -12,17 +12,18 @@
// istream wcout;
+// FILE_DEPENDENCIES: %t.exe
+// RUN: %{build}
+// RUN: %{exec} %t.exe > %t.out
+// RUN: grep -e 'Hello World!' %t.out
+
#include <iostream>
#include "test_macros.h"
int main(int, char**)
{
-#if 0
std::wcout << L"Hello World!\n";
-#else
- (void)std::wcout;
-#endif
- return 0;
+ return 0;
}
More information about the libcxx-commits
mailing list