diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-06-09 21:22:45 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:32 +0200 |
commit | 02eb206cb76c9efd6cecf9f9493eecfa410d4da3 (patch) | |
tree | 5b9f298d32d14f37710ac6c8751366450b4e98ff /src | |
parent | a973a822cabeed5bbd91372d241b26deaa6373ab (diff) |
Create test source file when creating new project or init project
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 5b7d81f..14e9a73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -643,6 +643,10 @@ int initProject(int argc, const _tinydir_char_t **argv) if(!fileOverwriteResult) fout << "Warning: Failed to create project file: " << toFileString(fileOverwriteResult.getErrMsg()) << endl; } + auto testFilePath = projectPath + TINYDIR_STRING("/tests/main.cpp"); + Result<bool> fileOverwriteResult = fileWrite(testFilePath.c_str(), "#include <cstdio>\n\nint main(int argc, char **argv)\n{\n printf(\"hello, world!\\n\");\n return 0;\n}\n"); + if(!fileOverwriteResult) + fout << "Warning: Failed to create project file: " << toFileString(fileOverwriteResult.getErrMsg()) << endl; auto gitProjDir = projectPath + TINYDIR_STRING("/.git"); if(getFileType(gitProjDir.c_str()) != FileType::FILE_NOT_FOUND) gitInitProject(projectPath); @@ -735,6 +739,13 @@ int newProject(int argc, const _tinydir_char_t **argv) exit(20); } } + auto testFilePath = projectPath + TINYDIR_STRING("/tests/main.cpp"); + Result<bool> fileOverwriteResult = fileWrite(testFilePath.c_str(), "#include <cstdio>\n\nint main(int argc, char **argv)\n{\n printf(\"hello, world!\\n\");\n return 0;\n}\n"); + if(!fileOverwriteResult) + { + ferr << "Failed to create project file: " << toFileString(fileOverwriteResult.getErrMsg()) << endl; + exit(20); + } // We are ignoring git init result on purpose. If it fails, just ignore it; not important gitInitProject(projectPath); return 0; |