diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0b9c497 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Test +on: + push: + +jobs: + build_and_test: + name: "Build and Test" + strategy: + fail-fast: false + matrix: + runner: [ubuntu-24.04, macos-15] + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + # No need to install dependencies — only Ninja and CMake are needed, + # slang CMakeLists.txt fetch the rest. + # + # https://github.com/actions/runner-images + - name: Build + run: | + rm -rf ./build + mkdir -p ./build + cd ./build + cmake -G Ninja .. + ninja + - name: Test + run: | + cd ./build + ctest diff --git a/src/driver.cc b/src/driver.cc index aab6540..b6d6902 100644 --- a/src/driver.cc +++ b/src/driver.cc @@ -429,28 +429,25 @@ void prunefl::Driver::write_output_flags() const { // defines for (auto &define : options.defines) { - output_flags.insert(std::string("+define+") + define); + output_flags.insert(fmt::format("+define+{}", define)); } // include search directories for (auto &file : result_includes) { output_flags.insert( - std::string("+incdir+") + file.parent_path().string() + fmt::format("+incdir+{}", file.parent_path().string()) ); } // module search directories for (auto &dir : sourceLoader.getSearchDirectories()) { - output_flags.insert(std::string("-y ") + dir.string()); + output_flags.insert(fmt::format("-y {}", dir.string())); } // module search extensions - if (verific_compat_mode) { - output_flags.insert(std::string("+libext+")); - } else { - for (auto &ext : sourceLoader.getSearchExtensions()) { - output_flags.insert(std::string("-Y ") + ext.string()); - } + std::string_view libext_pfx = verific_compat_mode ? "+libext+" : "-Y "; + for (auto &ext : sourceLoader.getSearchExtensions()) { + output_flags.insert(fmt::format("{}{}", libext_pfx, ext.string())); } // library files @@ -465,14 +462,14 @@ void prunefl::Driver::write_output_flags() const { } // input command file - if (verific_compat_mode) { - // verific is single-unit by default, so -C doesn't matter - output_flags.insert(fmt::format("-f {}", fs::absolute(*output).c_str()) - ); - } else { - output_flags.insert(fmt::format("-C {}", fs::absolute(*output).c_str()) - ); - } + std::string_view cmdfile_pfx = + verific_compat_mode + ? "-f " // verific is single-unit by default, so -C doesn't matter + : "-C "; + + output_flags.insert( + fmt::format("{}{}", cmdfile_pfx, fs::absolute(*output).c_str()) + ); std::string out_string; for (auto &flag : output_flags) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4382a61..87827b1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,6 +8,7 @@ set(ALL_TESTS test_cli_define test_libmap test_timescales + test_no_list ) foreach(test_name ${ALL_TESTS}) diff --git a/test/run_test b/test/run_test index 8331414..80650b7 100755 --- a/test/run_test +++ b/test/run_test @@ -21,10 +21,30 @@ assert len(unused & result) == 0 HERE } -$prunefl -f list.f --top top_module \ +rm -f $bindir/$test.cache.json + +input_file="-f list.f" +if ! test -f list.f; then + input_file=test.v +fi + +$prunefl $input_file --top top_module \ + --verific-compat --ignore-unknown-modules\ --output-flags-to $bindir/$test.flags.f \ - --output $bindir/$test.f + --output $bindir/$test.f \ + --cache-to $bindir/$test.cache.json verify_unused ./unused.txt $bindir/$test.flags.f -$slang_hier -F $bindir/$test.flags.f --top top_module --compat all --timescale=1ns/1ns +$slang_hier --single-unit -F $bindir/$test.flags.f --top top_module --compat all --timescale=1ns/1ns + +# test loading from cache +$prunefl $input_file --top top_module \ + --verific-compat --ignore-unknown-modules\ + --output-flags-to $bindir/$test.flags.cached.f \ + --output $bindir/$test.cached.f \ + --cache-to $bindir/$test.cache.json + +# only difference should be that it points to .cached.f instead of .f +cat $bindir/$test.flags.cached.f | sed 's/.cached.f/.f/' | cmp $bindir/$test.flags.f - +cmp $bindir/$test.f $bindir/$test.cached.f diff --git a/test/test_no_list/test.v b/test/test_no_list/test.v new file mode 100644 index 0000000..e502f11 --- /dev/null +++ b/test/test_no_list/test.v @@ -0,0 +1,11 @@ +module top_module +#( + parameter DEC_WIDTH = 8, + parameter ENC_WIDTH = 3 +) +( + input wire [ENC_WIDTH-1:0] in_enc_nnn, + output wire [DEC_WIDTH-1:0] out_dec_nnn +); + assign out_dec_nnn = DEC_WIDTH'(1'b1 << in_enc_nnn); +endmodule