Skip to content

Commit

Permalink
double copy issue fixed with copyToTmpDir
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaSTL committed Dec 16, 2023
1 parent 1d99f0d commit 3f2abad
Show file tree
Hide file tree
Showing 29 changed files with 4,138 additions and 85 deletions.
4,059 changes: 4,059 additions & 0 deletions compile_commands.json.tmpf72ae

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion include/Frate/Test/Test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ namespace Tests::Command {
*/
bool testAddMode(std::string mode_name);
bool testAddDuplicateMode(std::string mode_name);

bool testRemoveMode(std::string mode_name);

/* --------------------
Expand Down
2 changes: 0 additions & 2 deletions src/Generators/ProjectGenerator/DownloadTemplates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ namespace Frate::Generators::Project {
std::filesystem::rename(project_path / "template/frate-callbacks/scripts",
project_path / "template/scripts");

path tmp_path = Utils::copyToTmpPath(project_path / "template/frate-callbacks",
"frate-callbacks-");

std::filesystem::remove_all(project_path / "template/frate-callbacks");

Expand Down
2 changes: 1 addition & 1 deletion src/Test/Commands/Author/TestAddDuplicateAuthor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Tests::Command {
bool testAddDuplicateAuthor(std::string name){
Utils::info << "Testing add duplicate author command normal conditions" << std::endl;
Frate::Utils::info << "Testing add duplicate author command normal conditions" << std::endl;

if(!testNew()) return false;

Expand Down
16 changes: 8 additions & 8 deletions src/Test/Commands/Author/TestAddMultiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Tests::Command {
bool testAddAuthorMultiple(std::vector<std::string> names) {


Utils::info << "Testing add author command with names: " << std::endl;
Frate::Utils::info << "Testing add author command with names: " << std::endl;
for(auto name : names){
Utils::info << name << std::endl;
Frate::Utils::info << name << std::endl;
}

if (!testNew()) {
Utils::error << "Failed to create new project" << std::endl;
Frate::Utils::error << "Failed to create new project" << std::endl;
return false;
}

Expand All @@ -24,15 +24,15 @@ namespace Tests::Command {
auto [failed, inter] = init(command);

if (failed) {
Utils::error << "Failed to init" << std::endl;
Frate::Utils::error << "Failed to init" << std::endl;

return false;
}

if (inter->pro->authors.size() != names.size()) {

Utils::error << "Failed to add author project wrong number of authors" << std::endl;
Utils::error << "Got: " << inter->pro->authors.size() << std::endl;
Frate::Utils::error << "Failed to add author project wrong number of authors" << std::endl;
Frate::Utils::error << "Got: " << inter->pro->authors.size() << std::endl;
return false;
}
for(auto name : names){
Expand All @@ -43,8 +43,8 @@ namespace Tests::Command {
}
}
if(!found){
Utils::error << "Failed to add author project" << std::endl;
Utils::error << "Got: " << inter->pro->authors[0] << std::endl;
Frate::Utils::error << "Failed to add author project" << std::endl;
Frate::Utils::error << "Got: " << inter->pro->authors[0] << std::endl;

return false;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Test/Commands/Author/TestAddSingle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Tests::Command {
bool testAddAuthorSingle(std::string name){

Utils::info << "Testing add author command with name: " << name << std::endl;
Frate::Utils::info << "Testing add author command with name: " << name << std::endl;
if(!testNew()) return false;

std::string command = "frate add author " + name;
Expand All @@ -15,14 +15,14 @@ namespace Tests::Command {

if(inter->pro->authors.size() != 1){

Utils::error << "Failed to add author project wrong number of authors" << std::endl;
Utils::error << "Got: " << inter->pro->authors.size() << std::endl;
Frate::Utils::error << "Failed to add author project wrong number of authors" << std::endl;
Frate::Utils::error << "Got: " << inter->pro->authors.size() << std::endl;
return false;
}

if(inter->pro->authors[0] != name){
Utils::error << "Failed to add author project" << std::endl;
Utils::error << "Got: " << inter->pro->authors[0] << std::endl;
Frate::Utils::error << "Failed to add author project" << std::endl;
Frate::Utils::error << "Got: " << inter->pro->authors[0] << std::endl;

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Commands/Author/TestRemoveAuthor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Tests::Command {
bool testRemoveAuthor(std::string name){
Utils::info << "Testing remove author command normal conditions" << std::endl;
Frate::Utils::info << "Testing remove author command normal conditions" << std::endl;
if(!testNew()){
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Test/Commands/Flags/TestAddFlagMultiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ namespace Tests::Command {

if(inter->pro->flags.size() != 2){

Utils::error << "Failed to add flags project wrong number of flags" << std::endl;
Frate::Utils::error << "Failed to add flags project wrong number of flags" << std::endl;
return false;
}

if(inter->pro->flags[0] != "-g"){

Utils::error << "Failed to add flags project" << std::endl;
Frate::Utils::error << "Failed to add flags project" << std::endl;
return false;
}
if(inter->pro->flags[1] != "-O3"){

Utils::error << "Failed to add flags project" << std::endl;
Frate::Utils::error << "Failed to add flags project" << std::endl;
return false;
}

Expand Down
11 changes: 5 additions & 6 deletions src/Test/Commands/Flags/TestAddFlagSingle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
namespace Tests::Command {
bool testAddFlagsSingle(){
if(!testNew()) return false;
Utils::info << "Testing add flags command normal conditions" << std::endl;
Frate::Utils::info << "Testing add flags command normal conditions" << std::endl;
auto [failed, inter] = init("frate add flags '-O3'");

if(failed) return false;

if(inter->pro->flags.size() != 1){

Utils::error << "Failed to add flags project wrong number of flags" << std::endl;
Utils::error << "Got: " << inter->pro->flags.size() << std::endl;
Frate::Utils::error << "Failed to add flags project wrong number of flags" << std::endl;
Frate::Utils::error << "Got: " << inter->pro->flags.size() << std::endl;
return false;
}

if(inter->pro->flags[0] != "-O3"){
Utils::error << inter->pro->flags[0] << std::endl;

Utils::error << "Failed to add flags project" << std::endl;
Frate::Utils::error << inter->pro->flags[0] << std::endl;
Frate::Utils::error << "Failed to add flags project" << std::endl;
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Test/Commands/Flags/TestAddFlagWithMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ namespace Tests::Command {
bool testAddFlagsWithMode(){
std::cout << "Testing add flags command with a mode specified" << std::endl;
if(!testNew()){
Utils::error << "Failed to create new project" << std::endl;
Frate::Utils::error << "Failed to create new project" << std::endl;
return false;
}

auto [failed, inter] = init("frate add flags -m Release '-O3'");
if (failed) {
Utils::error << "Failed to init" << std::endl;
Frate::Utils::error << "Failed to init" << std::endl;
return false;
}
if (inter->pro->modes[0].flags[1] != "-O3") {
std::cout << inter->pro->modes[0].flags[0] << std::endl;

Utils::error << "Failed to add flags project" << std::endl;
Frate::Utils::error << "Failed to add flags project" << std::endl;
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Test/Commands/Flags/TestRemoveFlagSingle.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifdef TEST
#include <Frate/Test/Test.hpp>
bool Tests::Command::testRemoveFlagsSingle(std::string name){
Utils::info << "Testing remove flags command normal conditions" << std::endl;
Frate::Utils::info << "Testing remove flags command normal conditions" << std::endl;
if(!testNew()){
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Commands/Mode/TestAddModeDuplicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Frate/Test/Test.hpp>

bool Tests::Command::testAddDuplicateMode(std::string mode_name){
Utils::info << "Testing add mode command with duplicate mode" << std::endl;
Frate::Utils::info << "Testing add mode command with duplicate mode" << std::endl;
if(!testNew()) return false;

auto [failed, inter] = init("frate add mode " + mode_name );
Expand Down
4 changes: 2 additions & 2 deletions src/Test/Commands/Mode/TestAddModeSingle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifdef TEST

bool Tests::Command::testAddMode(std::string mode_name){
Utils::info << "Testing add mode command normal conditions" << std::endl;
Frate::Utils::info << "Testing add mode command normal conditions" << std::endl;
if(!testNew()) return false;

auto [failed, inter] = init("frate add mode " + mode_name);
Expand All @@ -18,7 +18,7 @@ bool Tests::Command::testAddMode(std::string mode_name){
}
}

Utils::error << "Failed to add mode : could not find " << mode_name << " in frate-project.json" << std::endl;
Frate::Utils::error << "Failed to add mode : could not find " << mode_name << " in frate-project.json" << std::endl;
return true;
}
#endif
2 changes: 1 addition & 1 deletion src/Test/Commands/Mode/TestRemoveModeSingle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Frate/Test/Test.hpp>

bool Tests::Command::testRemoveMode(std::string mode){
Utils::info << "Testing remove mode command normal conditions" << std::endl;
Frate::Utils::info << "Testing remove mode command normal conditions" << std::endl;
if(!testNew()) return false;

auto [failed, inter] = init("frate add mode " + mode);
Expand Down
4 changes: 2 additions & 2 deletions src/Test/Commands/New/TestNormal.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifdef TEST
#include <Frate/Test/Test.hpp>
bool Tests::Command::testNew(){
Utils::info << "Testing new command normal conditions" << std::endl;
Frate::Utils::info << "Testing new command normal conditions" << std::endl;

test_path = genTestDirectory();
auto [failed, inter] = init("frate new test -d");
if(failed){
Utils::error << "Failed to create new project" << std::endl;
Frate::Utils::error << "Failed to create new project" << std::endl;
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Test/Commands/New/TestWithLang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include <Frate/Utils/General.hpp>
bool Tests::Command::testNewWithLang(std::string lang){

Utils::info << "Testing new command with lang: " << lang << std::endl;
Frate::Utils::info << "Testing new command with lang: " << lang << std::endl;
test_path = genTestDirectory();
auto[failed, inter] = init("frate new test -d -l "+lang);

if(inter->pro->lang != lang){

Utils::error << "Failed to create new project : project lang not set" << std::endl;
Frate::Utils::error << "Failed to create new project : project lang not set" << std::endl;
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Test/Commands/New/TestWithType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#include "Frate/Utils/General.hpp"
#include <Frate/Test/Test.hpp>
bool Tests::Command::testNewWithType(std::string type){
Utils::info << "Testing new command with type: " << type << std::endl;
Frate::Utils::info << "Testing new command with type: " << type << std::endl;
test_path = genTestDirectory();
auto[failed,inter] = init("frate new -d -t " + type);

if(failed) return false;

if(inter->pro->type != type){

Utils::error << "Failed to create new project : project type: "
Frate::Utils::error << "Failed to create new project : project type: "
<< type << " not set"
<< std::endl;
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/Test/Commands/Nuke/TestNuke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace Tests::Command {
std::cout << "Testing nuke command" << std::endl;

if(!testNew()){
Utils::error << "Failed to create new project" << std::endl;
Frate::Utils::error << "Failed to create new project" << std::endl;
return false;
}
std::cout << "Testing nuke command normal conditions" << std::endl;
auto [failed, inter] = init("frate nuke",false);

if(failed){
Utils::error << "Failed to init nuke command" << std::endl;
Frate::Utils::error << "Failed to init nuke command" << std::endl;
return false;
}

Expand All @@ -24,7 +24,7 @@ namespace Tests::Command {
}

if(count != 0){
Utils::error << "Failed to nuke project had: " << count << " files left" << std::endl;
Frate::Utils::error << "Failed to nuke project had: " << count << " files left" << std::endl;

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Commands/Package/TestAddPackageMultiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool Tests::Command::testAddPackageMultiple(std::vector<std::string> packages) {

for(auto &p : package_results){
if(!p.second){
Utils::error << "Failed to add package : could not find " << p.first << " in frate-project.json" << std::endl;
Frate::Utils::error << "Failed to add package : could not find " << p.first << " in frate-project.json" << std::endl;
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Test/Commands/Package/TestAddPackageSingle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bool Tests::Command::testAddPackage(std::string package_name) {
auto [failed, inter] = init("frate add p "+package_name+" -l");

if(failed){
Utils::error << "Failed to add package : could not initialize interface" << std::endl;
Frate::Utils::error << "Failed to add package : could not initialize interface" << std::endl;
return false;
}

Expand All @@ -17,12 +17,12 @@ bool Tests::Command::testAddPackage(std::string package_name) {
config_file >> config;
if(config["dependencies"].size() != 1){

Utils::error << "Failed to add package : no pacakge add dected frate-project.json" << std::endl;
Frate::Utils::error << "Failed to add package : no pacakge add dected frate-project.json" << std::endl;
return false;
}
}catch(...){

Utils::error << "Failed to add package : could not open file - file possibly never created" << std::endl;
Frate::Utils::error << "Failed to add package : could not open file - file possibly never created" << std::endl;
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Test/Commands/Package/TestAddPackageWithDuplicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Tests::Command {

bool testAddPackageWithDuplicate(std::string package_name){
Utils::info << "Testing add package command with duplicate package" << std::endl;
Frate::Utils::info << "Testing add package command with duplicate package" << std::endl;
if(!testNew()) return false;

auto [failed, inter] = init("frate add package " + package_name + " -l");
Expand All @@ -17,7 +17,7 @@ namespace Tests::Command {
auto [failed_dup, inter_dup] = init("frate add package " + package_name + " -l");

if(!failed_dup){
error << "Failed to detect duplicate package" << std::endl;
Frate::Utils::error << "Failed to detect duplicate package" << std::endl;
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Test/Commands/Package/TestAddPackageWithMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ bool Tests::Command::testAddPackageToMode(std::string mode_name, std::string pac
std::cout << "Testing add package to mode command" << std::endl;

if(!testNew()){
Utils::error << "Failed to create new project" << std::endl;
Frate::Utils::error << "Failed to create new project" << std::endl;
return false;
}
auto [failed,inter] = init("frate add p "+package_name + " -m " + mode_name + " -l");
if(failed){
Utils::error << "Failed to add package" << std::endl;
Frate::Utils::error << "Failed to add package" << std::endl;
return false;
}

Expand All @@ -26,7 +26,7 @@ bool Tests::Command::testAddPackageToMode(std::string mode_name, std::string pac
}
}

Utils::error << "Failed to add package to mode "+mode_name+" : the selected mode either doesn't exist or we couldn't find " + package_name << std::endl;
Frate::Utils::error << "Failed to add package to mode "+mode_name+" : the selected mode either doesn't exist or we couldn't find " + package_name << std::endl;

return false;

Expand Down
2 changes: 1 addition & 1 deletion src/Test/Commands/Package/TestRemovePackageMultiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Tests::Command {
for(auto &dep : config["dependencies"]){
for(auto &p : packages){
if(dep["name"] == p){
Utils::error << "Failed to remove package : found " << p << " in frate-project.json" << std::endl;
Frate::Utils::error << "Failed to remove package : found " << p << " in frate-project.json" << std::endl;
return false;
}
}
Expand Down
Loading

0 comments on commit 3f2abad

Please sign in to comment.