-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_target_test.sh
More file actions
32 lines (27 loc) · 1.07 KB
/
set_target_test.sh
File metadata and controls
32 lines (27 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Ensure a test header file is passed as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <test-header-file>"
exit 1
fi
# Create a CPP header file with configuration definitions
echo // Configuration settings for the current test > include/config.h
echo // This file is generated by vscode on build - DO NOT EDIT >> include/config.h
echo >> include/config.h
echo "#pragma once" >> include/config.h
echo >> include/config.h
echo "#define LOCAL_TEST" >> include/config.h
echo "#define TEST_FUNC plusOne" >> include/config.h;
echo >> include/config.h
# Append necessary lines from the tests file
sed '/ TEST TYPES/q' $1/$1-tests.cpp >> include/config.h
echo >> include/config.h
# copy the test template to the test directory for this leetcode solution
if [ ! -f "$1/$1-tests.cpp" ]; then
# If it doesn't exist, copy the test template
cp include/testTemplate.txt "$1/$1-tests.cpp"
echo "Created new test file: $1/$1-tests.cpp"
else
echo "Test file $1/$1-tests.cpp already exists. Skipping creation."
fi
sed -i '' "26s|.*|#include \"$1.cpp\"|" $1/$1-tests.cpp