/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
#include <glog/logging.h>
-#include <gtest/gtest.h>
#include <folly/Shell.h>
+#include <folly/portability/GTest.h>
using namespace folly;
}
TEST(Shell, Shellify) {
+ auto command = "rm -rf /"_shellify();
+ EXPECT_EQ(command[0], "/bin/sh");
+ EXPECT_EQ(command[1], "-c");
+ EXPECT_EQ(command[2], "rm -rf /");
+
+ command = "rm -rf {}"_shellify("someFile.txt");
+ EXPECT_EQ(command[2], "rm -rf 'someFile.txt'");
+
+ command = "rm -rf {}"_shellify(5);
+ EXPECT_EQ(command[2], "rm -rf '5'");
+
+ command = "ls {}"_shellify("blah'; rm -rf /");
+ EXPECT_EQ(command[2], "ls 'blah'\\''; rm -rf /'");
+}
+
+TEST(Shell, Shellify_deprecated) {
auto command = shellify("rm -rf /");
EXPECT_EQ(command[0], "/bin/sh");
EXPECT_EQ(command[1], "-c");