mirror of https://github.com/zachjs/sv2v.git
write adjacent overwrites existing files
This commit is contained in:
parent
ed09fe88cf
commit
f868f06e88
|
|
@ -1,5 +1,9 @@
|
|||
## Unreleased
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
* `--write adjacent` no longer forbids overwriting existing generated files
|
||||
|
||||
### New Features
|
||||
|
||||
* Added support for assignments within expressions (e.g., `x = ++y;`)
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@
|
|||
- conversion entry point
|
||||
-}
|
||||
|
||||
import System.Directory (doesFileExist)
|
||||
import System.IO (hPrint, hPutStrLn, stderr, stdout)
|
||||
import System.Exit (exitFailure, exitSuccess)
|
||||
|
||||
import Control.Monad (filterM, when, zipWithM_)
|
||||
import Control.Monad (when, zipWithM_)
|
||||
import Control.Monad.Except (runExceptT)
|
||||
import Data.List (intercalate)
|
||||
|
||||
import Convert (convert)
|
||||
import Job (readJob, Job(..), Write(..))
|
||||
|
|
@ -63,11 +61,6 @@ writeOutput (File f) _ asts =
|
|||
writeFile f $ show $ concat asts
|
||||
writeOutput Adjacent inPaths asts = do
|
||||
outPaths <- mapM rewritePath inPaths
|
||||
badPaths <- filterM doesFileExist outPaths
|
||||
when (not $ null badPaths) $ do
|
||||
hPutStrLn stderr $ "Refusing to write output because the following"
|
||||
++ " files would be overwritten: " ++ intercalate ", " badPaths
|
||||
exitFailure
|
||||
let results = map (++ "\n") $ map show asts
|
||||
zipWithM_ writeFile outPaths results
|
||||
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ test_adjacent() {
|
|||
test_adjacent_exist() {
|
||||
createArtifacts
|
||||
runAndCapture --write=adjacent *.sv
|
||||
clearArtifacts
|
||||
|
||||
assertFalse "adjacent conversion should fail" $result
|
||||
assertTrue "adjacent conversion should overwrite and succeed" $result
|
||||
assertNull "stdout should be empty" "$stdout"
|
||||
assertEquals "stderr should list existing files" \
|
||||
"Refusing to write output because the following files would be overwritten: one.v, two.v" \
|
||||
"$stderr"
|
||||
assertNull "stderr should be empty" "$stderr"
|
||||
|
||||
actual=`cat one.v two.v`
|
||||
assertEquals "adjacent output should match combined" "$expected" "$actual"
|
||||
clearArtifacts
|
||||
}
|
||||
|
||||
test_adjacent_extension() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue