Skip to content

Commit 367139b

Browse files
authored
Merge pull request #1462 from PLC-lang/target
feat: use the target triple without unknown in tests
2 parents d8f02b8 + fc767ed commit 367139b

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

.github/workflows/linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ jobs:
4949
run: |
5050
echo "Build command : ./scripts/build.sh --build --release"
5151
./scripts/build.sh --build --release --package \
52-
--target x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
52+
--target x86_64-linux-gnu,aarch64-linux-gnu, \
53+
x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
5354
5455
- uses: actions/upload-artifact@master
5556
with:

scripts/build.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ function run_std_build() {
9191
if [[ ! -z $target ]]; then
9292
for val in ${target//,/ }
9393
do
94+
# if the target ends with -linux-gnu but does not have unknown, add unknown
95+
if [[ $val == *"-linux-gnu" && $val != *"unknown-linux-gnu" ]]; then
96+
val="${val/-linux-gnu/-unknown-linux-gnu}"
97+
fi
9498
new_cmd="$cmd --target=$val"
9599
log "Running $new_cmd"
96100
eval "$new_cmd"
@@ -129,7 +133,7 @@ function run_doc() {
129133
log "Building book"
130134
log "Building preprocessor for the book"
131135
cargo build --release -p errorcode_book_generator
132-
cd book && mdbook build
136+
cd book && mdbook build
133137
# test is disabled because not all files in the book exist. The pre-processor for error codes adds new files
134138
# mdbook test
135139
}
@@ -163,7 +167,7 @@ function run_test() {
163167
rm -rf "$project_location/test_results"
164168
make_dir "$project_location/test_results"
165169
# JUnit test should run via cargo-nextest
166-
log "cargo-nextest nextest run $CARGO_OPTIONS --lib --profile ci \
170+
log "cargo-nextest nextest run $CARGO_OPTIONS --lib --profile ci \
167171
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/unit_tests.xml"
168172
cargo-nextest nextest run $CARGO_OPTIONS --lib --profile ci
169173
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/unit_tests.xml
@@ -176,11 +180,11 @@ function run_test() {
176180
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/integration_tests.xml
177181

178182
# Run the std integration
179-
log "cargo-nextest nextest run $CARGO_OPTIONS --profile ci -p iec61131std --test '*' \
183+
log "cargo-nextest nextest run $CARGO_OPTIONS --profile ci -p iec61131std --test '*' \
180184
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/std_integration_tests.xml"
181185
cargo-nextest nextest run $CARGO_OPTIONS --profile ci -p iec61131std --test '*'
182186
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/std_integration_tests.xml
183-
187+
184188
else
185189
cargo test $CARGO_OPTIONS --workspace
186190
fi
@@ -222,7 +226,12 @@ function run_package_std() {
222226
do
223227
lib_dir=$OUTPUT_DIR/$val/lib
224228
make_dir $lib_dir
225-
rel_dir="$target_dir/$val"
229+
230+
# if the target ends with -linux-gnu but does not have unknown, add unknown
231+
if [[ $val == *"-linux-gnu" && $val != *"unknown-linux-gnu" ]]; then
232+
rustc_target="${val/-linux-gnu/-unknown-linux-gnu}"
233+
fi
234+
rel_dir="$target_dir/$rustc_target"
226235
if [[ $release -ne 0 ]]; then
227236
rel_dir="$rel_dir/release"
228237
else

tests/integration/build_description_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ fn exports_env_variable() {
4545
"build",
4646
&get_test_file("json/build_to_temp.json"),
4747
"--target",
48-
"aarch64-unknown-linux-gnu",
48+
"aarch64-linux-gnu",
4949
"--build-location",
5050
dir.path().to_str().unwrap(),
5151
];
5252
compile(parameters).unwrap();
5353

54-
assert_eq!(std::env::var("ARCH").unwrap(), "aarch64-unknown-linux-gnu");
54+
assert_eq!(std::env::var("ARCH").unwrap(), "aarch64-linux-gnu");
5555
}
5656

5757
#[test]
@@ -86,13 +86,13 @@ fn build_with_target_but_without_sysroot() {
8686
"build",
8787
&get_test_file("json/build_without_sysroot.json"),
8888
"--target",
89-
"x86_64-unknown-linux-gnu",
89+
"x86_64-linux-gnu",
9090
"--build-location",
9191
dir.path().to_str().unwrap(),
9292
];
9393
compile(parameters).unwrap();
9494

95-
assert!(dir.path().join("x86_64-unknown-linux-gnu").join("proj.so").is_file());
95+
assert!(dir.path().join("x86_64-linux-gnu").join("proj.so").is_file());
9696
}
9797

9898
#[test]
@@ -102,15 +102,15 @@ fn build_with_cc_linker() {
102102
let dir = tempfile::tempdir().unwrap();
103103
let arch = match () {
104104
#[cfg(target_arch = "x86_64")]
105-
_ => "x86_64-unknown-linux-gnu",
105+
_ => "x86_64-linux-gnu",
106106

107107
#[cfg(target_arch = "aarch64")]
108108
_ => match () {
109109
#[cfg(target_os = "macos")]
110110
_ => "aarch64-apple-darwin",
111111

112112
#[cfg(not(target_os = "macos"))]
113-
_ => "aarch64-unknown-linux-gnu",
113+
_ => "aarch64-linux-gnu",
114114
},
115115
};
116116

tests/integration/external_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn compile_all(name: &str, encoding: Option<&'static Encoding>) {
1313
let out_name = format!("{}.out", &name);
1414
out.push(out_name);
1515
let out = out.into_os_string().into_string().unwrap();
16-
let mut main_args = vec!["plc", &path, "-o", &out, "-Odefault", "--target", "x86_64-unknown-linux-pc"];
16+
let mut main_args = vec!["plc", &path, "-o", &out, "-Odefault", "--target", "x86_64-linux-pc"];
1717
if let Some(encoding) = encoding {
1818
main_args.push("--encoding");
1919
main_args.push(encoding.name());

0 commit comments

Comments
 (0)