Travis Platformio,未运行test_main.cpp

时间:2018-11-05 16:27:12

标签: travis-ci platformio

我设法让Travis和PlatformIO一起工作。源代码是由Travis构建和检查的,但是我无法在test_main.cpp中找到测试结果。当我更改测试必须失败的源代码时,Travis也会返回成功。我该如何解决Travis检查test_main.cpp中的测试的问题,而不仅限于它是否已构建(我想它现在正在这样做)

Test_main.cpp

#include <Arduino.h>
#include <unity.h>

#define LED_BUILTIN 13

void setUp(void) {
// set stuff up here
}

void tearDown(void) {
// clean stuff up here
}

void test_led_builtin_pin_number(void) {
    TEST_ASSERT_EQUAL(13, LED_BUILTIN);
}

void test_led_state_high(void) {
    digitalWrite(LED_BUILTIN, HIGH);
    TEST_ASSERT_EQUAL(HIGH, digitalRead(LED_BUILTIN));
}

void test_led_state_low(void) {
    digitalWrite(LED_BUILTIN, LOW);
    TEST_ASSERT_EQUAL(HIGH, digitalRead(LED_BUILTIN));
}

void setup() {
    // NOTE!!! Wait for >2 secs
    // if board doesn't support software reset via Serial.DTR/RTS
    delay(2000);

    UNITY_BEGIN();    // IMPORTANT LINE!
    RUN_TEST(test_led_builtin_pin_number);

    pinMode(LED_BUILTIN, OUTPUT);
}

uint8_t i = 0;
uint8_t max_blinks = 5;

void loop() {
    if (i < max_blinks)
    {
        RUN_TEST(test_led_state_high);
        delay(500);
        RUN_TEST(test_led_state_low);
        delay(500);
        i++;
    }
    else if (i == max_blinks) {
      UNITY_END(); // stop unit testing
    }
}

.Travis.yml

language: python
python:
    - "2.7"

sudo: false
cache:
    directories:
        - "~/.platformio"

install:
     - pip install -U platformio
     - platformio lib -g install https://github.com/ThrowTheSwitch/Unity.git

env:
    - PLATFORMIO_CI_SRC=test/test_main.cpp

script:
    # - platformio ci --project-conf=platformio.ini
    - platformio ci --lib="." --board=esp32dev

Platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:MainBoard]
platform = espressif32
board = esp32dev
framework = arduino

travis结果的最后一部分

Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-spi.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-time.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-timer.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-touch.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-uart.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/libb64/cdecode.c.o
Archiving .pioenvs/esp32dev/libe4e/libUnity.a
Compiling .pioenvs/esp32dev/FrameworkArduino/libb64/cencode.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/main.cpp.o
Indexing .pioenvs/esp32dev/libe4e/libUnity.a
Compiling .pioenvs/esp32dev/FrameworkArduino/stdlib_noniso.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/wiring_pulse.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/wiring_shift.c.o
Archiving .pioenvs/esp32dev/libFrameworkArduino.a
Indexing .pioenvs/esp32dev/libFrameworkArduino.a
Linking .pioenvs/esp32dev/firmware.elf
Building .pioenvs/esp32dev/firmware.bin
Retrieving maximum program size .pioenvs/esp32dev/firmware.elf
Checking size .pioenvs/esp32dev/firmware.elf
Memory Usage -> 
DATA:    [          ]   4.3% (used 14008 bytes from 327680 bytes)
PROGRAM: [=         ]  13.9% (used 182772 bytes from 1310720 bytes)
========================= [SUCCESS] Took 5.53 seconds =========================
The command "platformio ci --lib="." --board=esp32dev" exited with 0.
cache.2
store build cache
0.00s
1.65snothing changed, not updating cache
Done. Your build exited with 0.

0 个答案:

没有答案