Skip to content

Commit

Permalink
Merge pull request #73 from Matts966/hotfix/empty-dir
Browse files Browse the repository at this point in the history
Add test for "" as directory
  • Loading branch information
Matts966 authored Dec 29, 2021
2 parents 96ffce7 + d92c41b commit 7e92f50
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
jobs:
osx:
name: Create artifacts on macOS-latest
runs-on: macOS-latest
runs-on: macos-10.15
steps:
- name: Checkout the repository
uses: actions/checkout@v2
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ jobs:
--slave /usr/bin/g++ g++ /usr/bin/g++-9
bazelisk build //alphasql/...
bazelisk test --test_output=errors //alphasql/...
- name: Test installation
run: |
temp=$(mktemp -d)
wget -P $temp https://github.com/Matts966/alphasql/releases/latest/download/alphasql_linux_x86_64.tar.gz \
&& sudo tar -zxvf $temp/alphasql_linux_x86_64.tar.gz -C /usr/local/bin --strip=1
alphadag ./samples/sample
./bazel-bin/alphasql/alphadag ./samples/sample
./bazel-bin/alphasql/alphadag --output_path=dag.dot ./samples/sample
./bazel-bin/alphasql/alphadag --external_required_tables_output_path=dag.dot ./samples/sample
osx:
name: Test the repository on Mac
runs-on: macOS-latest
runs-on: macos-10.15
steps:
- name: Checkout the repository
uses: actions/checkout@v2
Expand All @@ -49,11 +47,11 @@ jobs:
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-bazelisk-build-
- name: Test the repository
run: |
make test
- name: Test installation
shell: bash
run: |
temp=$(mktemp -d)
wget -P $temp https://github.com/Matts966/alphasql/releases/latest/download/alphasql_darwin_x86_64.tar.gz \
&& sudo tar -zxvf $temp/alphasql_darwin_x86_64.tar.gz -C /usr/local/bin --strip=1
brew install graphviz
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
bazel shutdown
make
alphadag ./samples/sample
alphadag --output_path=dag.dot ./samples/sample
alphadag --external_required_tables_output_path=dag.dot ./samples/sample
11 changes: 8 additions & 3 deletions alphasql/alphadag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "absl/flags/flag.h"
#include "alphasql/dag_lib.h"
#include <filesystem>
#include <system_error>
#include <regex>

std::regex DEFAULT_EXCLUDES(".*(.git/.*|.hg/.*|.svn/.*)");
Expand Down Expand Up @@ -248,8 +249,10 @@ int main(int argc, char *argv[]) {
!std::filesystem::exists(output_path)) {
std::filesystem::path parent =
std::filesystem::path(output_path).parent_path();
if (!std::filesystem::is_directory(parent)) {
std::filesystem::create_directories(parent);
if (!std::filesystem::is_directory(parent) && parent != "") {
// Ignore error code for empty directory
std::error_code ec;
std::filesystem::create_directories(parent, ec);
}
std::ofstream out(output_path);
write_graphviz_dp(out, g, dp);
Expand All @@ -275,7 +278,9 @@ int main(int argc, char *argv[]) {
std::filesystem::path(external_required_tables_output_path)
.parent_path();
if (!std::filesystem::is_directory(parent)) {
std::filesystem::create_directories(parent);
// Ignore error code for empty directory
std::error_code ec;
std::filesystem::create_directories(parent, ec);
}
std::ofstream out(external_required_tables_output_path);
for (const auto &required_table : external_required_tables) {
Expand Down

0 comments on commit 7e92f50

Please sign in to comment.