#TempDir created has null value in JUnit5 - junit5

I am trying to create temp folder, add files to it and iterate over the files, in one of my test cases. I am currently using Junit5's #TempDir annotation.
#TempDir Path tempDir2;
Further when I tried to create a file in the temp folder, I found that the path of dir is showing null.
It should have been actually created in /tmp folder as per my knowledge.
Any idea anyone, what could be the cause for tempDir path to be null?

Probably the reason why TempDir is null is that because you have imported the wrong Test class.
This is the class you need to use: org.junit.jupiter.api.Test.
TempDir won't work with org.junit.Test!

Related

How to specify multiple Working directory in set_tests_properties in Ctest

I have a large supporting file placed in another location outside my test Working directory.
Working Directory = C:/cmake/src/Test
Large Binary file to be parsed = C:/Largefiles/Binary.fft
I dont want to copy Binary.fft to C:/cmake/src/Test
set(working_dir "C:/cmake/src/Test")
set(Large_Binary "C:/Largefiles/")
Is it possible to do specify two working directories for a test like this?
set_tests_properties(Test_Large PROPERTIES ENVIRONMENT PATH=${BIN_DIR} WORKING_DIRECTORY ${working_dir }${Large_Binary })
Or is there a better way to approach this situation?

Shortcut in intellij to create resource folder with same path as of Java file in main or test section

Let's say if I am writing a test in folder structure of
test/com/abc/xyz/mysql/departments/employee/permission/TestAdmin.java
Is there a short cut to create resource file in same directory structure. Currently I have to create all the folders indivisually.
resources/com/abc/xyz/mysql/departments/employee/permission/mydef.features
key combination or fastest way. Like ctrl + shift + T create test file in same directory path in "test"
Unfortunately No :(
For tests, there is a specific intention named Create Test (under Settings->Intentions->Java->Declaration defined in IntelliJ by default which creates the test in the same folder and is bound to Ctrl+Shift+T, but there is no intention to create resources in the same manner.

Need help on Pig

I am executing a Pig script, which reads files from a directory, performs some operation and stores to some output directory. In output directory I'm getting one or more "part" files, one _SUCCESS file and one _logs directory. My questions are:
Is there any way to control the name of files generated (upon execution of STORE command) in output directory. To be specific, I don't want the names to be "part-.......". I want Pig to generate files according to the file name pattern I specify.
Is there any way to suppress the _SUCCESS file and the _log directory? Basically I don't want the _SUCCESS and _logs to be generated in the output directory.
Regards
Biswajit
See this post.
To remove _SUCCESS, use SET mapreduce.fileoutputcommitter.marksuccessfuljobs false;. I'm not 100% sure how to remove _logs but you could try SET pig.streaming.log.persist false;.

load script from other file extension?

is it possible to load module from file with extension other than .lua?
require("grid.txt") results in:
module 'grid.txt' not found:
no field package.preload['grid.txt']
no file './grid/txt.lua'
no file '/usr/local/share/lua/5.1/grid/txt.lua'
no file '/usr/local/share/lua/5.1/grid/txt/init.lua'
no file '/usr/local/lib/lua/5.1/grid/txt.lua'
no file '/usr/local/lib/lua/5.1/grid/txt/init.lua'
no file './grid/txt.so'
no file '/usr/local/lib/lua/5.1/grid/txt.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './grid.so'
no file '/usr/local/lib/lua/5.1/grid.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
I suspect that it's somehow possible to load the script into package.preaload['grid.txt'] (whatever that is) before calling require?
It depends on what you mean by load.
If you want to execute the code in a file named grid.txt in the current directory, then just do dofile"grid.txt". If grid.txt is in a different directory, give a path to it.
If you want to use the path search that require performs, then add a template for .txt in package.path, with the correct path and then do require"grid". Note the absence of suffix: require loads modules identified by names, not by paths.
If you want require("grid.txt") to work should someone try that then yes, you'll need to manually loadfile and run the script and put whatever it returns (or whatever require is documented to return when the module doesn't return anything) into package.loaded["grid.txt"].
Alternatively, you could write your own loader just for entries like this which you set into package.preload["grid.txt"] which finds and loads/runs the file or, more generically, you could write yourself a loader function, insert it into package.loaders, and then let it do its job whenever it sees a "*.txt" module come its way.

How to compute destination path for a file in InnoSetup dynamicaly?

I need to compute destination path for a file before copying. If the path does not exist I won't copy the file during installation.
Is this possible?
For example, can I call some computepath.exe an store the result into a variable?
You do not need to call a external program for that. Almost any computation can be done using pascal script, and you can then use the FileOrDirExists() function to determine if the path exists.
If that is not enough, you can take a different approach: extract the file to a temporary directory and call a computepathandcopy.exe passing the temp file name as a parameter. The exe will compute the path, check if it exists and perform the file copy.