diff --git a/.gitignore b/.gitignore index 27c9fc8..82536a1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,5 @@ test_script* docs_test/* test/*-temp result/* -result/ +**/result/ notes/* diff --git a/nix/makePrunedSrc.nix b/nix/makePrunedSrc.nix index 0da5afa..22f48d3 100644 --- a/nix/makePrunedSrc.nix +++ b/nix/makePrunedSrc.nix @@ -3,6 +3,7 @@ , source , filter , glibcLocales + , lib }: stdenv.mkDerivation { name = "pruned_src"; @@ -12,18 +13,16 @@ stdenv.mkDerivation { buildPhase = '' export LANG="en_US.UTF-8" mkdir $out - echo $(locale) - echo "treeSurgeon is located: ${treeSurgeon}" - if $(${treeSurgeon}/bin/tree-surgeon to-bash -f '${filter}' -s ${source} > call_out 2> call_err); then + if $(${treeSurgeon}/bin/tree-surgeon to-bash \ + -f ${lib.strings.escapeNixString filter} \ + -s ${source} > call_out 2> call_err); + then BASHARR="$(cat call_out)" cd ${source} cp --parents $BASHARR $out/ else - echo "is not working; test char is: │" ERRMSG=$(cat call_err) - echo "Echoing error" echo "$ERRMSG" - echo "Exiting" exit 1 fi ''; diff --git a/notes/notes.md b/notes/notes.md index 22f394e..314af3a 100644 --- a/notes/notes.md +++ b/notes/notes.md @@ -2,8 +2,6 @@ ---------- We have three current issues: -- If you screw up your ts expression in prune, you get crazy error output - - An incorrect filter expression doesn't return a non-zero error code - Error messages probably still not great - It does not seem to work with "endsWith '.cpp' (basename file)", does using '' " " '' though - README is incomplete and the documentation doesn't really describe the command-line options. diff --git a/result b/result index dfc1ac5..7aed5f5 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/pp79zhm1dcgdsd1vdxrgwcrkq87walks-tstest \ No newline at end of file +/nix/store/9h2mqw0srb8gq8rfs5viakqjcj33hg0i-tstest \ No newline at end of file diff --git a/src/app/TreeFilter.hs b/src/app/TreeFilter.hs index 8e6e16d..5c91e5e 100644 --- a/src/app/TreeFilter.hs +++ b/src/app/TreeFilter.hs @@ -20,7 +20,6 @@ import Debug.Trace (trace) import qualified Data.Text as T import System.Directory.Tree import System.Exit -import System.IO (hPutStrLn, stderr) import TextShow import qualified Lexer as X @@ -65,9 +64,7 @@ applyFilterWith :: FileName -> (DirTree FData -> IO()) -> BS.ByteString -> IO () applyFilterWith dirname ioF filterStr = do filteredTreeE <- applyFilter dirname filterStr case filteredTreeE of - Left (e:_) -> do - hPutStrLn stderr $ trace ("to error message: " <> toErrorMessage filterStr e) (toErrorMessage filterStr e) - exitWith (ExitFailure 1) + Left (e:_) -> die $ toErrorMessage filterStr e Left [] -> error "Wie ist es moglich" Right filtered -> ioF filtered @@ -75,9 +72,7 @@ applyFilterWithReproduce :: FileName -> (DirTree FData -> IO()) -> BS.ByteString applyFilterWithReproduce dirname ioF filterStr = do filteredTreeE <- applyFilter dirname filterStr case filteredTreeE of - Left (e:_) -> do - hPutStrLn stderr $ trace ("to error message: " <> toErrorMessage filterStr e) (toErrorMessage filterStr e) - exitWith (ExitFailure 1) + Left (e:_) -> die $ toErrorMessage filterStr e Left [] -> error "Wie ist es moglich" Right filtered -> ioF filtered @@ -86,9 +81,7 @@ applyFilterWithComparative dirname ioF filterStr = do anchoredTree <- readDirectoryWith return dirname filteredTreeE <- applyFilter dirname filterStr case filteredTreeE of - Left (e:_) -> do - hPutStrLn stderr $ trace ("to error message: " <> toErrorMessage filterStr e) (toErrorMessage filterStr e) - exitWith (ExitFailure 1) + Left (e:_) -> die $ toErrorMessage filterStr e Left [] -> error "Wie ist es moglich" Right filtered -> ioF (toElements $ dirTree anchoredTree) filtered @@ -97,9 +90,7 @@ applyFilterWithComparativeReproduce dirname ioF filterStr = do anchoredTree <- readDirectoryWith return dirname filteredTreeE <- applyFilter dirname filterStr case filteredTreeE of - Left (e:_) -> do - hPutStrLn stderr $ trace ("to error message:\n" <> toErrorMessage filterStr e) (toErrorMessage filterStr e) - exitWith (ExitFailure 1) + Left (e:_) -> die $ toErrorMessage filterStr e Left [] -> error "Wie ist es moglich" Right filtered -> ioF (toElements $ dirTree anchoredTree) filtered diff --git a/src/call_err b/src/call_err deleted file mode 100644 index b2f2b3b..0000000 --- a/src/call_err +++ /dev/null @@ -1,6 +0,0 @@ -to error message: Error: name endsWit is not a recognized function name -in original source: -1 │ endsWit ".cpp" (basename file) -Error: name endsWit is not a recognized function name -in original source: -1 │ endsWit ".cpp" (basename file) diff --git a/src/call_out b/src/call_out deleted file mode 100644 index e69de29..0000000 diff --git a/src/result b/src/result deleted file mode 120000 index ae0b955..0000000 --- a/src/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/0d5y4632ajz3x8b613vldab331ky5rqg-tstest \ No newline at end of file diff --git a/tree-surgeon-test.nix b/tree-surgeon-test.nix index 551b29b..f96baba 100644 --- a/tree-surgeon-test.nix +++ b/tree-surgeon-test.nix @@ -4,7 +4,7 @@ stdenv.mkDerivation { name = "tstest"; - src = tsLib.prune ./src/test/test-data ''endsWit ".cpp" (basename file)''; + src = tsLib.prune ./src/test/test-data "endsWith '.cpp' (basename file)"; dontUnpack = true; buildPhase = '' mkdir $out