Skip to content

Commit

Permalink
Adding new test to build system
Browse files Browse the repository at this point in the history
- adding newly generated files to verification
- flyby: fixing typos in code generator
  • Loading branch information
hkaiser committed May 9, 2023
1 parent 6a926f6 commit 858813f
Show file tree
Hide file tree
Showing 33 changed files with 662 additions and 692 deletions.
15 changes: 15 additions & 0 deletions .cmake-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@
additional_commands = { 'add_chplx_pseudo_dependencies': {'pargs': {'nargs': 0}},
'add_chplx_pseudo_dependencies_no_shortening': {'pargs': {'nargs': 0}},
'add_chplx_pseudo_target': {'pargs': {'nargs': 0}},
'add_chplx_pseudo_target_folder': { 'kwargs': { 'FOLDER': 1,
'TARGET': 1 },
'pargs': {'nargs': 0}},
'add_chplx_test': { 'kwargs': { 'ARGS': '+',
'EXECUTABLE': 1,
'LOCALITIES': 1,
Expand All @@ -228,6 +231,18 @@
'NO_PARCELPORT_MPI',
'NO_PARCELPORT_LCI'],
'nargs': '2+'}},
'chplx_compare_result': { 'kwargs': { 'GOOD': 1,
'TEST_NAME': 1,
'DEPENDENCIES': '+',
'SOURCES': '+'},
'pargs': {'nargs': '2+'}},
'chplx_compile_project': { 'kwargs': { 'TARGET': 1,
'TEST_NAME': 1,
'DEPENDENCIES': '+'},
'pargs': {'nargs': '2+'}},
'chplx_format_file': { 'kwargs': { 'SOURCES': '+',
'DEPENDENCIES': '+'},
'pargs': {'nargs': '2+'}},
'chplx_config_loglevel': {'pargs': {'nargs': 2}},
'chplx_debug': {'pargs': {'nargs': 0}},
'chplx_error': {'pargs': {'nargs': 0}},
Expand Down
4 changes: 2 additions & 2 deletions backend/src/codegenvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,15 +870,15 @@ static void generateSourceFooter(std::string const& modStr, SymbolTable & symtab
<< " chplx::registerModule<" << modStr << "::__thisModule>();" << std::endl;

if(0 < cfgVars.size()) {
fos << " hpx::program::options::options::options_description options;\n options.add_options()";
fos << " hpx::program_options::options_description options;\n options.add_options()";
for(auto & opt : cfgVars) {
fos << std::endl << " (\"" << opt.identifier << "\"," << std::endl;
FuncDeclArgVisitor v{fos};
fos << " hpx::program_options::value<";

std::visit(v, opt.kind);

std::string opt_identifier{"_this->" + opt.identifier};
std::string opt_identifier{"__this->" + opt.identifier};
buildFullNamespaceString(opt_identifier, symtable, opt);

fos << ">(&" << opt_identifier << "), " << "\"config ";
Expand Down
28 changes: 22 additions & 6 deletions backend/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,43 @@ find_package(ClangFormat)

add_chplx_pseudo_target(tests.unit.backend_dir)
add_chplx_pseudo_target_folder(
backend TARGET tests.unit.backend_dir FOLDER "Backend/Tests/Targets"
backend
TARGET tests.unit.backend_dir
FOLDER "Backend/Tests/Targets"
)

add_chplx_pseudo_dependencies(tests.unit tests.unit.backend_dir)

set(tests arr cond expr fn fnc forall)
set(tests
arr
cfg
cond
expr
fn
fnc
forall
)

foreach(test ${tests})
chplx_compile(${test} SOURCE ${test}.chpl)

if(CLANGFORMAT_FOUND)
chplx_format_file(${test} SOURCES ${test}.cpp ${test}.hpp)
chplx_format_file(
${test} SOURCES ${test}.cpp ${test}.hpp ${test}_driver.cpp
${test}_driver.hpp
)
endif()

chplx_compare_result(${test}
SOURCES ${test}.cpp ${test}.hpp "CMakeLists.txt"
chplx_compare_result(
${test}
SOURCES ${test}.cpp ${test}.hpp ${test}_driver.cpp ${test}_driver.hpp
"CMakeLists.txt"
TEST_NAME "tests.unit.backend_dir.${test}"
)

# now build the created files
chplx_compile_project(${test}
chplx_compile_project(
${test}
TARGET ${test}
TEST_NAME "tests.unit.backend_dir.${test}_cpp"
)
Expand Down
124 changes: 61 additions & 63 deletions backend/test/arr/arr.cpp.good
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,67 @@

namespace arr {

struct __thisModule* __this = nullptr;
struct __thisModule *__this = nullptr;

#line 37 "../../backend/test/arr.chpl"
auto __thisModule::dd()
{
#line 38 "../../backend/test/arr.chpl"
return 1;
};
#line 37 "arr.chpl"
auto __thisModule::dd() {
#line 38 "arr.chpl"
return 1;
};

void __thisModule::__main()
{
#line 8 "../../backend/test/arr.chpl"
std::vector<std::int64_t> k = {1, 2, 3, 4, 5};
#line 9 "../../backend/test/arr.chpl"
std::vector<std::vector<std::int64_t>> l = {{1, 2}, {3, 4}};
#line 10 "../../backend/test/arr.chpl"
std::vector<std::vector<std::int64_t>> m = {{1}, {2}, {3, 4, 5}};
#line 11 "../../backend/test/arr.chpl"
std::vector<std::vector<std::int64_t>> n = {{1, 2}, {1, 2}};
#line 12 "../../backend/test/arr.chpl"
std::vector<std::vector<std::vector<std::int64_t>>> o = {
{{1, 2}, {1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
#line 13 "../../backend/test/arr.chpl"
std::vector<std::vector<std::int64_t>> p = {{1, 2, 3, 4, 5}};
#line 14 "../../backend/test/arr.chpl"
std::vector<std::vector<std::vector<std::int64_t>>> q = {
{{1, 2, 3, 4, 5}}};
#line 16 "../../backend/test/arr.chpl"
bool u;
#line 17 "../../backend/test/arr.chpl"
double v;
#line 18 "../../backend/test/arr.chpl"
std::uint8_t w;
#line 19 "../../backend/test/arr.chpl"
std::int64_t x;
#line 20 "../../backend/test/arr.chpl"
std::complex<double> y;
#line 21 "../../backend/test/arr.chpl"
std::string z;
#line 23 "../../backend/test/arr.chpl"
std::vector<std::int64_t> a(10);
#line 24 "../../backend/test/arr.chpl"
std::vector<double> b(10);
#line 25 "../../backend/test/arr.chpl"
std::vector<std::complex<double>> c(10);
#line 26 "../../backend/test/arr.chpl"
std::vector<std::string> d(10);
#line 27 "../../backend/test/arr.chpl"
std::vector<std::uint8_t> e(10);
#line 28 "../../backend/test/arr.chpl"
std::vector<bool> f(10);
#line 30 "../../backend/test/arr.chpl"
std::int64_t g = 1;
#line 31 "../../backend/test/arr.chpl"
bool h = true;
#line 32 "../../backend/test/arr.chpl"
std::string i = {"value"};
#line 33 "../../backend/test/arr.chpl"
double j = 1.000000;
#line 35 "../../backend/test/arr.chpl"
auto aa = 1 + 1;
#line 41 "../../backend/test/arr.chpl"
auto bb = dd();
}
void __thisModule::__main() {

} // namespace arr
#line 8 "arr.chpl"
std::vector<std::int64_t> k = {1, 2, 3, 4, 5};
#line 9 "arr.chpl"
std::vector<std::vector<std::int64_t>> l = {{1, 2}, {3, 4}};
#line 10 "arr.chpl"
std::vector<std::vector<std::int64_t>> m = {{1}, {2}, {3, 4, 5}};
#line 11 "arr.chpl"
std::vector<std::vector<std::int64_t>> n = {{1, 2}, {1, 2}};
#line 12 "arr.chpl"
std::vector<std::vector<std::vector<std::int64_t>>> o = {
{{1, 2}, {1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
#line 13 "arr.chpl"
std::vector<std::vector<std::int64_t>> p = {{1, 2, 3, 4, 5}};
#line 14 "arr.chpl"
std::vector<std::vector<std::vector<std::int64_t>>> q = {{{1, 2, 3, 4, 5}}};
#line 16 "arr.chpl"
bool u;
#line 17 "arr.chpl"
double v;
#line 18 "arr.chpl"
std::uint8_t w;
#line 19 "arr.chpl"
std::int64_t x;
#line 20 "arr.chpl"
std::complex<double> y;
#line 21 "arr.chpl"
std::string z;
#line 23 "arr.chpl"
std::vector<std::int64_t> a(10);
#line 24 "arr.chpl"
std::vector<double> b(10);
#line 25 "arr.chpl"
std::vector<std::complex<double>> c(10);
#line 26 "arr.chpl"
std::vector<std::string> d(10);
#line 27 "arr.chpl"
std::vector<std::uint8_t> e(10);
#line 28 "arr.chpl"
std::vector<bool> f(10);
#line 30 "arr.chpl"
std::int64_t g = 1;
#line 31 "arr.chpl"
bool h = true;
#line 32 "arr.chpl"
std::string i = {"value"};
#line 33 "arr.chpl"
double j = 1.000000;
#line 35 "arr.chpl"
auto aa = 1 + 1;
#line 41 "arr.chpl"
auto bb = dd();
}

} // namespace arr
34 changes: 15 additions & 19 deletions backend/test/arr/arr.hpp.good
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,26 @@
#include <functional>
#include <string>
#include <vector>
#line 1 "../../backend/test/arr.chpl"
#line 1 "arr.chpl"
namespace arr {
extern struct __thisModule* __this;
extern struct __thisModule *__this;

struct __thisModule
{
#line 37 "../../backend/test/arr.chpl"
auto dd();
struct __thisModule {

static void __construct()
{
arr::__this = new __thisModule();
}
#line 37 "arr.chpl"
auto dd();

static void __destruct() noexcept
{
auto* m = arr::__this;
arr::__this = nullptr;
delete m;
}
static void __construct() { arr::__this = new __thisModule(); }

void __main();
}; // end struct __thisModule
static void __destruct() noexcept {
auto *m = arr::__this;
arr::__this = nullptr;
delete m;
}

} // namespace arr
void __main();
}; // end struct __thisModule

} // namespace arr

#endif
14 changes: 6 additions & 8 deletions backend/test/arr/arr_driver.cpp.good
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

using namespace arr;

int hpx_main(int argc, char* argv[])
{
arr::__this->__main();
return hpx::finalize();
int hpx_main(int argc, char *argv[]) {
arr::__this->__main();
return hpx::finalize();
}

int main(int argc, char* argv[])
{
chplx::registerModule<arr::__thisModule>();
return hpx::init(argc, argv);
int main(int argc, char *argv[]) {
chplx::registerModule<arr::__thisModule>();
return hpx::init(argc, argv);
}
2 changes: 1 addition & 1 deletion backend/test/arr/arr_driver.hpp.good
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef __ARR_DRIVER_HPP__
#define __ARR_DRIVER_HPP__

#include <chplx.hpp>
#include "arr.hpp"
#include <chplx.hpp>

#endif
6 changes: 3 additions & 3 deletions backend/test/cfg/cfg.cpp.good
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

namespace cfg {

struct __thisModule* __this = nullptr;
struct __thisModule *__this = nullptr;

void __thisModule::__main() {}
void __thisModule::__main() {}

} // namespace cfg
} // namespace cfg
56 changes: 26 additions & 30 deletions backend/test/cfg/cfg.hpp.good
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,32 @@
#define __CFG_HPP__

#include <chplx.hpp>
#line 1 "../../backend/test/cfg.chpl"
#line 1 "cfg.chpl"
namespace cfg {
extern struct __thisModule* __this;

struct __thisModule
{
#line 8 "../../backend/test/cfg.chpl"
std::int64_t a;
#line 9 "../../backend/test/cfg.chpl"
std::int64_t b = 1;
#line 10 "../../backend/test/cfg.chpl"
std::int64_t c;
#line 11 "../../backend/test/cfg.chpl"
std::int64_t d = 1;

static void __construct()
{
cfg::__this = new __thisModule();
}

static void __destruct() noexcept
{
auto* m = cfg::__this;
cfg::__this = nullptr;
delete m;
}

void __main();
}; // end struct __thisModule

} // namespace cfg
extern struct __thisModule *__this;

struct __thisModule {

#line 8 "cfg.chpl"
std::int64_t a;
#line 9 "cfg.chpl"
std::int64_t b = 1;
#line 10 "cfg.chpl"
std::int64_t c;
#line 11 "cfg.chpl"
std::int64_t d = 1;

static void __construct() { cfg::__this = new __thisModule(); }

static void __destruct() noexcept {
auto *m = cfg::__this;
cfg::__this = nullptr;
delete m;
}

void __main();
}; // end struct __thisModule

} // namespace cfg

#endif
Loading

0 comments on commit 858813f

Please sign in to comment.